/* * Copyright (C) 2026 Fluxer Contributors * * This file is part of Fluxer. * * Fluxer is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Fluxer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Fluxer. If not, see . */ import type {ChannelID, GuildID, MessageID, ReportID, UserID} from '@fluxer/api/src/BrandedTypes'; import type {MessageAttachment, MessageEmbed, MessageStickerItem} from '@fluxer/api/src/database/types/MessageTypes'; import type {DSAReportEmailVerificationRow, DSAReportTicketRow} from '@fluxer/api/src/database/types/ReportTypes'; export enum ReportStatus { PENDING = 0, RESOLVED = 1, } export enum ReportType { MESSAGE = 0, USER = 1, GUILD = 2, } const REPORT_STATUS_STRINGS: Record = { [ReportStatus.PENDING]: 'pending', [ReportStatus.RESOLVED]: 'resolved', }; export function reportStatusToString(status: ReportStatus | number): string { return REPORT_STATUS_STRINGS[status as ReportStatus] ?? 'unknown'; } type MentionCollection = ReadonlyArray | Set | null | undefined; export interface IARMessageContextRow { message_id: bigint; channel_id: bigint | null; author_id: bigint; author_username: string; author_discriminator: number; author_avatar_hash: string | null; content: string | null; timestamp: Date; edited_timestamp: Date | null; type: number; flags: number; mention_everyone: boolean; mention_users: MentionCollection; mention_roles: MentionCollection; mention_channels: MentionCollection; attachments: Array | null; embeds: Array | null; sticker_items: Array | null; } export interface IARMessageContext { messageId: MessageID; channelId: ChannelID | null; authorId: UserID; authorUsername: string; authorDiscriminator: number; authorAvatarHash: string | null; content: string | null; timestamp: Date; editedTimestamp: Date | null; type: number; flags: number; mentionEveryone: boolean; mentionUsers: Array; mentionRoles: Array; mentionChannels: Array; attachments: Array; embeds: Array; stickers: Array; } export interface IARSubmissionRow { report_id: bigint; reporter_id: bigint | null; reporter_email: string | null; reporter_full_legal_name: string | null; reporter_country_of_residence: string | null; reported_at: Date; status: number; report_type: number; category: string; additional_info: string | null; reported_user_id: bigint | null; reported_user_avatar_hash: string | null; reported_guild_id: bigint | null; reported_guild_name: string | null; reported_guild_icon_hash: string | null; reported_message_id: bigint | null; reported_channel_id: bigint | null; reported_channel_name: string | null; message_context: Array | null; guild_context_id: bigint | null; resolved_at: Date | null; resolved_by_admin_id: bigint | null; public_comment: string | null; audit_log_reason: string | null; reported_guild_invite_code: string | null; } export interface IARSubmission { reportId: ReportID; reporterId: UserID | null; reporterEmail: string | null; reporterFullLegalName: string | null; reporterCountryOfResidence: string | null; reportedAt: Date; status: number; reportType: number; category: string; additionalInfo: string | null; reportedUserId: UserID | null; reportedUserAvatarHash: string | null; reportedGuildId: GuildID | null; reportedGuildName: string | null; reportedGuildIconHash: string | null; reportedMessageId: MessageID | null; reportedChannelId: ChannelID | null; reportedChannelName: string | null; messageContext: Array | null; guildContextId: GuildID | null; resolvedAt: Date | null; resolvedByAdminId: UserID | null; publicComment: string | null; auditLogReason: string | null; reportedGuildInviteCode: string | null; } export abstract class IReportRepository { abstract createReport(data: IARSubmissionRow): Promise; abstract getReport(reportId: ReportID): Promise; abstract resolveReport( reportId: ReportID, resolvedByAdminId: UserID, publicComment: string | null, auditLogReason: string | null, ): Promise; abstract listAllReportsPaginated(limit: number, lastReportId?: ReportID): Promise>; abstract upsertDsaEmailVerification(row: DSAReportEmailVerificationRow): Promise; abstract deleteDsaEmailVerification(emailLower: string): Promise; abstract getDsaEmailVerification(emailLower: string): Promise; abstract createDsaTicket(row: DSAReportTicketRow): Promise; abstract getDsaTicket(ticket: string): Promise; abstract deleteDsaTicket(ticket: string): Promise; }