diff --git a/server/federation/ego.js b/server/federation/ego.js index 431dd5b6..5a9dacdd 100644 --- a/server/federation/ego.js +++ b/server/federation/ego.js @@ -13,6 +13,15 @@ module.exports = { res.sendStatus(201) }, + async unboost (req, res) { + const match = req.body.object.match*`${config.baseurl}/federation/m/(.*)`) + if (!match || match.length < 2) return res.status(404).send('Event not found!') + debug('unboost %s', match[1]) + const event = await Event.findByPk(Number(match[1])) + if (!event) return res.status(404).send('Event not found!') + await event.update({ boost: [...event.boost.filter(actor => actor !== body.actor )]}) + }, + async bookmark (req, res) { const match = req.body.object.match(`${config.baseurl}/federation/m/(.*)`) if (!match || match.length < 2) { return res.status(404).send('Event not found!') } diff --git a/server/federation/index.js b/server/federation/index.js index 9ccfef5c..0e212634 100644 --- a/server/federation/index.js +++ b/server/federation/index.js @@ -50,7 +50,7 @@ router.post('/u/:name/inbox', Helpers.verifySignature, async (req, res) => { } else if (b.object.type === 'Like') { Ego.unbookmark(req, res) } else if (b.object.type === 'Announce') { - console.error('Unboost') + Ego.unboost(req, res) } break case 'Announce':