Set queue for broadcast task

This commit is contained in:
Mouse Reeve 2021-11-11 19:00:01 -08:00
parent c33d791974
commit 6aa57d4d34

View file

@ -126,12 +126,15 @@ class ActivitypubMixin:
# there OUGHT to be only one match # there OUGHT to be only one match
return match.first() return match.first()
def broadcast(self, activity, sender, software=None): def broadcast(self, activity, sender, software=None, queue="medium_priority"):
"""send out an activity""" """send out an activity"""
broadcast_task.delay( broadcast_task.apply_async(
args=(
sender.id, sender.id,
json.dumps(activity, cls=activitypub.ActivityEncoder), json.dumps(activity, cls=activitypub.ActivityEncoder),
self.get_recipients(software=software), self.get_recipients(software=software),
),
queue=queue,
) )
def get_recipients(self, software=None): def get_recipients(self, software=None):
@ -374,9 +377,9 @@ class CollectionItemMixin(ActivitypubMixin):
activity_serializer = activitypub.CollectionItem activity_serializer = activitypub.CollectionItem
def broadcast(self, activity, sender, software="bookwyrm"): def broadcast(self, activity, sender, software="bookwyrm", queue="medium_priority"):
"""only send book collection updates to other bookwyrm instances""" """only send book collection updates to other bookwyrm instances"""
super().broadcast(activity, sender, software=software) super().broadcast(activity, sender, software=software, queue=queue)
@property @property
def privacy(self): def privacy(self):
@ -406,7 +409,7 @@ class CollectionItemMixin(ActivitypubMixin):
# adding an obj to the collection # adding an obj to the collection
activity = self.to_add_activity(self.user) activity = self.to_add_activity(self.user)
self.broadcast(activity, self.user) self.broadcast(activity, self.user, queue="low_priority")
def delete(self, *args, broadcast=True, **kwargs): def delete(self, *args, broadcast=True, **kwargs):
"""broadcast a remove activity""" """broadcast a remove activity"""