Skip to content

Commit

Permalink
Fix admin edits (#1737)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis authored Dec 19, 2024
1 parent b8061a6 commit d3a705d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/resolvers/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down

0 comments on commit d3a705d

Please sign in to comment.