From eda707a65a608f4ddef85e7ac32ca09f41503a49 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 2 Nov 2023 20:20:34 +0100 Subject: [PATCH 1/3] Test and fix post compat --- compat/post.js | 1 + test/compat.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) 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/test/compat.js b/test/compat.js index 7da00185..e128b425 100644 --- a/test/compat.js +++ b/test/compat.js @@ -109,6 +109,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()) }) From cb95783c942c7481ea6cd47eaedb754366cfdfd9 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 2 Nov 2023 20:51:15 +0100 Subject: [PATCH 2/3] Try removing post compat from default import --- index.js | 1 - test/compat.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) 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 e128b425..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, From deadad0213da42440f398eddf7009da9115e9601 Mon Sep 17 00:00:00 2001 From: Jacob Karlsson Date: Thu, 2 Nov 2023 20:58:03 +0100 Subject: [PATCH 3/3] Get post compat in validate test --- test/validate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, })