2019-08-01 15:18:45 +02:00
|
|
|
const { event: Event, comment: Comment } = require('../api/models')
|
|
|
|
|
const config = require('config')
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
async create (body) {
|
|
|
|
|
|
|
|
|
|
//search for related event
|
|
|
|
|
const inReplyTo = body.object.inReplyTo
|
|
|
|
|
const event_id = inReplyTo.match(`${config.baseurl}/federation/m/(.*)`)[1]
|
|
|
|
|
|
|
|
|
|
console.error(event_id)
|
|
|
|
|
const event = await Event.findByPk(event_id)
|
|
|
|
|
if (!event) {
|
|
|
|
|
return console.error('event not found!')
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-03 00:48:48 +02:00
|
|
|
return await Comment.create({
|
2019-08-01 15:18:45 +02:00
|
|
|
activitypub_id: body.object.id,
|
|
|
|
|
data: body.object,
|
|
|
|
|
eventId: event.id
|
|
|
|
|
})
|
|
|
|
|
|
2019-08-03 00:48:48 +02:00
|
|
|
|
2019-08-01 15:18:45 +02:00
|
|
|
}
|
|
|
|
|
}
|