MCPcopy Create free account
hub / github.com/monkeytypegame/monkeytype / reportUser

Function reportUser

backend/src/api/controllers/user.ts:1086–1112  ·  view source on GitHub ↗
(
  req: MonkeyRequest<undefined, ReportUserRequest>,
)

Source from the content-addressed store, hash-verified

1084}
1085
1086export async function reportUser(
1087 req: MonkeyRequest<undefined, ReportUserRequest>,
1088): Promise<MonkeyResponse> {
1089 const { uid } = req.ctx.decodedToken;
1090 const {
1091 reporting: { maxReports, contentReportLimit },
1092 } = req.ctx.configuration.quotes;
1093
1094 const { uid: uidToReport, reason, comment, captcha } = req.body;
1095
1096 await verifyCaptcha(captcha);
1097
1098 const newReport: ReportDAL.DBReport = {
1099 _id: new ObjectId(),
1100 id: uuidv4(),
1101 type: "user",
1102 timestamp: new Date().getTime(),
1103 uid,
1104 contentId: `${uidToReport}`,
1105 reason,
1106 comment: comment ?? "",
1107 };
1108
1109 await ReportDAL.createReport(newReport, maxReports, contentReportLimit);
1110
1111 return new MonkeyResponse("User reported", null);
1112}
1113
1114export async function setStreakHourOffset(
1115 req: MonkeyRequest<undefined, SetStreakHourOffsetRequest>,

Callers

nothing calls this directly

Calls 1

verifyCaptchaFunction · 0.70

Tested by

no test coverage detected