improve logging

This commit is contained in:
les
2021-04-28 12:44:26 +02:00
parent f7ba790398
commit 5f8bbd68c8
16 changed files with 63 additions and 39 deletions

View File

@@ -6,7 +6,7 @@ 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!') }
log.debug(`boost ${match[1]}`)
log.info(`boost ${match[1]}`)
const event = await Event.findByPk(Number(match[1]))
if (!event) { return res.status(404).send('Event not found!') }
// TODO, has to be unique...
@@ -17,7 +17,7 @@ module.exports = {
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!') }
log.debug(`unboost ${match[1]}`)
log.info(`unboost ${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 !== req.body.actor) })
@@ -27,7 +27,7 @@ module.exports = {
const match = req.body.object.match(`${config.baseurl}/federation/m/(.*)`)
if (!match || match.length < 2) { return res.status(404).send('Event not found!') }
const event = await Event.findByPk(Number(match[1]))
log.debug(`${req.body.actor} bookmark ${event.title} (${event.likes.length})`)
log.info(`${req.body.actor} bookmark ${event.title} (${event.likes.length})`)
if (!event) { return res.status(404).send('Event not found!') }
// TODO: has to be unique
await event.update({ likes: [...event.likes, req.body.actor] })
@@ -40,7 +40,7 @@ module.exports = {
const match = object.object.match(`${config.baseurl}/federation/m/(.*)`)
if (!match || match.length < 2) { return res.status(404).send('Event not found!') }
const event = await Event.findByPk(Number(match[1]))
log.debug(`${body.actor} unbookmark ${event.title} (${event.likes.length})`)
log.info(`${body.actor} unbookmark ${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) })
res.sendStatus(201)