Flip timelines back to created ordering

Also added in some tracking from where post fetches come from, in case
this re-creates the weird thing where posts emerge from history.
This commit is contained in:
Andrew Godwin 2023-01-14 11:31:17 -07:00
parent ade954c2cd
commit 76076e3387
3 changed files with 11 additions and 9 deletions

View file

@ -853,7 +853,7 @@ class Post(StatorModel):
try:
parent = cls.by_object_uri(post.in_reply_to)
except cls.DoesNotExist:
cls.ensure_object_uri(post.in_reply_to)
cls.ensure_object_uri(post.in_reply_to, reason=post.object_uri)
else:
parent.calculate_stats()
return post
@ -900,7 +900,7 @@ class Post(StatorModel):
raise cls.DoesNotExist(f"Cannot find Post with URI {object_uri}")
@classmethod
def ensure_object_uri(cls, object_uri: str):
def ensure_object_uri(cls, object_uri: str, reason: str | None = None):
"""
Sees if the post is in our local set, and if not, schedules a fetch
for it (in the background)
@ -916,6 +916,7 @@ class Post(StatorModel):
"object": {
"type": "FetchPost",
"object": object_uri,
"reason": reason,
},
}
)

View file

@ -88,9 +88,10 @@ class PostService:
ancestor = self.post
while ancestor.in_reply_to and len(ancestors) < num_ancestors:
object_uri = ancestor.in_reply_to
reason = ancestor.object_uri
ancestor = self.queryset().filter(object_uri=object_uri).first()
if ancestor is None:
Post.ensure_object_uri(object_uri)
Post.ensure_object_uri(object_uri, reason=reason)
break
if ancestor.state in [PostStates.deleted, PostStates.deleted_fanned_out]:
break

View file

@ -37,7 +37,7 @@ class TimelineService:
identity=self.identity,
type__in=[TimelineEvent.Types.post, TimelineEvent.Types.boost],
)
.order_by("-published")
.order_by("-created")
)
def local(self) -> models.QuerySet[Post]:
@ -45,7 +45,7 @@ class TimelineService:
PostService.queryset()
.local_public()
.filter(author__restriction=Identity.Restriction.none)
.order_by("-published")
.order_by("-id")
)
def federated(self) -> models.QuerySet[Post]:
@ -53,7 +53,7 @@ class TimelineService:
PostService.queryset()
.public()
.filter(author__restriction=Identity.Restriction.none)
.order_by("-published")
.order_by("-id")
)
def hashtag(self, hashtag: str | Hashtag) -> models.QuerySet[Post]:
@ -62,14 +62,14 @@ class TimelineService:
.public()
.filter(author__restriction=Identity.Restriction.none)
.tagged_with(hashtag)
.order_by("-published")
.order_by("-id")
)
def notifications(self, types: list[str]) -> models.QuerySet[TimelineEvent]:
return (
self.event_queryset()
.filter(identity=self.identity, type__in=types)
.order_by("-published")
.order_by("-created")
)
def identity_public(self, identity: Identity):
@ -80,5 +80,5 @@ class TimelineService:
PostService.queryset()
.filter(author=identity)
.unlisted(include_replies=True)
.order_by("-created")
.order_by("-id")
)