Skip to content

Avoid replaying already-posted daily notifications - #153

Open
kentoku24 wants to merge 1 commit into
mainfrom
codex/fix-daily-duplicate-replay
Open

Avoid replaying already-posted daily notifications#153
kentoku24 wants to merge 1 commit into
mainfrom
codex/fix-daily-duplicate-replay

Conversation

@kentoku24

Copy link
Copy Markdown
Owner

Summary

  • treat a pending Discord daily notification as delivered if the exact message is already visible from the bot in the target channel
  • avoid replaying the same pending daily notification every scheduled run after an ambiguous delivery failure
  • cover the recovery path with a runner test and extend the fake Discord client with read helpers

Context

  • observed duplicate daily notifications on March 26, 2026 JST after earlier runs reported delivery failure: 1件
  • the repeated hourly posts are consistent with a pending daily message being replayed on every scheduled run

Verification

  • /Users/kentokumatsunami/Documents/GitHub/comic_crawler/.venv/bin/python -m unittest tests.test_runner tests.test_discord_outbound
  • /Users/kentokumatsunami/Documents/GitHub/comic_crawler/.venv/bin/python -m unittest discover -s tests -p 'test_*.py'
  • git diff --check

Residual Risks

  • this fixes the "message actually appeared but delivery was treated as failed" replay case by checking recent channel history; it does not change genuine repeated failures where Discord never accepted the message

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39e0157c8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

bot_user_id = _coerce_text(read_client.get_current_user_id())
if not bot_user_id:
return False
recent_messages = read_client.list_channel_messages(channel_id, limit=10)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scan more than 10 messages before suppressing a retry

The replay suppression check only inspects the latest 10 channel messages, so if more than 10 messages are posted after an ambiguous failure, the previously delivered daily notification is missed and the pending item is re-sent again on the next run. In active channels this recreates the duplicate-post loop this change is trying to prevent; consider paginating history (or scanning since created_at) instead of hard-capping at 10.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants