Files
library/apps/frontend/src/app/services/report.service.ts
T
hikari d797d38ddd feat: implement profile reporting system with admin review
Added comprehensive profile reporting system to allow users to report
inappropriate profiles and admins to review reports.

Features:
- User can report profiles with predefined reasons + custom details
- Duplicate prevention (one pending report per profile per user)
- Rate limiting (5 pending reports maximum per user)
- Admin dashboard to view and filter reports (All, Pending, Reviewed, etc.)
- Admin review modal to update status and add review notes
- Report button on profile page (only visible when viewing others)
- Font Awesome icons for better UI consistency

Database changes:
- New ProfileReport model with ReportReason/ReportStatus enums
- User relations for reports (reportsMade, reportsReceived, reportsReviewed)
- Indices for efficient querying
2026-02-19 18:33:58 -08:00

75 lines
2.1 KiB
TypeScript

/**
* @copyright 2026 NHCarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { Injectable, inject } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiService } from './api.service';
import type {
ProfileReportWithUsers,
CreateReportDto,
ReportStatus
} from '@library/shared-types';
@Injectable({
providedIn: 'root'
})
export class ReportService {
private api = inject(ApiService);
/**
* Create a new profile report.
*
* @param reportedUserId - The ID of the user being reported
* @param reason - The reason for the report
* @param details - Additional details about the report
* @returns Observable of the created report
*/
createReport(reportedUserId: string, reason: string, details: string): Observable<ProfileReportWithUsers> {
const dto: CreateReportDto = {
reportedUserId,
reason: reason as CreateReportDto['reason'],
details
};
return this.api.post<ProfileReportWithUsers>('/reports', dto);
}
/**
* Get all reports (admin only). Optionally filter by status.
*
* @param status - Optional status to filter by
* @returns Observable of all matching reports
*/
getAllReports(status?: ReportStatus): Observable<ProfileReportWithUsers[]> {
const url = status ? `/reports?status=${status}` : '/reports';
return this.api.get<ProfileReportWithUsers[]>(url);
}
/**
* Get a specific report by ID (admin only).
*
* @param id - The report ID
* @returns Observable of the report
*/
getReportById(id: string): Observable<ProfileReportWithUsers> {
return this.api.get<ProfileReportWithUsers>(`/reports/${id}`);
}
/**
* Update a report's status and review notes (admin only).
*
* @param id - The report ID
* @param status - The new status
* @param reviewNotes - Optional review notes
* @returns Observable of the updated report
*/
updateReport(id: string, status: ReportStatus, reviewNotes?: string): Observable<ProfileReportWithUsers> {
return this.api.put<ProfileReportWithUsers>(`/reports/${id}`, {
status,
reviewNotes
});
}
}