Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const op = entry.payload.op
const mods = this.capabilities['moderators']
const members = this.capabilities['members']
const isMod = mods.includes(entry.identity.id)
const isMember = members.includes(entry.identity.id)
if (op === 'ADD') {
// Anyone can add entry if open thread
if (!this._members) return await trueIfValidSig()
// Not open thread, any member or mod can add to thread
if (isMember || isMod) return await trueIfValidSig()
}
if (op === 'DEL') {
const hash = entry.payload.value
const delEntry = await entryIPFS.fromMultihash(this._ipfs, hash)
// An id can delete their own entries
if (delEntry.identity.id === entry.identity.id) return await trueIfValidSig()
// Mods can't delete other mods entries
if (mods.includes(delEntry.identity.id)) return false
// Mods can delete any other entries
if (isMod) return await trueIfValidSig()
}
return false
}