Skip to content

feat: Discord webhook support and fixes for webhook logging and Moodle - #10

Merged
CsPS0 merged 5 commits into
mainfrom
feat/discord-notifier
Nov 11, 2026
Merged

CsPS0 merged 5 commits into
mainfrom
feat/discord-notifier

Conversation

@CsPS0

@CsPS0 CsPS0 commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Summary

Adds Discord webhook support next to Slack, and fixes three known issues from the Slack/Moodle/Gemini work.

  • Discord: lib/utils/discord_notifier.dart, modeled on SlackNotifier. Webhook from PALA_DISCORD_WEBHOOK or <configDir>/discord_webhook. Only https://discord.com, discordapp.com, ptb.discord.com and canary.discord.com /api/webhooks/<digits>/<token> addresses are accepted. Posts allowed_mentions: {"parse": []} so alert text never pings anyone. Messages over 2000 characters are split at line boundaries. Success is HTTP 204; a 429 waits retry_after once (capped at 30 s) and retries once. It never throws and never logs the URL or token.
  • One flush, every sink: Slack and Discord work at the same time, each with its own bold markup. The Gemini summary logic and its privacy rule are unchanged (the prompt gets the name-free text), and a run with no alerts or no sink makes no API call. A failed Kréta login is reported to every sink.
  • Fix: webhook URL in debug logs. A failed Slack send logged the secret URL with PALA_DEBUG=1, because ClientException messages carry uri=. Only the exception type is logged now, for Slack and Discord.
  • Fix: wrong Moodle password reported every run. A refused login (invalidlogin) sets moodleLoginFailed with a salted hash of the username and password, and is skipped until either changes. Timeouts, HTTP errors and other server errors never lock it. crypto becomes a direct dependency (already in the lock file).
  • Fix: first Moodle run. 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.
  • docs/USER.md updated in Hungarian.

Testing

  • dart analyze --fatal-infos lib bin test: no issues
  • dart test: 171 passed (new: discord_notifier_test, alert_digest_test, moodle_tracking_test, extended slack_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_WEBHOOK secret and the matching env line in the "Run Pala check" step.

🤖 Generated with Claude Code

CsPS0 and others added 5 commits November 11, 2026 12:00
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>
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pala Ready Ready Preview Nov 11, 2026 11:07am UTC

@CsPS0
CsPS0 merged commit 0aa95a1 into main Nov 11, 2026
6 checks passed
@CsPS0
CsPS0 deleted the feat/discord-notifier branch November 18, 2026 20:05
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.

1 participant