Small tweaks to commends and super() calls
This commit is contained in:
parent
6a3c01a67f
commit
fd66ff1861
|
@ -19,12 +19,12 @@ class ActivityStream(RedisStore):
|
||||||
return "{}-unread".format(self.stream_id(user))
|
return "{}-unread".format(self.stream_id(user))
|
||||||
|
|
||||||
def get_rank(self, obj): # pylint: disable=no-self-use
|
def get_rank(self, obj): # pylint: disable=no-self-use
|
||||||
""" the sort rank of a status, which is published date """
|
""" statuses are sorted by date published """
|
||||||
return obj.published_date.timestamp()
|
return obj.published_date.timestamp()
|
||||||
|
|
||||||
def add_status(self, status):
|
def add_status(self, status):
|
||||||
""" add a status to users' feeds """
|
""" add a status to users' feeds """
|
||||||
# the pipeline contains all the addp-to-stream activities
|
# the pipeline contains all the add-to-stream activities
|
||||||
pipeline = self.add_object_to_related_stores(status, execute=False)
|
pipeline = self.add_object_to_related_stores(status, execute=False)
|
||||||
|
|
||||||
for user in self.get_audience(status):
|
for user in self.get_audience(status):
|
||||||
|
@ -36,11 +36,13 @@ class ActivityStream(RedisStore):
|
||||||
|
|
||||||
def add_user_statuses(self, viewer, user):
|
def add_user_statuses(self, viewer, user):
|
||||||
""" add a user's statuses to another user's feed """
|
""" add a user's statuses to another user's feed """
|
||||||
|
# only add the statuses that the viewer should be able to see (ie, not dms)
|
||||||
statuses = privacy_filter(viewer, user.status_set.all())
|
statuses = privacy_filter(viewer, user.status_set.all())
|
||||||
self.bulk_add_objects_to_store(statuses, self.stream_id(viewer))
|
self.bulk_add_objects_to_store(statuses, self.stream_id(viewer))
|
||||||
|
|
||||||
def remove_user_statuses(self, viewer, user):
|
def remove_user_statuses(self, viewer, user):
|
||||||
""" remove a user's status from another user's feed """
|
""" remove a user's status from another user's feed """
|
||||||
|
# remove all so that followers only statuses are removed
|
||||||
statuses = user.status_set.all()
|
statuses = user.status_set.all()
|
||||||
self.bulk_remove_objects_from_store(statuses, self.stream_id(viewer))
|
self.bulk_remove_objects_from_store(statuses, self.stream_id(viewer))
|
||||||
|
|
||||||
|
@ -49,7 +51,7 @@ class ActivityStream(RedisStore):
|
||||||
# clear unreads for this feed
|
# clear unreads for this feed
|
||||||
r.set(self.unread_id(user), 0)
|
r.set(self.unread_id(user), 0)
|
||||||
|
|
||||||
statuses = super().get_store(self.stream_id(user))
|
statuses = self.get_store(self.stream_id(user))
|
||||||
return (
|
return (
|
||||||
models.Status.objects.select_subclasses()
|
models.Status.objects.select_subclasses()
|
||||||
.filter(id__in=statuses)
|
.filter(id__in=statuses)
|
||||||
|
@ -62,7 +64,7 @@ class ActivityStream(RedisStore):
|
||||||
|
|
||||||
def populate_streams(self, user):
|
def populate_streams(self, user):
|
||||||
""" go from zero to a timeline """
|
""" go from zero to a timeline """
|
||||||
super().populate_store(self.stream_id(user))
|
self.populate_store(self.stream_id(user))
|
||||||
|
|
||||||
def get_audience(self, status): # pylint: disable=no-self-use
|
def get_audience(self, status): # pylint: disable=no-self-use
|
||||||
""" given a status, what users should see it """
|
""" given a status, what users should see it """
|
||||||
|
|
Loading…
Reference in New Issue