Fix admin edits (#1737)
This commit is contained in:
parent
b8061a630c
commit
d3a705d3ad
|
@ -1381,10 +1381,11 @@ export const updateItem = async (parent, { sub: subName, forward, hash, hmac, ..
|
||||||
|
|
||||||
const user = await models.user.findUnique({ where: { id: meId } })
|
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 myBio = user.bioId === old.id
|
||||||
const timer = Date.now() < datePivot(new Date(old.invoicePaidAt ?? old.createdAt), { seconds: ITEM_EDIT_SECONDS })
|
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) {
|
if (!canEdit) {
|
||||||
throw new GqlInputError('item can no longer be edited')
|
throw new GqlInputError('item can no longer be edited')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue