( req: MonkeyRequest<undefined, ReportQuoteRequest>, )
| 137 | } |
| 138 | |
| 139 | export async function reportQuote( |
| 140 | req: MonkeyRequest<undefined, ReportQuoteRequest>, |
| 141 | ): Promise<MonkeyResponse> { |
| 142 | const { uid } = req.ctx.decodedToken; |
| 143 | const { |
| 144 | reporting: { maxReports, contentReportLimit }, |
| 145 | } = req.ctx.configuration.quotes; |
| 146 | |
| 147 | const { quoteId, quoteLanguage, reason, comment, captcha } = req.body; |
| 148 | |
| 149 | await verifyCaptcha(captcha); |
| 150 | |
| 151 | const newReport: ReportDAL.DBReport = { |
| 152 | _id: new ObjectId(), |
| 153 | id: uuidv4(), |
| 154 | type: "quote", |
| 155 | timestamp: new Date().getTime(), |
| 156 | uid, |
| 157 | contentId: `${quoteLanguage}-${quoteId}`, |
| 158 | reason, |
| 159 | comment: comment ?? "", |
| 160 | }; |
| 161 | |
| 162 | await ReportDAL.createReport(newReport, maxReports, contentReportLimit); |
| 163 | |
| 164 | return new MonkeyResponse("Quote reported", null); |
| 165 | } |
nothing calls this directly
no test coverage detected