Skip to content

Commit 0eb8db7

Browse files
fix: staff report reason when closing should be optional
1 parent b67a78d commit 0eb8db7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/lib/reports.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ const getReports = async ({
273273
assignedStaffId: assignedFilter,
274274

275275
...(guildId !== undefined && { guildId: BigInt(guildId) }),
276-
...(filterByUser !== undefined && { reportingUserId: BigInt(filterByUser) }),
276+
...(filterByUser !== undefined && {
277+
reportingUserId: BigInt(filterByUser),
278+
}),
277279
},
278280
orderBy: {
279281
createdAt: "desc",
@@ -557,6 +559,10 @@ const createReportMessage = async ({
557559
ReportMessages: true,
558560
},
559561
});
562+
// validate content
563+
if (content.length < 1) {
564+
throw new BadRequest("Content must not be empty")
565+
}
560566
if (report === null) {
561567
throw new NotFound("report not found");
562568
}
@@ -842,7 +848,7 @@ const closeReport = async ({
842848
instance: FastifyInstance;
843849
user: UserRequestData;
844850
reportId: string;
845-
staffReportReason: string;
851+
staffReportReason?: string;
846852
messageToReportingUser: string;
847853
closeStatus: ReportCloseStatusEnum;
848854
}) => {
@@ -881,7 +887,7 @@ const closeReport = async ({
881887
},
882888
});
883889

884-
if (staffReportReason !== undefined) {
890+
if (staffReportReason !== undefined && staffReportReason.length > 0) {
885891
await createReportMessage({
886892
instance,
887893
reportId,

src/v1/routes/reports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ type PUTAssignedUserBodyType = Static<typeof PUTAssignedUserBody>;
8282
const CloseReportBody = Type.Object({
8383
status: Type.Enum(ReportCloseStatusEnum),
8484
message_to_reporting_user: Type.String(),
85-
staff_report_reason: Type.String(),
85+
staff_report_reason: Type.Optional(Type.String()),
8686
});
8787

8888
type CloseReportBodyType = Static<typeof CloseReportBody>;

0 commit comments

Comments
 (0)