Merge pull request #1534 from bookwyrm-social/followers-display
Fixes privacy filters for followers-only replies
This commit is contained in:
commit
eac1ed3484
3 changed files with 76 additions and 5 deletions
|
@ -67,16 +67,15 @@ class BookWyrmModel(models.Model):
|
|||
return
|
||||
|
||||
# you can see the followers only posts of people you follow
|
||||
if (
|
||||
self.privacy == "followers"
|
||||
and self.user.followers.filter(id=viewer.id).first()
|
||||
if self.privacy == "followers" and (
|
||||
self.user.followers.filter(id=viewer.id).first()
|
||||
):
|
||||
return
|
||||
|
||||
# you can see dms you are tagged in
|
||||
if hasattr(self, "mention_users"):
|
||||
if (
|
||||
self.privacy == "direct"
|
||||
self.privacy in ["direct", "followers"]
|
||||
and self.mention_users.filter(id=viewer.id).first()
|
||||
):
|
||||
return
|
||||
|
|
|
@ -224,6 +224,16 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
~Q(Q(user=viewer) | Q(mention_users=viewer)), privacy="direct"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def followers_filter(cls, queryset, viewer):
|
||||
"""Override-able filter for "followers" privacy level"""
|
||||
return queryset.exclude(
|
||||
~Q( # not yourself, a follower, or someone who is tagged
|
||||
Q(user__followers=viewer) | Q(user=viewer) | Q(mention_users=viewer)
|
||||
),
|
||||
privacy="followers", # and the status is followers only
|
||||
)
|
||||
|
||||
|
||||
class GeneratedNote(Status):
|
||||
"""these are app-generated messages about user activity"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue