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.
This commit is contained in:
Mouse Reeve 2023-01-24 08:46:29 -08:00
parent 6425e569c5
commit 858bf70d62

View file

@ -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()