[AP] unfollow, tags, attachment, sign

This commit is contained in:
les
2019-09-11 12:00:13 +02:00
parent a026e5738d
commit 939e19bb0d
4 changed files with 64 additions and 23 deletions

View File

@@ -27,13 +27,23 @@ module.exports = {
'type': 'Accept',
'actor': `${config.baseurl}/federation/u/${user.username}`,
'object': body,
}
}
Helpers.signAndSend(message, user, body.actor)
res.sendStatus(200)
},
// unfollow request from fediverse
unfollow () {
console.error('inside unfollow')
async unfollow (req, res) {
debug("Unfollow UNFOLLOW!")
const body = req.body
const username = body.object.object.replace(`${config.baseurl}/federation/u/`, '')
const user = await User.findOne({ where: { username }})
if (!user) return res.status(404).send('User not found')
if (body.actor !== body.object.actor) return res.status(400).send('Bad things')
user.followers = user.followers.filter(follower => follower !== username)
debug('%s unfollowed by %s (%d)', username, body.actor, user.followers.length)
await user.save()
res.sendStatus(200)
}
}