Compare commits
2 Commits
0280e2a277
...
3dd56bc471
Author | SHA1 | Date | |
---|---|---|---|
3dd56bc471 | |||
8e60f83b6f |
@ -50,12 +50,7 @@ export const POST = (async ({ request, cookies }) => {
|
|||||||
|
|
||||||
let reports = await Report.findAll({
|
let reports = await Report.findAll({
|
||||||
where: reportFindOptions,
|
where: reportFindOptions,
|
||||||
include: [
|
include: [{ all: true }],
|
||||||
{ 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
|
||||||
@ -139,7 +134,10 @@ 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 (data.strike_reason != -1 && data.strike_reason != report.strike_reason_id) {
|
} else if (
|
||||||
|
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 });
|
||||||
@ -153,12 +151,10 @@ 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);
|
webhookUserReported(env.REPORTED_WEBHOOK, webhookTriggerUser).catch((e) =>
|
||||||
} catch (e) {
|
console.error(`failed to send reported webhook: ${e}`)
|
||||||
console.error(`failed to send reported webhook: ${e}`);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user