Skip to content

Commit

Permalink
Remove unused publish hook code
Browse files Browse the repository at this point in the history
  • Loading branch information
Powersource committed Nov 24, 2023
1 parent a1cc675 commit c888143
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
init (ssb, config) {
const allowedTypes = getAllowedTypes(ssb, config)

const publishHook = (keepOptions) => (publish, args) => {
const publishHook = (publish, args) => {
const [input, cb] = args

if (
Expand All @@ -25,18 +25,14 @@ module.exports = {
return cb(new Error('recps-guard: should not have recps && allowPublic, check your code'))
}

if (keepOptions) {
return publish({...input.content, options: input.options}, cb)
} else {
return publish(input.content, cb)
}
return publish(input.content, cb)
}

cb(new Error(`recps-guard: public messages of type "${input.type}" not allowed`))
}

if (ssb.publish) {
ssb.publish.hook(publishHook(false))
ssb.publish.hook(publishHook)

ssb.publish.hook = () => {
throw new Error('ssb-recps-guard must be the last to hook ssb.publish')
Expand Down

0 comments on commit c888143

Please sign in to comment.