fix uncaught null return on user info database query
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m28s
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m28s
This commit is contained in:
parent
b92e494ecb
commit
8ccff82fd3
@ -20,18 +20,18 @@ export const GET = (async ({ url }) => {
|
|||||||
'striked_at'
|
'striked_at'
|
||||||
],
|
],
|
||||||
include: { model: StrikeReason, as: 'strike_reason' }
|
include: { model: StrikeReason, as: 'strike_reason' }
|
||||||
})) as { dataValues: { weight: number; striked_at: Date } } | null;
|
})) as { weight: number | null; striked_at: Date | null } | null;
|
||||||
const ban_time = (
|
const ban_time = (
|
||||||
await StrikePunishment.findOne({
|
await StrikePunishment.findOne({
|
||||||
attributes: ['punishment_in_seconds'],
|
attributes: ['punishment_in_seconds'],
|
||||||
where: { type: ['ban'], weight: { [Op.lte]: query?.dataValues.weight } },
|
where: { type: ['ban'], weight: { [Op.lte]: query?.weight } },
|
||||||
order: [['weight', 'DESC']]
|
order: [['weight', 'DESC']]
|
||||||
})
|
})
|
||||||
)?.punishment_in_seconds;
|
)?.punishment_in_seconds;
|
||||||
const outlawed_time = (
|
const outlawed_time = (
|
||||||
await StrikePunishment.findOne({
|
await StrikePunishment.findOne({
|
||||||
attributes: ['punishment_in_seconds'],
|
attributes: ['punishment_in_seconds'],
|
||||||
where: { type: ['outlawed'], weight: { [Op.lte]: query?.dataValues.weight } },
|
where: { type: ['outlawed'], weight: { [Op.lte]: query?.weight } },
|
||||||
order: [['weight', 'DESC']]
|
order: [['weight', 'DESC']]
|
||||||
})
|
})
|
||||||
)?.punishment_in_seconds;
|
)?.punishment_in_seconds;
|
||||||
@ -43,12 +43,12 @@ export const GET = (async ({ url }) => {
|
|||||||
firstname: user.firstname,
|
firstname: user.firstname,
|
||||||
lastname: user.lastname,
|
lastname: user.lastname,
|
||||||
banned_until:
|
banned_until:
|
||||||
query && ban_time
|
query && query.striked_at && ban_time
|
||||||
? Math.round(query.dataValues.striked_at.getTime() / 1000 + ban_time!)
|
? Math.round(query.striked_at.getTime() / 1000 + ban_time!)
|
||||||
: null,
|
: null,
|
||||||
outlawed_until:
|
outlawed_until:
|
||||||
query && outlawed_time
|
query && query.striked_at && outlawed_time
|
||||||
? Math.round(query.dataValues.striked_at.getTime() / 1000 + outlawed_time!)
|
? Math.round(query.striked_at.getTime() / 1000 + outlawed_time!)
|
||||||
: null
|
: null
|
||||||
}),
|
}),
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user