Exemple #1
0
        /// <inheritdoc />
        public async Task <ServiceResult> RescindInfractionAsync(InfractionType type, ulong subjectId)
        {
            var authResult = AuthorizationService.CheckClaims(AuthorizationClaim.ModerationRescind);

            if (authResult.IsFailure)
            {
                return(authResult);
            }

            var rankResult = await RequireSubjectRankLowerThanModeratorRankAsync(AuthorizationService.CurrentGuildId.Value, subjectId);

            if (rankResult.IsFailure)
            {
                return(rankResult);
            }

            await DoRescindInfractionAsync(
                (await InfractionRepository.SearchSummariesAsync(
                     new InfractionSearchCriteria()
            {
                GuildId = AuthorizationService.CurrentGuildId.Value,
                Types = new [] { type },
                SubjectId = subjectId,
                IsRescinded = false,
                IsDeleted = false,
            }))
                .FirstOrDefault());

            return(ServiceResult.FromSuccess());
        }
Exemple #2
0
        /// <inheritdoc />
        public async Task RescindInfractionAsync(InfractionType type, ulong subjectId)
        {
            AuthorizationService.RequireAuthenticatedGuild();
            AuthorizationService.RequireAuthenticatedUser();
            AuthorizationService.RequireClaims(AuthorizationClaim.ModerationRescind);

            await DoRescindInfractionAsync(
                (await InfractionRepository.SearchSummariesAsync(
                     new InfractionSearchCriteria()
            {
                GuildId = AuthorizationService.CurrentGuildId.Value,
                Types = new [] { type },
                SubjectId = subjectId,
                IsRescinded = false,
                IsDeleted = false,
            }))
                .FirstOrDefault());
        }
Exemple #3
0
        /// <inheritdoc />
        public async Task RescindInfractionAsync(InfractionType type, ulong subjectId, string reason = null)
        {
            AuthorizationService.RequireAuthenticatedGuild();
            AuthorizationService.RequireAuthenticatedUser();
            AuthorizationService.RequireClaims(AuthorizationClaim.ModerationRescind);

            if (reason?.Length >= MaxReasonLength)
            {
                throw new ArgumentException($"Reason must be less than {MaxReasonLength} characters in length", nameof(reason));
            }

            await DoRescindInfractionAsync(
                (await InfractionRepository.SearchSummariesAsync(
                     new InfractionSearchCriteria()
            {
                GuildId = AuthorizationService.CurrentGuildId.Value,
                Types = new[] { type },
                SubjectId = subjectId,
                IsRescinded = false,
                IsDeleted = false,
            }))
                .FirstOrDefault(), reason);
        }
Exemple #4
0
        /// <inheritdoc />
        public Task <IReadOnlyCollection <InfractionSummary> > SearchInfractionsAsync(InfractionSearchCriteria searchCriteria, IEnumerable <SortingCriteria> sortingCriteria = null)
        {
            AuthorizationService.RequireClaims(AuthorizationClaim.ModerationRead);

            return(InfractionRepository.SearchSummariesAsync(searchCriteria, sortingCriteria));
        }
Exemple #5
0
 /// <inheritdoc />
 public async Task <ServiceResult <IReadOnlyCollection <InfractionSummary> > > SearchInfractionsAsync(InfractionSearchCriteria searchCriteria, IEnumerable <SortingCriteria> sortingCriteria = null)
 => await AuthorizationService.CheckClaims(AuthorizationClaim.ModerationRead)
 .ShortCircuitAsync(InfractionRepository.SearchSummariesAsync(searchCriteria, sortingCriteria));