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'
|
||||
],
|
||||
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 = (
|
||||
await StrikePunishment.findOne({
|
||||
attributes: ['punishment_in_seconds'],
|
||||
where: { type: ['ban'], weight: { [Op.lte]: query?.dataValues.weight } },
|
||||
where: { type: ['ban'], weight: { [Op.lte]: query?.weight } },
|
||||
order: [['weight', 'DESC']]
|
||||
})
|
||||
)?.punishment_in_seconds;
|
||||
const outlawed_time = (
|
||||
await StrikePunishment.findOne({
|
||||
attributes: ['punishment_in_seconds'],
|
||||
where: { type: ['outlawed'], weight: { [Op.lte]: query?.dataValues.weight } },
|
||||
where: { type: ['outlawed'], weight: { [Op.lte]: query?.weight } },
|
||||
order: [['weight', 'DESC']]
|
||||
})
|
||||
)?.punishment_in_seconds;
|
||||
@ -43,12 +43,12 @@ export const GET = (async ({ url }) => {
|
||||
firstname: user.firstname,
|
||||
lastname: user.lastname,
|
||||
banned_until:
|
||||
query && ban_time
|
||||
? Math.round(query.dataValues.striked_at.getTime() / 1000 + ban_time!)
|
||||
query && query.striked_at && ban_time
|
||||
? Math.round(query.striked_at.getTime() / 1000 + ban_time!)
|
||||
: null,
|
||||
outlawed_until:
|
||||
query && outlawed_time
|
||||
? Math.round(query.dataValues.striked_at.getTime() / 1000 + outlawed_time!)
|
||||
query && query.striked_at && outlawed_time
|
||||
? Math.round(query.striked_at.getTime() / 1000 + outlawed_time!)
|
||||
: null
|
||||
}),
|
||||
{ status: 200 }
|
||||
|
Loading…
x
Reference in New Issue
Block a user