Support AP remote following to accounts (not accept yet)
This commit is contained in:
parent
862f968f1b
commit
2f69c506cc
|
@ -1,3 +1,5 @@
|
||||||
|
const utils = require('../api-utils.js')
|
||||||
|
|
||||||
async function areActorsValid(actors, ourDomain) {
|
async function areActorsValid(actors, ourDomain) {
|
||||||
if (!actors instanceof Array && typeof actors !== 'string') {
|
if (!actors instanceof Array && typeof actors !== 'string') {
|
||||||
console.error('Unexpected type of "actors" in "federation.doesActorsExistAndOurs"')
|
console.error('Unexpected type of "actors" in "federation.doesActorsExistAndOurs"')
|
||||||
|
@ -48,13 +50,18 @@ module.exports = {
|
||||||
}
|
}
|
||||||
if (msg.activity.type === 'Block')
|
if (msg.activity.type === 'Block')
|
||||||
{
|
{
|
||||||
if (areActorsValid(msg.activity.object, true)) {
|
if (await areActorsValid(msg.activity.object, true)) {
|
||||||
if (msg.activity.actor instanceof Array &&
|
msg.activity.actor = utils.firstIfArray(msg.activity.actor)
|
||||||
msg.activity.actor.length > 0)
|
msg.activity.object = utils.firstIfArray(msg.activity.object)
|
||||||
msg.activity.actor = msg.activity.actor[0]
|
await apex.store.saveObject(msg.activity)
|
||||||
if (msg.activity.object instanceof Array &&
|
}
|
||||||
msg.activity.object.length > 0)
|
return true
|
||||||
msg.activity.object = msg.activity.object[0]
|
}
|
||||||
|
if (msg.activity.type === 'Follow')
|
||||||
|
{
|
||||||
|
if (await areActorsValid(msg.activity.object, true)) {
|
||||||
|
msg.activity.actor = utils.firstIfArray(msg.activity.actor)
|
||||||
|
msg.activity.object = utils.firstIfArray(msg.activity.object)
|
||||||
await apex.store.saveObject(msg.activity)
|
await apex.store.saveObject(msg.activity)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -66,6 +73,11 @@ module.exports = {
|
||||||
{ id: msg.object.id, type: 'Block' })
|
{ id: msg.object.id, type: 'Block' })
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if (msg.object.type === 'Follow') {
|
||||||
|
const actorid = utils.firstIfArray(msg.object.id)
|
||||||
|
await db.table.objects().deleteOne({ id: actorid, type: 'Follow' })
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('INBOX')
|
console.log('INBOX')
|
||||||
|
|
Loading…
Reference in New Issue