prefilter inbox to reduce work from inappropriate deliveries
This commit is contained in:
parent
231fbffee7
commit
60d57e8a50
1 changed files with 18 additions and 5 deletions
23
index.js
23
index.js
|
@ -92,6 +92,24 @@ async function actorOnDemand (req, res, next) {
|
||||||
} catch (err) { return next(err) }
|
} catch (err) { return next(err) }
|
||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
|
// Lots of servers are delivering inappropriate activities to Guppe, move the filtering up earlier in the process to save work
|
||||||
|
apex.net.inbox.post.slice(
|
||||||
|
// just after standardizing the jsonld
|
||||||
|
apex.net.inbox.post.indexOf(apex.net.validators.jsonld) + 1,
|
||||||
|
0,
|
||||||
|
function (req, res, next) {
|
||||||
|
try {
|
||||||
|
const groupIRI = apex.utils.usernameToIRI(apex.actorParam)
|
||||||
|
if (!apex.audienceFromActivity(req.body).includes(groupIRI) && !req.body.object?.[0] === groupIRI) {
|
||||||
|
console.log('Ignoring irrelevant activity', req.body)
|
||||||
|
return res.status(202).send('Irrelevant activity ignored')
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('Error performing prefilter:', err)
|
||||||
|
}
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
)
|
||||||
// Do not boost posts from servers who abuse the service.
|
// Do not boost posts from servers who abuse the service.
|
||||||
apex.net.inbox.post.splice(
|
apex.net.inbox.post.splice(
|
||||||
// Blocked domain check is inserted into apex inbox route right after the sender is verified
|
// Blocked domain check is inserted into apex inbox route right after the sender is verified
|
||||||
|
@ -145,11 +163,6 @@ app.on('apex-inbox', async ({ actor, activity, recipient, object }) => {
|
||||||
switch (activity.type.toLowerCase()) {
|
switch (activity.type.toLowerCase()) {
|
||||||
// automatically reshare incoming posts
|
// automatically reshare incoming posts
|
||||||
case 'create': {
|
case 'create': {
|
||||||
// check audience to ignore forwarded messages not adddressed to group
|
|
||||||
const audience = apex.audienceFromActivity(activity)
|
|
||||||
if (!audience.includes(recipient.id) || !activity.object?.length) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const to = [
|
const to = [
|
||||||
recipient.followers[0],
|
recipient.followers[0],
|
||||||
apex.consts.publicAddress
|
apex.consts.publicAddress
|
||||||
|
|
Loading…
Reference in a new issue