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,
|
areActorsValid,
|
||||||
inbox: async (msg) => {
|
inbox: async (msg) => {
|
||||||
// TODO: add logging for every matches params
|
// 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')
|
if (msg.activity.type === 'Reject' && msg.object.type === 'Follow')
|
||||||
{
|
{
|
||||||
const follow = await db.table.objects().findOne({ id: msg.object.id })
|
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)
|
if (await getRejectedTimes(req, res) >= REJECT_TIMES_MAX)
|
||||||
return res.json({ error: 'follow_rejected_max' })
|
return res.json({ error: 'follow_rejected_max' })
|
||||||
|
|
||||||
if (await getValidFollow(req, res) !== null)
|
const follow = await getValidFollow(req, res)
|
||||||
return res.json({ error: 'follow_already_requested' })
|
if (follow !== null) {
|
||||||
|
if (follow.accepted)
|
||||||
|
return res.json({ error: 'already_following' })
|
||||||
|
return res.json({ error: 'follow_pending' })
|
||||||
|
}
|
||||||
|
|
||||||
const actor = await apex.store.getObject(
|
const actor = await apex.store.getObject(
|
||||||
apID(res.locals.user.username), true)
|
apID(res.locals.user.username), true)
|
||||||
|
|
Loading…
Reference in New Issue