Add sort order to followers/following ordered collection querysets

This commit is contained in:
Mouse Reeve 2020-12-31 13:47:26 -08:00
parent e066c53dd0
commit 2f9123c206

View file

@ -130,14 +130,22 @@ class User(OrderedCollectionPageMixin, AbstractUser):
def to_following_activity(self, **kwargs): def to_following_activity(self, **kwargs):
''' activitypub following list ''' ''' activitypub following list '''
remote_id = '%s/following' % self.remote_id remote_id = '%s/following' % self.remote_id
return self.to_ordered_collection(self.following.all(), \ return self.to_ordered_collection(
remote_id=remote_id, id_only=True, **kwargs) self.following.order_by('-updated_date').all(),
remote_id=remote_id,
id_only=True,
**kwargs
)
def to_followers_activity(self, **kwargs): def to_followers_activity(self, **kwargs):
''' activitypub followers list ''' ''' activitypub followers list '''
remote_id = '%s/followers' % self.remote_id remote_id = '%s/followers' % self.remote_id
return self.to_ordered_collection(self.followers.all(), \ return self.to_ordered_collection(
remote_id=remote_id, id_only=True, **kwargs) self.followers.order_by('-updated_date').all(),
remote_id=remote_id,
id_only=True,
**kwargs
)
def to_activity(self): def to_activity(self):
''' override default AP serializer to add context object ''' override default AP serializer to add context object