From c6caa5a3f40f874a3a56e6b6223d5ac93c3af557 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 15 Oct 2021 13:26:02 -0700 Subject: [PATCH] Fixes privacy display --- bookwyrm/models/base_model.py | 6 +----- bookwyrm/models/status.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bookwyrm/models/base_model.py b/bookwyrm/models/base_model.py index 46a0d7232..07f6b0d5c 100644 --- a/bookwyrm/models/base_model.py +++ b/bookwyrm/models/base_model.py @@ -69,17 +69,13 @@ class BookWyrmModel(models.Model): # you can see the followers only posts of people you follow if self.privacy == "followers" and ( self.user.followers.filter(id=viewer.id).first() - or ( - hasattr(self, "mention_users") - and self.mention_users.filter(id=viewer.id) - ) ): 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 diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 1325aa884..610f076d3 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -220,6 +220,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"""