Adds privacy and recipient details to list items
This commit is contained in:
@ -359,6 +359,20 @@ class CollectionItemMixin(ActivitypubMixin):
|
||||
|
||||
activity_serializer = activitypub.CollectionItem
|
||||
|
||||
@property
|
||||
def privacy(self):
|
||||
""" inherit the privacy of the list, or direct if pending """
|
||||
collection_field = getattr(self, self.collection_field)
|
||||
if self.approved:
|
||||
return collection_field.privacy
|
||||
return "direct"
|
||||
|
||||
@property
|
||||
def recipients(self):
|
||||
""" the owner of the list is a direct recipient """
|
||||
collection_field = getattr(self, self.collection_field)
|
||||
return [collection_field.user]
|
||||
|
||||
def save(self, *args, broadcast=True, **kwargs):
|
||||
""" broadcast updated """
|
||||
# first off, we want to save normally no matter what
|
||||
|
@ -61,9 +61,7 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
|
||||
book = fields.ForeignKey(
|
||||
"Edition", on_delete=models.PROTECT, activitypub_field="book"
|
||||
)
|
||||
book_list = models.ForeignKey(
|
||||
"List", on_delete=models.CASCADE
|
||||
)
|
||||
book_list = models.ForeignKey("List", on_delete=models.CASCADE)
|
||||
user = fields.ForeignKey(
|
||||
"User", on_delete=models.PROTECT, activitypub_field="actor"
|
||||
)
|
||||
|
@ -68,9 +68,7 @@ class ShelfBook(CollectionItemMixin, BookWyrmModel):
|
||||
book = fields.ForeignKey(
|
||||
"Edition", on_delete=models.PROTECT, activitypub_field="book"
|
||||
)
|
||||
shelf = models.ForeignKey(
|
||||
"Shelf", on_delete=models.PROTECT
|
||||
)
|
||||
shelf = models.ForeignKey("Shelf", on_delete=models.PROTECT)
|
||||
user = fields.ForeignKey(
|
||||
"User", on_delete=models.PROTECT, activitypub_field="actor"
|
||||
)
|
||||
|
Reference in New Issue
Block a user