Merge pull request #725 from mouse-reeve/incoming-unshelve

Fixes handling incoming unshelve activities
This commit is contained in:
Mouse Reeve
2021-03-13 08:53:37 -08:00
committed by GitHub
3 changed files with 45 additions and 5 deletions

View File

@ -362,14 +362,15 @@ class CollectionItemMixin(ActivitypubMixin):
""" broadcast a remove activity """
activity = self.to_remove_activity()
super().delete(*args, **kwargs)
self.broadcast(activity, self.user)
if self.user.local:
self.broadcast(activity, self.user)
def to_add_activity(self):
""" AP for shelving a book"""
object_field = getattr(self, self.object_field)
collection_field = getattr(self, self.collection_field)
return activitypub.Add(
id="%s#add" % self.remote_id,
id=self.remote_id,
actor=self.user.remote_id,
object=object_field,
target=collection_field.remote_id,
@ -380,7 +381,7 @@ class CollectionItemMixin(ActivitypubMixin):
object_field = getattr(self, self.object_field)
collection_field = getattr(self, self.collection_field)
return activitypub.Remove(
id="%s#remove" % self.remote_id,
id=self.remote_id,
actor=self.user.remote_id,
object=object_field,
target=collection_field.remote_id,