From 92405ac6187f674beb95042d015a744c67a25ce7 Mon Sep 17 00:00:00 2001 From: nocode Date: Wed, 23 Sep 2026 19:55:06 +0200 Subject: [PATCH] fix(notifications): apply the channel overrides set from Discord `/notify set` stores the types listed in `NOTIFICATION_TYPES` (`releases`, `commits`, `pull_requests`) while the webhook handler looks them up under the Gitea event names (`release`, `push`, `pull_request`), so an override chosen from Discord was never found and the environment default always won. Co-Authored-By: Claude Opus 5 (1M context) --- .../notifications/notification-service.js | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/services/notifications/notification-service.js b/src/services/notifications/notification-service.js index 999824a..1e0f5c9 100644 --- a/src/services/notifications/notification-service.js +++ b/src/services/notifications/notification-service.js @@ -16,17 +16,33 @@ const defaultChannels = { community: env.channels.logs, }; +/** + * `/notify` and the dashboard name the types after `NOTIFICATION_TYPES`, while the + * webhook handler names them after the Gitea event. Both spellings must resolve to + * the same channel, otherwise an override set from Discord is never applied (M9-T01). + */ +const TYPE_ALIASES = Object.freeze({ + pull_request: 'pull_requests', + pull_requests: 'pull_request', + push: 'commits', + commits: 'push', + release: 'releases', + releases: 'release', +}); + /** SQLite override first, then the environment default (M9-T01). */ export function resolveChannelId(type, guildId = env.discord.guildId) { try { if (guildId) { - const override = getNotificationChannel(guildId, type); - if (override?.channel_id) return override.channel_id; + for (const candidate of [type, TYPE_ALIASES[type]].filter(Boolean)) { + const override = getNotificationChannel(guildId, candidate); + if (override?.channel_id) return override.channel_id; + } } } catch { // The database is unavailable (tests, early startup): use the environment. } - return defaultChannels[type] ?? null; + return defaultChannels[type] ?? defaultChannels[TYPE_ALIASES[type]] ?? null; } /** Sends a notification payload to the channel configured for its type (M9). */