Beispiel #1
0
        public async Task <bool> CanReportViolationAsync(IReportable reportObject)
        {
            var currentUser = await getCurrentUserOrNullAsync();

            if (currentUser == null || currentUser.Status.State != ProfileState.ACTIVE)
            {
                return(false);
            }
            else
            {
                return(await isNotDeletedAsync(reportObject) &&
                       currentUser.Id != reportObject.Author.Id &&
                       currentUser.Role >= Role.MODERATOR &&
                       (reportObject.As <IModeratable>()?.ModerationInfo?.State ?? ModerationState.MODERATED) == ModerationState.MODERATED);
            }
        }
Beispiel #2
0
        public async Task <bool> CanReportAsync(IReportable reportObject)
        {
            var currentUser = await getCurrentUserOrNullAsync();

            if (currentUser == null || currentUser.Status.State != ProfileState.ACTIVE)
            {
                return(false);
            }
            else
            {
                return(await isNotDeletedAsync(reportObject) &&
                       currentUser.Id != reportObject.Author.Id &&
                       !reportObject.Reports.Any(r => r.Reporter.Id == currentUser.Id) && // Already reported
                       (reportObject.As <IModeratable>()?.ModerationInfo?.State ?? ModerationState.MODERATED) == ModerationState.MODERATED &&
                       currentUser.Role == Role.USER);
            }
        }