using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Services; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; namespace DysonNetwork.Pass.Safety; public class SafetyService(AppDatabase db, IAccountService accountService, ILogger logger) { public async Task CreateReport(string resourceIdentifier, AbuseReportType type, string reason, Guid accountId) { // Check if a similar report already exists from this user var existingReport = await db.AbuseReports .Where(r => r.ResourceIdentifier == resourceIdentifier && r.AccountId == accountId && r.DeletedAt == null) .FirstOrDefaultAsync(); if (existingReport != null) { throw new InvalidOperationException("You have already reported this content."); } return await accountService.CreateAbuseReport(resourceIdentifier, type, reason, accountId); } public async Task CountReports(bool includeResolved = false) { return await accountService.CountAbuseReports(includeResolved); } public async Task CountUserReports(Guid accountId, bool includeResolved = false) { return await accountService.CountUserAbuseReports(accountId, includeResolved); } public async Task> GetReports(int skip = 0, int take = 20, bool includeResolved = false) { return await accountService.GetAbuseReports(skip, take, includeResolved); } public async Task> GetUserReports(Guid accountId, int skip = 0, int take = 20, bool includeResolved = false) { return await accountService.GetUserAbuseReports(accountId, skip, take, includeResolved); } public async Task GetReportById(Guid id) { return await accountService.GetAbuseReport(id); } public async Task ResolveReport(Guid id, string resolution) { return await accountService.ResolveAbuseReport(id, resolution); } public async Task GetPendingReportsCount() { return await accountService.GetPendingAbuseReportsCount(); } }