commenting from federation

This commit is contained in:
lesion
2019-08-01 15:18:45 +02:00
parent 37b63fc767
commit 5b013829fe
11 changed files with 137 additions and 21 deletions

View File

@@ -0,0 +1,24 @@
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!')
}
await Comment.create({
activitypub_id: body.object.id,
data: body.object,
eventId: event.id
})
}
}