This commit is contained in:
lesion
2019-07-31 01:43:08 +02:00
parent a25efc9e59
commit a09b567e97
3 changed files with 28 additions and 17 deletions

View File

@@ -9,6 +9,7 @@ const mail = require('../mail')
const { user: User, event: Event, tag: Tag, place: Place } = require('../models')
const settingsController = require('./settings')
const notifier = require('../../notifier')
const federation = require('../../federation/helpers')
const userController = {
async login(req, res) {
@@ -121,6 +122,8 @@ const userController = {
// send response to client
res.json(event)
federation.sendEvent(event, user)
// send notification (mastodon/email/confirmation)
notifier.notifyEvent(event.id)

View File

@@ -37,7 +37,7 @@ module.exports = (sequelize, DataTypes) => {
event.hasMany(models.comment)
}
event.prototype.toAP = function (username) {
event.prototype.toAP = function (username, follower) {
return {
id: `${config.baseurl}/federation/m/c_${this.id}`,
type: 'Create',
@@ -48,6 +48,7 @@ module.exports = (sequelize, DataTypes) => {
published: this.createdAt,
attributedTo: `${config.baseurl}/federation/u/${username}`,
to: 'https://www.w3.org/ns/activitystreams#Public',
cc: [follower],
content: this.title
}
}