This commit is contained in:
lesion
2019-07-31 01:03:21 +02:00
parent 7d4b2287e3
commit cbaeffbc67
3 changed files with 42 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
const config = require('config')
module.exports = (sequelize, DataTypes) => {
const event = sequelize.define('event', {
id: {
@@ -35,5 +37,21 @@ module.exports = (sequelize, DataTypes) => {
event.hasMany(models.comment)
}
event.prototype.toAP = function (username) {
return {
id: `${config.baseurl}/federation/m/c_${this.id}`,
type: 'Create',
actor: `${config.baseurl}/federation/u/${username}`,
object: {
id: `${config.baseurl}/federation/m/${this.id}`,
type: 'Note',
published: this.createdAt,
attributedTo: `${config.baseurl}/federation/u/${username}`,
to: 'https://www.w3.org/ns/activitystreams#Public',
content: this.title
}
}
}
return event
}