send emails with less spam points
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user