Skip to content

Commit

Permalink
Simplify db.create allowPublic check
Browse files Browse the repository at this point in the history
  • Loading branch information
Powersource committed Nov 24, 2023
1 parent c888143 commit 67d6616
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ function isAllowPublic (input) {
}

function isAllowPublic2 (input) {
if (typeof input.content !== 'object') return false
if (typeof get(input, ['content', 'type']) !== 'string') return false
if (get(input, ['options', 'allowPublic']) !== true) return false
return input.allowPublic === true
if (input.allowPublic !== true) return false

return true
}
4 changes: 2 additions & 2 deletions test/db2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test('db2', async t => {
})

content = { type: 'profile', name: 'mix' }
await p(server.db.create)({ content, options: { allowPublic: true } })
await p(server.db.create)({ content, allowPublic: true })
.then(data => {
t.deepEqual(data.value.content, content, '(msg content unencrypted, allowPublic pruned). db.create')
})
Expand All @@ -38,7 +38,7 @@ test('db2', async t => {

const weird = {
content: { type: 'profile', recps: [server.id] },
options: { allowPublic: true }
allowPublic: true
}
await p(server.db.create)(weird)
.then(msg => {
Expand Down

0 comments on commit 67d6616

Please sign in to comment.