Ejemplo n.º 1
0
        public UserUnverifyHistoryItem(UnverifyLog logItem)
        {
            var data = logItem.Json.ToObject <UnverifyLogSet>();

            AuditID        = logItem.ID;
            IsSelfUnverify = data.IsSelfUnverify;
            Time           = TimeSpan.FromSeconds(Convert.ToInt32(data.TimeFor));
            Reason         = data.Reason;
        }
Ejemplo n.º 2
0
        public async Task LogOperationAsync(UnverifyLogOperation operation, IUser fromUser, IGuild guild, UnverifyLogDataBase data)
        {
            var entity = new UnverifyLog()
            {
                Data       = JsonConvert.SerializeObject(data),
                DateTime   = DateTime.Now,
                GuildID    = guild.Id.ToString(),
                Operation  = operation,
                FromUserID = fromUser.Id.ToString()
            };

            await Context.UnverifyLog.AddAsync(entity).ConfigureAwait(false);

            await Context.SaveChangesAsync().ConfigureAwait(false);
        }
Ejemplo n.º 3
0
        public void LogOperation(UnverifyLogOperation operation, IUser fromUser, IGuild guild, IUser toUser, object data)
        {
            var entity = new UnverifyLog()
            {
                Data                = JsonConvert.SerializeObject(data),
                DateTime            = DateTime.Now,
                GuildIDSnowflake    = guild.Id,
                Operation           = operation,
                FromUserIDSnowflake = fromUser.Id,
                DestUserIDSnowflake = toUser.Id
            };

            Context.UnverifyLog.Add(entity);
            Context.SaveChanges();
        }
Ejemplo n.º 4
0
        public async Task <UnverifyLog> SaveLogOperationAsync(UnverifyLogOperation operation, JObject jsonData, long fromUserID, long toUserID)
        {
            var entity = new UnverifyLog()
            {
                CreatedAt  = DateTime.Now,
                FromUserID = fromUserID,
                Json       = jsonData,
                Operation  = operation,
                ToUserID   = toUserID
            };

            await GrillBotRepository.AddAsync(entity);

            await GrillBotRepository.CommitAsync();

            return(entity);
        }
Ejemplo n.º 5
0
        public UnverifyAuditItem(UnverifyLog log, DiscordSocketClient client)
        {
            ID        = log.ID;
            Operation = log.Operation;
            DateTime  = log.DateTime;
            Guild     = client.GetGuild(log.GuildIDSnowflake);

            switch (log.Operation)
            {
            case UnverifyLogOperation.AutoRemove:
            case UnverifyLogOperation.Remove:
            {
                var data = log.Json.ToObject <UnverifyLogRemove>();
                RemoveLogData = new AuditItemRemoveOperation()
                {
                    OverridedChannels = data.Overrides.Select(o => Guild.GetChannel(o.ChannelIdSnowflake)).Where(o => o != null).ToList(),
                    Roles             = data.Roles.Select(o => Guild.GetRole(o)).ToList()
                };
            }
            break;

            case UnverifyLogOperation.Set:
            {
                var data = log.Json.ToObject <UnverifyLogSet>();
                SetLogData = new AuditItemSetOperation()
                {
                    OverridedChannels = data.Overrides.Select(o => Guild.GetChannel(o.ChannelIdSnowflake)).Where(o => o != null).ToList(),
                    Roles             = data.Roles.Select(o => Guild.GetRole(o)).ToList(),
                    Reason            = data.Reason,
                    StartAt           = data.StartAt,
                    Time           = data.TimeFor,
                    IsSelfUnverify = data.IsSelfUnverify,
                    Subjects       = data.Subjects ?? new List <string>()
                };
            }
            break;

            case UnverifyLogOperation.Update:
                UpdateLogData = new AuditItemUpdateOperation()
                {
                    Time = log.Json.ToObject <UnverifyLogUpdate>().TimeFor
                };
                break;
            }
        }
Ejemplo n.º 6
0
        public UnverifyLogItem(UnverifyLog entity, DiscordSocketClient client)
        {
            var guild = client.GetGuild(entity.FromUser.GuildIDSnowflake);

            ID        = entity.ID;
            Operation = entity.Operation;
            DateTime  = entity.CreatedAt;
            FromUser  = guild.GetUserFromGuildAsync(entity.FromUser.UserIDSnowflake).Result;
            ToUser    = guild.GetUserFromGuildAsync(entity.ToUser.UserIDSnowflake).Result;

            switch (entity.Operation)
            {
            case UnverifyLogOperation.Autoremove:
            case UnverifyLogOperation.Remove:
            case UnverifyLogOperation.Recover:
                var removeLogData = entity.Json.ToObject <UnverifyLogRemove>();
                RemoveData = new UnverifyRemoveOperation()
                {
                    ReturnedChannels = removeLogData.ReturnedOverrides.Select(o => guild.GetChannel(o.ChannelID)).Where(o => o != null).ToList(),
                    ReturnedRoles    = removeLogData.ReturnedRoles.Select(o => guild.GetRole(o)).Where(o => o != null).ToList()
                };
                break;

            case UnverifyLogOperation.Selfunverify:
            case UnverifyLogOperation.Unverify:
                var logData = entity.Json.ToObject <UnverifyLogSet>();
                Profile = new UnverifyUserProfile()
                {
                    EndDateTime      = logData.EndDateTime,
                    Reason           = logData.Reason,
                    StartDateTime    = logData.StartDateTime,
                    ChannelsToKeep   = logData.ChannelsToKeep.Select(o => new ChannelOverwrite(guild.GetChannel(o.ChannelID), new OverwritePermissions(o.AllowValue, o.DenyValue))).Where(o => o.Channel != null).ToList(),
                    ChannelsToRemove = logData.ChannelsToRemove.Select(o => new ChannelOverwrite(guild.GetChannel(o.ChannelID), new OverwritePermissions(o.AllowValue, o.DenyValue))).Where(o => o.Channel != null).ToList(),
                    RolesToKeep      = logData.RolesToKeep.Select(o => guild.GetRole(o)).Where(o => o != null).ToList(),
                    RolesToRemove    = logData.RolesToRemove.Select(o => guild.GetRole(o)).Where(o => o != null).ToList()
                };
                break;

            case UnverifyLogOperation.Update:
                UpdateData = entity.Json.ToObject <UnverifyLogUpdate>();
                break;
            }
        }