Repository navigation
feat: Discord webhook support and fixes for webhook logging and Moodle - #10
Merged
Merged
Conversation
The http package puts the request URI into ClientException messages, so with PALA_DEBUG=1 a failed send printed the secret webhook. Only the exception type is logged now. Adds the AlertSink interface the Slack and Discord notifiers share, and a test helper that captures debug output. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Reads PALA_DISCORD_WEBHOOK or <configDir>/discord_webhook and accepts only https://discord.com (also discordapp.com, ptb. and canary.) /api/webhooks/ <id>/<token> addresses. Posts JSON with an empty allowed_mentions.parse so alert text never pings anyone, splits messages over 2000 characters at line boundaries, retries once after a 429 using retry_after, and never throws or logs the URL. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
One flush replaces the Slack-only one. Slack and Discord work at the same time, each message uses the sink's own bold markup, and a failing sink does not stop the other. The Gemini summary logic and its privacy rule are unchanged: the prompt holds the gemini form of each alert, and a run with no alerts or no sink makes no API call. A failed Kréta login is now reported to every sink too. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…a fetch A refused login (Moodle error code invalidlogin) sets moodleLoginFailed in the auth data with a salted hash of the username and password, and the login is skipped until either changes. Timeouts, HTTP errors and other server errors never lock it. Notifications and events are each recorded only after the server returned that list, so a failed first fetch no longer makes the next run announce every unread item. Adds crypto as a direct dependency; it was already in the lock file. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Adds Discord webhook support next to Slack, and fixes three known issues from the Slack/Moodle/Gemini work.
lib/utils/discord_notifier.dart, modeled onSlackNotifier. Webhook fromPALA_DISCORD_WEBHOOKor<configDir>/discord_webhook. Onlyhttps://discord.com,discordapp.com,ptb.discord.comandcanary.discord.com/api/webhooks/<digits>/<token>addresses are accepted. Postsallowed_mentions: {"parse": []}so alert text never pings anyone. Messages over 2000 characters are split at line boundaries. Success is HTTP 204; a 429 waitsretry_afteronce (capped at 30 s) and retries once. It never throws and never logs the URL or token.PALA_DEBUG=1, becauseClientExceptionmessages carryuri=. Only the exception type is logged now, for Slack and Discord.invalidlogin) setsmoodleLoginFailedwith a salted hash of the username and password, and is skipped until either changes. Timeouts, HTTP errors and other server errors never lock it.cryptobecomes a direct dependency (already in the lock file).docs/USER.mdupdated in Hungarian.Testing
dart analyze --fatal-infos lib bin test: no issuesdart test: 171 passed (new:discord_notifier_test,alert_digest_test,moodle_tracking_test, extendedslack_notifier_test)Not tried against a real Discord webhook; the tests use fake URLs and mock servers.
To use it in the runner, add a
PALA_DISCORD_WEBHOOKsecret and the matching env line in the "Run Pala check" step.🤖 Generated with Claude Code