Compare commits

..

No commits in common. "3dd56bc471be9e9668b65ffcf45f023b4619ecb7" and "0280e2a277557340ff25962ed892f0dfabdd74c4" have entirely different histories.

View File

@ -50,7 +50,12 @@ export const POST = (async ({ request, cookies }) => {
let reports = await Report.findAll({ let reports = await Report.findAll({
where: reportFindOptions, where: reportFindOptions,
include: [{ all: true }], include: [
{ model: User, as: 'reporter' },
{ model: User, as: 'reported' },
{ model: Admin, as: 'auditor' },
{ model: StrikeReason, as: 'strike_reason' }
],
order: [['created_at', 'DESC']], order: [['created_at', 'DESC']],
offset: data.from || 0, offset: data.from || 0,
limit: data.limit || 100 limit: data.limit || 100
@ -134,10 +139,7 @@ export const PATCH = (async ({ request, cookies }) => {
} else if (data.strike_reason == -1 && report.strike_reason_id != null) { } else if (data.strike_reason == -1 && report.strike_reason_id != null) {
report.strike_reason_id = null; report.strike_reason_id = null;
report.striked_at = null; report.striked_at = null;
} else if ( } else if (data.strike_reason != -1 && data.strike_reason != report.strike_reason_id) {
data.strike_reason != -1 &&
(data.strike_reason != report.strike_reason_id || data.status != report.status)
) {
if (!report.reported_id) return new Response(null, { status: 400 }); if (!report.reported_id) return new Response(null, { status: 400 });
const strike_reason = await StrikeReason.findByPk(data.strike_reason); const strike_reason = await StrikeReason.findByPk(data.strike_reason);
if (strike_reason == null) return new Response(null, { status: 400 }); if (strike_reason == null) return new Response(null, { status: 400 });
@ -151,10 +153,12 @@ export const PATCH = (async ({ request, cookies }) => {
if (webhookTriggerUsers.length > 0 && data.status == 'reviewed' && env.REPORTED_WEBHOOK) { if (webhookTriggerUsers.length > 0 && data.status == 'reviewed' && env.REPORTED_WEBHOOK) {
for (const webhookTriggerUser of webhookTriggerUsers) { for (const webhookTriggerUser of webhookTriggerUsers) {
try {
// no `await` to avoid blocking // no `await` to avoid blocking
webhookUserReported(env.REPORTED_WEBHOOK, webhookTriggerUser).catch((e) => webhookUserReported(env.REPORTED_WEBHOOK, webhookTriggerUser);
console.error(`failed to send reported webhook: ${e}`) } catch (e) {
); console.error(`failed to send reported webhook: ${e}`);
}
} }
} }