Fix #776: Don't store unhandled ActivityPub messages in database

This commit is contained in:
Eliot Berriot 2019-03-27 12:53:35 +01:00
parent b9b1e1e26a
commit 46f1d96206
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
3 changed files with 32 additions and 0 deletions

View file

@ -121,6 +121,7 @@ def receive(activity, on_behalf_of):
from . import models
from . import serializers
from . import tasks
from .routes import inbox
# we ensure the activity has the bare minimum structure before storing
# it in our database
@ -128,6 +129,10 @@ def receive(activity, on_behalf_of):
data=activity, context={"actor": on_behalf_of, "local_recipients": True}
)
serializer.is_valid(raise_exception=True)
if not inbox.get_matching_handlers(activity):
# discard unhandlable activity
return
if should_reject(
fid=serializer.validated_data.get("id"),
actor_id=serializer.validated_data["actor"].fid,