Skip to content

Commit

Permalink
Allow feed ids in first recps slot
Browse files Browse the repository at this point in the history
  • Loading branch information
Powersource committed Oct 24, 2023
1 parent 9ff3384 commit 6d97ded
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,18 @@ function init (ssb, config) {

return {
publish (content, cb) {
if (!content.recps) return cb(Error('recps missing in content'))
if (!content.recps) {
return ssb.db.create({
content,
}, cb)
}

if (!isGroup(content.recps[0])) return cb(Error('first recp in recps needs to be a group id'))
if (!isGroup(content.recps[0])) {
return ssb.db.create({
content,
encryptionFormat: 'box2'
}, cb)
}

ssb.box2.getGroupInfo(content.recps[0], (err, groupInfo) => {
if (err) return cb(Error('error on getting group info in publish', { cause: err }))
Expand Down
3 changes: 1 addition & 2 deletions test/publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test('publish (group + feedId)', t => {
})
})

test.skip('publish (DMs: myFeedId + feedId)', async t => {
test('publish (DMs: myFeedId + feedId)', async t => {
const alice = Server()
const bob = Server()
const name = (id) => {
Expand All @@ -94,7 +94,6 @@ test.skip('publish (DMs: myFeedId + feedId)', async t => {
const content = {
type: 'announce',
text: 'summer has arrived in wellington!',
// TODO: failing here because the first recp isn't a groupId. the old code just published anyway. do we still want to do that? i think the spec might allow it but we disallow it in tribes2
recps: [alice.id, bob.id]
}

Expand Down

0 comments on commit 6d97ded

Please sign in to comment.