Exclude replies in most situations from timelines
This commit is contained in:
parent
a4c9e85da2
commit
5fe5f04955
|
@ -23,13 +23,23 @@ class FanOutStates(StateGraph):
|
||||||
post = await fan_out.subject_post.afetch_full()
|
post = await fan_out.subject_post.afetch_full()
|
||||||
if fan_out.identity.local:
|
if fan_out.identity.local:
|
||||||
# Make a timeline event directly
|
# Make a timeline event directly
|
||||||
# TODO: Exclude replies to people we don't follow
|
# If it's a reply, we only add it if we follow at least one
|
||||||
await sync_to_async(TimelineEvent.add_post)(
|
# of the people mentioned.
|
||||||
identity=fan_out.identity,
|
add = True
|
||||||
post=post,
|
mentioned = {identity.id for identity in post.mentions.all()}
|
||||||
)
|
if post.in_reply_to:
|
||||||
|
add = False
|
||||||
|
async for follow in fan_out.identity.outbound_follows.all():
|
||||||
|
if follow.target_id in mentioned:
|
||||||
|
add = True
|
||||||
|
break
|
||||||
|
if add:
|
||||||
|
await sync_to_async(TimelineEvent.add_post)(
|
||||||
|
identity=fan_out.identity,
|
||||||
|
post=post,
|
||||||
|
)
|
||||||
# We might have been mentioned
|
# We might have been mentioned
|
||||||
if fan_out.identity in list(post.mentions.all()):
|
if fan_out.identity.id in mentioned:
|
||||||
TimelineEvent.add_mentioned(
|
TimelineEvent.add_mentioned(
|
||||||
identity=fan_out.identity,
|
identity=fan_out.identity,
|
||||||
post=post,
|
post=post,
|
||||||
|
|
|
@ -71,7 +71,11 @@ class Local(ListView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return (
|
return (
|
||||||
Post.objects.filter(visibility=Post.Visibilities.public, author__local=True)
|
Post.objects.filter(
|
||||||
|
visibility=Post.Visibilities.public,
|
||||||
|
author__local=True,
|
||||||
|
in_reply_to__isnull=True,
|
||||||
|
)
|
||||||
.select_related("author")
|
.select_related("author")
|
||||||
.prefetch_related("attachments")
|
.prefetch_related("attachments")
|
||||||
.order_by("-created")[:50]
|
.order_by("-created")[:50]
|
||||||
|
@ -97,7 +101,9 @@ class Federated(ListView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return (
|
return (
|
||||||
Post.objects.filter(visibility=Post.Visibilities.public)
|
Post.objects.filter(
|
||||||
|
visibility=Post.Visibilities.public, in_reply_to__isnull=True
|
||||||
|
)
|
||||||
.select_related("author")
|
.select_related("author")
|
||||||
.prefetch_related("attachments")
|
.prefetch_related("attachments")
|
||||||
.order_by("-created")[:50]
|
.order_by("-created")[:50]
|
||||||
|
|
Loading…
Reference in New Issue