Skip to content

Commit

Permalink
Merge pull request #426 from ssbc/fix-post-compat
Browse files Browse the repository at this point in the history
Test and fix post compat
  • Loading branch information
Powersource authored Nov 6, 2023
2 parents bf3232a + deadad0 commit d955ea1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions compat/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Obv = require('obz')
exports.init = function (sbot) {
const post = Obv()
sbot.db.post = post
sbot.post = post
sbot.db.onMsgAdded((ev) => {
post.set(ev.kvt)
})
Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ module.exports = [
require('ssb-box'),
require('ssb-box2'),
require('./compat/publish'),
require('./compat/post'),
require('./migrate'),
]
13 changes: 13 additions & 0 deletions test/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const sbot = SecretStack({ appKey: caps.shs })
.use(require('../'))
.use(require('../compat/db'))
.use(require('../compat/history-stream'))
.use(require('../compat/post'))
.call(null, {
keys,
path: dir,
Expand Down Expand Up @@ -109,6 +110,18 @@ test('keys', (t) => {
t.end()
})

test('post', t=> {
sbot.post((msg)=> {
if (msg.value.content.text === 'post test') {
t.end()
}
})

sbot.publish({ type: 'test', text: 'post test'}, (err) => {
if (err) t.fail(err, 'failed publish for post')
})
})

test('teardown sbot', (t) => {
sbot.close(true, () => t.end())
})
2 changes: 1 addition & 1 deletion test/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mkdirp.sync(dir)

const keys = ssbKeys.loadOrCreateSync(path.join(dir, 'secret'))

const sbot = SecretStack({ appKey: caps.shs }).use(require('../')).call(null, {
const sbot = SecretStack({ appKey: caps.shs }).use(require('../')).use(require('../compat/post')).call(null, {
keys,
path: dir,
})
Expand Down

0 comments on commit d955ea1

Please sign in to comment.