Build/project structure #142

Merged
BlackAngelTV merged 80 commits from build/project-structure into main 2026-09-23 14:31:21 +02:00
Showing only changes of commit 13f8e24e54 - Show all commits
@@ -0,0 +1,33 @@
import { env } from '../../config/env.js';
import { createLogger } from '../../core/logger.js';
const log = createLogger('notifications');
const defaultChannels = {
issues: env.channels.notifIssues,
pull_request: env.channels.notifPullRequests,
push: env.channels.notifCommits,
release: env.channels.notifReleases,
errors: env.channels.notifErrors,
};
// TODO(M9-T01): resolve channels from notification_channels in SQLite first.
export function resolveChannelId(type) {
return defaultChannels[type] ?? null;
}
/** Sends a notification payload to the channel configured for its type (M9). */
export async function notify(client, type, payload) {
const channelId = resolveChannelId(type);
if (!channelId) {
log.debug(`No channel configured for notification type ${type}`);
return;
}
const channel = await client.channels.fetch(channelId).catch(() => null);
if (!channel?.isSendable()) {
log.warn(`Notification channel unavailable for ${type}`, { channelId });
return;
}
await channel.send(payload);
}