Пример #1
0
        /// <inheritdoc />
        public async Task RescindInfractionAsync(long infractionId, string reason)
        {
            AuthorizationService.RequireClaims(AuthorizationClaim.ModerationRescind);

            var infraction = await InfractionRepository.ReadAsync(infractionId);

            if (infraction == null)
            {
                throw new ArgumentException("Infraction does not exist", nameof(infractionId));
            }

            switch (infraction.Type)
            {
            case InfractionType.Mute:
                await DoDiscordUnMuteAsync(infraction.Subject.Id);

                break;

            case InfractionType.Ban:
                await DoDiscordUnBanAsync(infraction.Subject.Id);

                break;
            }

            var actionId = await ModerationActionRepository.CreateAsync(new ModerationActionCreationData()
            {
                Type         = ModerationActionType.InfractionRescinded,
                CreatedById  = AuthorizationService.CurrentUserId.Value,
                Reason       = reason,
                InfractionId = infractionId
            });

            // TODO: Log action to a channel, pulled from IModerationConfigRepository.
        }