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). */