mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-15 03:35:29 +00:00
Set queue for broadcast task
This commit is contained in:
parent
c33d791974
commit
6aa57d4d34
1 changed files with 11 additions and 8 deletions
|
@ -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"""
|
||||||
|
|
Loading…
Reference in a new issue