/// <summary>
 /// Replaces "LockPost" with "lock" since "lock" is a reserved word and can't be used in the enum
 /// </summary>
 /// <returns>String representation of enum value recognized by Reddit's api</returns>
 public static string GetRedditParamName(ModActionType action)
 {
     if (action == ModActionType.LockPost)
     {
         return("lock");
     }
     else
     {
         return(action.ToString("g").ToLower());
     }
 }
        /// <summary>
        /// Record the action taken by a moderator by setting the action on the object which it is related to, updates the moderators profiles (adds points)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="type"></param>
        /// <param name="original"></param>
        /// <param name="updated"></param>
        /// <param name="modMeta"></param>
        /// <param name="modMetaUpdateAction"></param>
        /// <param name="modProfileUpdateAction"></param>
        /// <param name="descriptionFormat"></param>
        /// <param name="descriptionArgs"></param>
        internal ModAction SaveModActionAndUpdateModProfile <T>(ModActionType type, T original, T updated, ObjectModMeta modMeta,
                                                                Action <ObjectModMeta, Guid> modMetaUpdateAction, Action <ModProfile> modProfileUpdateAction,
                                                                string descriptionFormat, params object[] descriptionArgs) where T : IOOObject, new ()
        {
            ModAction action;
            //-- Generate a unique ID for the action
            var newActionID = Guid.NewGuid();

            //-- Look up the points associated with the action
            byte reputationPointsForAction = type.GetPoints();

            //-- Description (Used for the mod action feed)
            string actionDescription = currentUser.FullName + " " + string.Format(descriptionFormat, descriptionArgs);

            //-- TODO wrap this in a transaction/single data hit
            {
                //-- Step 1 save the mod action
                action = modActionRepo.Create(new ModAction()
                {
                    ID          = newActionID,
                    TypeID      = (int)type,
                    OnObjectID  = modMeta.ID,
                    Description = actionDescription,
                    Data        = original.DifferenceAsJson(updated, original.GetCompareIgnorePropertyNames()),
                    UserID      = currentUser.UserID,
                    Utc         = DateTime.UtcNow,
                    Points      = reputationPointsForAction,
                    Comment     = string.Empty
                });

                //-- Step 2 update the objModMeta Action Foreign Key & update the object
                if (modMetaUpdateAction != null)
                {
                    modMetaUpdateAction(modMeta, newActionID);
                }
                objModMetaRepo.Update(modMeta);

                //-- Step 3 is update the moderators profile
                if (modProfileUpdateAction != null)
                {
                    modProfileUpdateAction(CfPrincipal.ModDetails);
                }
                CfPrincipal.ModDetails.LastActivityUtc = DateTime.UtcNow;
                CfPrincipal.ModDetails.Reputation     += reputationPointsForAction;
                modProfileRepo.Update(CfPrincipal.ModDetails);
            }

            return(action);
        }
Esempio n. 3
0
        public ModAction(string target, Player actor, ModActionType type,
                         string reason = null, TimeSpan duration = default(TimeSpan))
        {
            Target = target;
            Actor  = actor;
            Type   = type;

            if (reason == null)
            {
                reason = "";
            }
            Reason   = reason;
            Duration = duration;
            Announce = true;
        }
