diff --git a/compat/post.js b/compat/post.js index be5abee4..6d526f7c 100644 --- a/compat/post.js +++ b/compat/post.js @@ -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) }) diff --git a/index.js b/index.js index 32054903..b98a5328 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,5 @@ module.exports = [ require('ssb-box'), require('ssb-box2'), require('./compat/publish'), - require('./compat/post'), require('./migrate'), ] diff --git a/test/compat.js b/test/compat.js index 7da00185..a4b71183 100644 --- a/test/compat.js +++ b/test/compat.js @@ -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, @@ -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()) }) diff --git a/test/validate.js b/test/validate.js index 67166f61..41881330 100644 --- a/test/validate.js +++ b/test/validate.js @@ -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, })