fix: track newest notification ID in Mastodon polling fallback#538
Open
Fail-Safe wants to merge 1 commit intoRightNow-AI:mainfrom
Open
fix: track newest notification ID in Mastodon polling fallback#538Fail-Safe wants to merge 1 commit intoRightNow-AI:mainfrom
Fail-Safe wants to merge 1 commit intoRightNow-AI:mainfrom
Conversation
The polling loop was updating last_notification_id on every iteration, leaving it set to the oldest (smallest) ID in the batch after the loop completed. On the next poll, since_id was set to that oldest ID, causing Mastodon to return all previously seen notifications again. Re-delivered notifications caused the bot to respond to the same user mention repeatedly. Combined with api_post_status chaining each response chunk as a reply to the previous chunk, this produced long self-reply threads that appeared to be the bot conversing with itself. Fix: capture the first (newest) notification ID before processing the batch, so since_id always advances correctly on each poll cycle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
since_idtracking in the Mastodon REST polling fallback so previously seen notifications are never re-deliveredlast_notification_idupdate out of the processing loop and captures the first (newest) notification ID before iteratingProblem
Mastodon returns notifications in reverse chronological order (newest first). The polling loop was updating
last_notification_idon every iteration, leaving it set to the oldest (smallest) ID in the batch after the loop completed.On the next poll,
since_idwas set to that oldest ID, so the API returned all notifications newer than it — including every notification already processed in the previous batch. This caused the bot to respond to the same user mention repeatedly on every poll cycle.Combined with
api_post_statuschaining each response chunk as a reply to the previous chunk, repeated responses accumulated into long self-reply threads that appeared to be the bot conversing with itself.Test plan
cargo test -p openfang-channelspasses cleanly🤖 Generated with Claude Code