From 26e932aa7b97018717565f9c59bb0435bb4297d1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 23 Aug 2021 15:47:14 -0700 Subject: [PATCH] Increment unread count less wildly Works on #1293 --- bookwyrm/activitystreams.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index 0e07905ba..c6ad57608 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -23,14 +23,15 @@ class ActivityStream(RedisStore): """statuses are sorted by date published""" return obj.published_date.timestamp() - def add_status(self, status): + def add_status(self, status, increment_unread=False): """add a status to users' feeds""" # the pipeline contains all the add-to-stream activities pipeline = self.add_object_to_related_stores(status, execute=False) - for user in self.get_audience(status): - # add to the unread status count - pipeline.incr(self.unread_id(user)) + if increment_unread: + for user in self.get_audience(status): + # add to the unread status count + pipeline.incr(self.unread_id(user)) # and go! pipeline.execute() @@ -262,7 +263,7 @@ def add_status_on_create(sender, instance, created, *args, **kwargs): return for stream in streams.values(): - stream.add_status(instance) + stream.add_status(instance, increment_unread=created) if sender != models.Boost: return