From cedc79a962775b8e4fa150f6586e5d8a3ff60f10 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 14 Oct 2020 17:29:43 -0700 Subject: [PATCH] Tweaks handle_follow behavior for unknown users --- bookwyrm/incoming.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bookwyrm/incoming.py b/bookwyrm/incoming.py index 0241fefb8..b223ab16b 100644 --- a/bookwyrm/incoming.py +++ b/bookwyrm/incoming.py @@ -112,9 +112,16 @@ def has_valid_signature(request, activity): def handle_follow(activity): ''' someone wants to follow a local user ''' # figure out who they want to follow -- not using get_or_create because - # we only allow you to follow local users - to_follow = models.User.objects.get(remote_id=activity['object']) - # raises models.User.DoesNotExist id the remote id is not found + # we only care if you want to follow local users + try: + to_follow = models.User.objects.get(remote_id=activity['object']) + except models.User.DoesNotExist: + # some rando, who cares + return + if not to_follow.local: + # just ignore follow alerts about other servers. maybe they should be + # handled. maybe they shouldn't be sent at all. + return # figure out who the actor is user = get_or_create_remote_user(activity['actor'])