Fix admin edits (#1737)

This commit is contained in:
ekzyis 2024-12-19 01:28:18 +01:00 committed by GitHub
parent b8061a630c
commit d3a705d3ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -1381,10 +1381,11 @@ export const updateItem = async (parent, { sub: subName, forward, hash, hmac, ..
const user = await models.user.findUnique({ where: { id: meId } })
// edits are only allowed for own items within 10 minutes but forever if it's their bio or a job
// edits are only allowed for own items within 10 minutes
// but forever if an admin is editing an "admin item", it's their bio or a job
const myBio = user.bioId === old.id
const timer = Date.now() < datePivot(new Date(old.invoicePaidAt ?? old.createdAt), { seconds: ITEM_EDIT_SECONDS })
const canEdit = (timer && ownerEdit) || myBio || isJob(item)
const canEdit = (timer && ownerEdit) || adminEdit || myBio || isJob(item)
if (!canEdit) {
throw new GqlInputError('item can no longer be edited')
}