From 78e47c3236856bcc9ab83a3ef9fdbb070a5a3c59 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 28 Apr 2024 19:45:32 +0200 Subject: [PATCH] [backend/streaming] Don't send notes older than a 5 minutes to home timeline streams This fixes the issue where when older notes get ingested through ways other than direct federation, they don't erroneously appear at the top of the home timeline. --- .../Controllers/Mastodon/Streaming/Channels/UserChannel.cs | 1 + .../Hubs/Helpers/StreamingConnectionAggregate.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/UserChannel.cs b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/UserChannel.cs index 0c5b4cbf..2d0335b7 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/UserChannel.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/UserChannel.cs @@ -107,6 +107,7 @@ public class UserChannel(WebSocketConnection connection, bool notificationsOnly) var wrapped = IsApplicable(note); if (wrapped == null) return; if (IsFiltered(note)) return; + if (note.CreatedAt < DateTime.UtcNow - TimeSpan.FromMinutes(5)) return; await using var scope = connection.ScopeFactory.CreateAsyncScope(); var renderer = scope.ServiceProvider.GetRequiredService(); diff --git a/Iceshrimp.Backend/Hubs/Helpers/StreamingConnectionAggregate.cs b/Iceshrimp.Backend/Hubs/Helpers/StreamingConnectionAggregate.cs index 7b145839..d7a985a8 100644 --- a/Iceshrimp.Backend/Hubs/Helpers/StreamingConnectionAggregate.cs +++ b/Iceshrimp.Backend/Hubs/Helpers/StreamingConnectionAggregate.cs @@ -236,10 +236,10 @@ public sealed class StreamingConnectionAggregate : IDisposable if (note.UserHost == null) timelines.Add(StreamingTimeline.Local); - if (IsFollowingOrSelf(note.User)) + if (IsFollowingOrSelf(note.User) && note.CreatedAt > DateTime.UtcNow - TimeSpan.FromMinutes(5)) timelines.Add(StreamingTimeline.Home); } - else + else if (note.CreatedAt > DateTime.UtcNow - TimeSpan.FromMinutes(5)) { // We already enumerated _following in IsApplicable() timelines.Add(StreamingTimeline.Home);