From 33d2a45be477b2dea38b5446783420b8bbf94b78 Mon Sep 17 00:00:00 2001 From: ecency Date: Sun, 12 Jul 2026 07:32:11 +0000 Subject: [PATCH] fix: stop forwarding rate-limited checkin activities upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ty=10 rate-limit branch acked repeat visits (same IP within 15 min) with an early 201 but was missing a return — inherited from the Node code — so the duplicate event was still POSTed to the private API on every rate-limited hit, and pipe logged 'headers already sent' each time (the only source of that warning in production). Short-circuit after refreshing the sliding window, as the branch always intended. First-seen and stale-window requests are unchanged. --- dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs b/dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs index 8fb5e5f9..e483ca77 100644 --- a/dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs +++ b/dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs @@ -107,13 +107,12 @@ public static async Task Activities(HttpContext ctx) if (!string.IsNullOrEmpty(rec)) { var nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - if (double.TryParse(rec, System.Globalization.NumberStyles.Float, + var withinWindow = double.TryParse(rec, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var recMs) - && nowMs - recMs < 900000) + && nowMs - recMs < 900000; + + if (withinWindow) { - // Node sends 201 here WITHOUT returning; the cache write and the - // upstream usr-activity call below still run (pipe then skips the - // second response) — replicated as-is. await ctx.SendJson(201, new JsonObject()); } try @@ -126,6 +125,15 @@ public static async Task Activities(HttpContext ctx) Console.Error.WriteLine(e); Console.Error.WriteLine("Cache set failed."); } + if (withinWindow) + { + // The Node implementation was missing this return: it acked the + // rate-limited checkin with 201 but still forwarded the duplicate + // event upstream (pipe then skipped the second response, logging + // "headers already sent" on every occurrence). Short-circuit after + // refreshing the sliding window, as the branch always intended. + return; + } } else {