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({
|
||||
where: reportFindOptions,
|
||||
include: [
|
||||
{ model: User, as: 'reporter' },
|
||||
{ model: User, as: 'reported' },
|
||||
{ model: Admin, as: 'auditor' },
|
||||
{ model: StrikeReason, as: 'strike_reason' }
|
||||
],
|
||||
include: [{ all: true }],
|
||||
order: [['created_at', 'DESC']],
|
||||
offset: data.from || 0,
|
||||
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) {
|
||||
report.strike_reason_id = 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 });
|
||||
const strike_reason = await StrikeReason.findByPk(data.strike_reason);
|
||||
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) {
|
||||
for (const webhookTriggerUser of webhookTriggerUsers) {
|
||||
try {
|
||||
// no `await` to avoid blocking
|
||||
webhookUserReported(env.REPORTED_WEBHOOK, webhookTriggerUser);
|
||||
} catch (e) {
|
||||
console.error(`failed to send reported webhook: ${e}`);
|
||||
}
|
||||
webhookUserReported(env.REPORTED_WEBHOOK, webhookTriggerUser).catch((e) =>
|
||||
console.error(`failed to send reported webhook: ${e}`)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user