Commit 8dc8b29a authored by les's avatar les
Browse files

.

parent 280d4bec
......@@ -123,6 +123,7 @@ const userController = {
res.json(event)
federation.sendEvent(event, req.user)
res.json(200)
// send notification (mastodon/email/confirmation)
// notifier.notifyEvent(event.id)
......
const config = require('config')
const Helpers = require('./helpers')
const { user: User } = require('../api/models')
const crypto = require('crypto')
module.exports = {
// follow request from fediverse
......@@ -18,7 +19,15 @@ module.exports = {
console.error('ok this is a new follower: ', body.actor)
await user.update({ followers: [...user.followers, body.actor] })
}
return Helpers.sendAcceptMessage(body, user, domain, req, res, targetOrigin)
const guid = crypto.randomBytes(16).toString('hex')
let message = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': `${config.baseurl}/federation/${guid}`,
'type': 'Accept',
'actor': `${config.baseurl}/federation/u/${user.username}`,
'object': body,
}
return Helpers.signAndSend(message, user, body.actor)
},
// unfollow request from fediverse
......
const fetch = require('fetch')
const request = require('request')
const crypto = require('crypto')
const config = require('config')
const Helpers = {
......@@ -41,18 +40,6 @@ const Helpers = {
console.log('Response:', response.body, response.statusCode, response.status, response.statusMessage)
}
})
return res.status(200)
},
async sendAcceptMessage (body, user, domain, req, res, targetOrigin) {
const guid = crypto.randomBytes(16).toString('hex')
let message = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': `${config.baseurl}/federation/${guid}`,
'type': 'Accept',
'actor': `${config.baseurl}/federation/u/${user.username}`,
'object': body,
}
// Helpers.signAndSend(message, user, domain, req, res, targetOrigin)
},
async sendEvent(event, user) {
console.error('devo inviare un evento ai followers')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment