Fixes list item fields and broadcast updates

This commit is contained in:
Mouse Reeve
2021-04-08 14:47:38 -07:00
parent af58455ae9
commit e550f8cde6
3 changed files with 11 additions and 12 deletions

View File

@ -361,12 +361,11 @@ class CollectionItemMixin(ActivitypubMixin):
def save(self, *args, broadcast=True, **kwargs):
""" broadcast updated """
created = not bool(self.id)
# first off, we want to save normally no matter what
super().save(*args, **kwargs)
# these shouldn't be edited, only created and deleted
if not broadcast or not created or not self.user.local:
# list items can be updateda, normally you would only broadcast on created
if not broadcast or not self.user.local:
return
# adding an obj to the collection
@ -384,7 +383,7 @@ class CollectionItemMixin(ActivitypubMixin):
""" AP for shelving a book"""
collection_field = getattr(self, self.collection_field)
return activitypub.Add(
id=self.get_remote_id(),
id="{:s}#add".format(collection_field.remote_id),
actor=user.remote_id,
object=self.to_activity_dataclass(),
target=collection_field.remote_id,
@ -394,7 +393,7 @@ class CollectionItemMixin(ActivitypubMixin):
""" AP for un-shelving a book"""
collection_field = getattr(self, self.collection_field)
return activitypub.Remove(
id=self.get_remote_id(),
id="{:s}#remove".format(collection_field.remote_id),
actor=user.remote_id,
object=self.to_activity_dataclass(),
target=collection_field.remote_id,