Esempio n. 4
0
        string GetActionType(ModActionType type)
        {
            switch (type)
            {
            case ModActionType.Ban:
                return("banned");

            case ModActionType.BanIP:
                return("IP Banned");

            case ModActionType.UnbanIP:
                return("IP Unbanned");

            case ModActionType.Muted:
                return("Muted");

            case ModActionType.Unmuted:
                return("Unmuted");

            case ModActionType.Frozen:
                return("Frozen");

            case ModActionType.Unfrozen:
                return("Unfrozen");

            case ModActionType.Jailed:
                return("Jailed");

            case ModActionType.Unjailed:
                return("Unjailed");

            case ModActionType.Warned:
                return("Warned");

            case ModActionType.Rank:
                return("Ranked");

            case ModActionType.Kicked:
                return("Kicked");

            default:
                return("Punished");
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Gets the moderation log of the current subreddit filtered by the action taken and moderator(s) who performed the action
 /// </summary>
 /// <param name="action">ModActionType of action performed</param>
 /// <param name="mods">String array of mods to filter by</param>
 /// <returns></returns>
 public Listing <ModAction> GetModerationLog(ModActionType action, string[] mods)
 {
     return(new Listing <ModAction>(Reddit, string.Format(ModLogUrl + "?type={1}&mod={2}", Name, ModActionTypeConverter.GetRedditParamName(action), string.Join(",", mods)), WebAgent));
 }
Esempio n. 6
0
 public WeGroupProduct(string productId, ModActionType modaction)
 {
     ModAction = modaction;
 }
Esempio n. 7
0
 /// <summary>
 /// Replaces "LockPost" with "lock" since "lock" is a reserved word and can't be used in the enum
 /// </summary>
 /// <returns>String representation of enum value recognized by Reddit's api</returns>
 public static string GetRedditParamName(ModActionType action)
 {
     if (action == ModActionType.LockPost) return "lock";
     else return action.ToString("g").ToLower();
 }
Esempio n. 8
0
 public ModActionEventArgs WithActionType(ModActionType type)
 {
     ActionType = type;
     return(this);
 }
Esempio n. 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="Action"></param>
 /// <param name="Type"></param>
 public ModActions(string Action, ModActionType Type)
 {
     this.Action = Action;
     this.Type   = Type;
 }
Esempio n. 10
0
 /// <summary>
 /// Gets the moderation log of the current subreddit filtered by the action taken and moderator(s) who performed the action
 /// </summary>
 /// <param name="action">ModActionType of action performed</param>
 /// <param name="mods">String array of mods to filter by</param>
 /// <returns></returns>
 public Listing<ModAction> GetModerationLog(ModActionType action, string[] mods)
 {
     return new Listing<ModAction>(Reddit, string.Format(ModLogUrl + "?type={1}&mod={2}", Name, ModActionTypeConverter.GetRedditParamName(action), string.Join(",", mods)), WebAgent);
 }
Esempio n. 11
0
 /// <summary>
 /// Gets the moderation log of the current subreddit filtered by the action taken
 /// </summary>
 /// <param name="action">ModActionType of action performed</param>
 public Listing<ModAction> GetModerationLog(ModActionType action)
 {
     return new Listing<ModAction>(Reddit, string.Format(ModLogUrl + "?type={1}", Name, ModActionTypeConverter.GetRedditParamName(action)), WebAgent);
 }
Esempio n. 12
0
 public static byte GetPoints(this ModActionType modActionType)
 {
     return(modActionTypeToPoints[modActionType]);
 }
Esempio n. 13
0
        /// <summary>
        /// Gets the moderation log of the current subreddit filtered by the action taken and moderator(s) who performed the action
        /// </summary>
        /// <param name="action">ModActionType of action performed.</param>
        /// <param name="mods">String array of mods to filter by.</param>
        /// <param name="max">Maximum number of records to return.</param>
        /// <returns></returns>
        public Listing <ModAction> GetModerationLog(ModActionType action, IEnumerable <string> mods, int max = -1)
        {
            var url = $"{ModLogUrl}?type={action}";

            return(Listing <ModAction> .Create(WebAgent, url, max, 500));
        }
Esempio n. 14
0
        /// <summary>
        /// Gets the moderation log of the current subreddit filtered by the action taken
        /// </summary>
        /// <param name="action">ModActionType of action performed</param>
        /// <param name="max">Maximum number of records to return.</param>
        public Listing <ModAction> GetModerationLog(ModActionType action, int max = -1)
        {
            var url = $"{ModLogUrl}?type={action.ToString("g").ToLower()}";

            return(Listing <ModAction> .Create(WebAgent, url, max, 500));
        }