From 858bf70d6241771e5225009d2238e8ab9822b04d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 24 Jan 2023 08:46:29 -0800 Subject: [PATCH] Make follow activities a high priority This should go a long way towards fixing the problems with follows not going through to remote servers. All it does is move relationship related activities from the medium priority queue, which gets backlogged easily, to the high priority queue, which is less backlogged. The risk here is that the high priority queue could end up getting backlogged, so this isn't the last word on fixing this, but I think the volume of activities that this will add to it will be manageable. --- bookwyrm/views/inbox.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bookwyrm/views/inbox.py b/bookwyrm/views/inbox.py index eec35f9d1..e5372a3e4 100644 --- a/bookwyrm/views/inbox.py +++ b/bookwyrm/views/inbox.py @@ -14,7 +14,7 @@ from django.views import View from django.views.decorators.csrf import csrf_exempt from bookwyrm import activitypub, models -from bookwyrm.tasks import app, MEDIUM +from bookwyrm.tasks import app, MEDIUM, HIGH from bookwyrm.signatures import Signature from bookwyrm.utils import regex @@ -60,7 +60,11 @@ class Inbox(View): return HttpResponse() return HttpResponse(status=401) - activity_task.delay(activity_json) + # Make activities relating to follow/unfollow a high priority + high = ["Follow", "Accept", "Reject", "Block", "Unblock", "Undo"] + + priority = HIGH if activity_json["type"] in high else MEDIUM + activity_task.apply_async(args=(activity_json), queue=priority) return HttpResponse()