This commit is contained in:
les
2019-09-11 19:12:24 +02:00
parent 93baf01a55
commit 2fe956d117
65 changed files with 762 additions and 721 deletions

View File

@@ -5,21 +5,21 @@ const debug = require('debug')('fediverse:ego')
module.exports = {
async boost (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!')
if (!match || match.length < 2) { return res.status(404).send('Event not found!') }
debug('boost %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, req.body.actor]})
if (!event) { return res.status(404).send('Event not found!') }
await event.update({ boost: [...event.boost, req.body.actor] })
res.sendStatus(201)
},
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!')
if (!match || match.length < 2) { return res.status(404).send('Event not found!') }
const event = await Event.findByPk(Number(match[1]))
debug('%s bookmark %s (%d)', req.body.actor, event.title, event.likes.length)
if (!event) return res.status(404).send('Event not found!')
await event.update({ likes: [...event.likes, req.body.actor]})
if (!event) { return res.status(404).send('Event not found!') }
await event.update({ likes: [...event.likes, req.body.actor] })
res.sendStatus(201)
},
@@ -27,11 +27,11 @@ module.exports = {
const body = req.body
const object = body.object
const match = object.object.match(`${config.baseurl}/federation/m/(.*)`)
if (!match || match.length<2) return res.status(404).send('Event not found!')
if (!match || match.length < 2) { return res.status(404).send('Event not found!') }
const event = await Event.findByPk(Number(match[1]))
debug('%s unbookmark %s (%d)', body.actor, event.title, event.likes.length)
if (!event) return res.status(404).send('Event not found!')
await event.update({ likes: [...event.likes.filter(actor => actor!==body.actor)]})
if (!event) { return res.status(404).send('Event not found!') }
await event.update({ likes: [...event.likes.filter(actor => actor !== body.actor)] })
res.sendStatus(201)
}
}
}