send emails with less spam points

This commit is contained in:
les
2019-08-10 15:00:08 +02:00
parent f722187c65
commit fdb1620658
10 changed files with 61 additions and 43 deletions

View File

@@ -4,15 +4,21 @@ const debug = require('debug')('fediverse:comment')
module.exports = {
async create (req, res) {
const body = req.body
//search for related event
const inReplyTo = body.object.inReplyTo
const match = inReplyTo.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]))
let event = await Event.findByPk(Number(match[1]))
if (!event) return res.status(404).send('Event not found!')
debug('comment from %s to %s', req.body.actor, event.titles)
debug('comment coming for %s', inReplyTo)
if (!event) {
// in reply to another comment...
const comment = await Comment.findByPk(inReplyTo, { include: [Event] })
if (!comment) return res.status(404).send('Not found')
event = comment.event
}
debug('comment from %s to "%s"', req.body.actor, event.title)
await Comment.create({
activitypub_id: body.object.id,