Capture Inbox "Accept" event of "Follow" and update property "accepted"
This commit is contained in:
parent
bdb2b63fe9
commit
c8bba73b99
|
@ -24,6 +24,16 @@ module.exports = {
|
|||
areActorsValid,
|
||||
inbox: async (msg) => {
|
||||
// TODO: add logging for every matches params
|
||||
if (msg.activity.type === 'Accept')
|
||||
{
|
||||
if (msg.object.type === 'Follow') {
|
||||
const follow = await db.table.objects().findOne({ id: msg.object.id })
|
||||
if (follow !== null && follow.type === 'Follow')
|
||||
await db.table.objects().updateOne({ _id: follow._id },
|
||||
{ $set: { accepted: true } })
|
||||
return true
|
||||
}
|
||||
}
|
||||
if (msg.activity.type === 'Reject' && msg.object.type === 'Follow')
|
||||
{
|
||||
const follow = await db.table.objects().findOne({ id: msg.object.id })
|
||||
|
|
|
@ -34,8 +34,12 @@ module.exports = {
|
|||
if (await getRejectedTimes(req, res) >= REJECT_TIMES_MAX)
|
||||
return res.json({ error: 'follow_rejected_max' })
|
||||
|
||||
if (await getValidFollow(req, res) !== null)
|
||||
return res.json({ error: 'follow_already_requested' })
|
||||
const follow = await getValidFollow(req, res)
|
||||
if (follow !== null) {
|
||||
if (follow.accepted)
|
||||
return res.json({ error: 'already_following' })
|
||||
return res.json({ error: 'follow_pending' })
|
||||
}
|
||||
|
||||
const actor = await apex.store.getObject(
|
||||
apID(res.locals.user.username), true)
|
||||
|
|
Loading…
Reference in New Issue