The Notification System in Certimate is a multi-channel alerting subsystem designed to provide real-time updates on certificate renewal status, workflow execution results, and system health. It utilizes a provider-based architecture, allowing for extensible support of various communication platforms including Email, Webhooks, and instant messaging services.
The system is structured into three layers:
NotifyService): Orchestrates high-level logic, such as the test-push functionality and integration with the repository layer to fetch credentials internal/notify/service.go15-17notifiers.Registries): A registry-based factory that maps provider types to their specific implementations and handles the population of configuration structs from generic maps.notifier.Provider): The low-level implementation for each specific channel (e.g., SMTP for Email, HTTP for Webhooks) pkg/core/notifier/providers/email/email.go45-48The following diagram illustrates the flow of a notification request from the API or a Workflow Node through to the final delivery.
Notification Delivery Flow
Sources: internal/notify/service.go25-45 pkg/core/notifier/providers/email/email.go71-110 internal/notify/service.go15-17
The NotifyService acts as the primary entry point for manual notification triggers, such as the "Test Push" feature in the UI. It depends on an accessRepository to retrieve stored credentials associated with a specific Access record internal/notify/service.go15-17
When a user requests a test notification:
Access record by ID via n.accessRepo.GetById internal/notify/service.go27Reserve field set to "notif") internal/notify/service.go30-31SendNotificationRequest with a default subject [Certimate] Notification Testing and message Welcome to use Certimate! internal/notify/service.go11-12 internal/notify/service.go38-44NotifyClient via NewClient() to dispatch the message internal/notify/service.go37-45Sources: internal/notify/service.go25-50
Every notification channel must implement the notifier.Provider interface. This ensures a consistent contract for the dispatcher regardless of the underlying protocol.
The interface requires a Notify method and a SetLogger method for observability:
Notify(ctx, subject, message): Executes the actual delivery. For example, the Email provider uses smtp.Client to send the message pkg/core/notifier/providers/email/email.go71-82 pkg/core/notifier/providers/email/email.go105SetLogger(logger): Allows the workflow engine to inject node-specific logging pkg/core/notifier/providers/email/email.go63-69Providers are registered in the internal/notify/notifiers package. This registers a factory function that transforms generic configuration maps into concrete provider instances using xmaps.Populate.
Code to Entity Mapping: Email Provider Initialization
Sources: pkg/core/notifier/providers/email/email.go19-43 ui/src/components/access/forms/AccessConfigFieldsProviderEmail.tsx11-111 internal/tools/smtp/client.go18-29
Certimate supports a wide array of notification channels. Each channel is defined by a NotificationProviderType. Note that Bark, Gotify, ServerChan, Pushover, and PushPlus are not present in the current implementation; Matrix and Mattermost are supported.
| Channel | Implementation Detail | Configuration Key Examples |
|---|---|---|
| SMTP client with HTML/Plain support | smtpHost, smtpPort, username, senderAddress pkg/core/notifier/providers/email/email.go19-43 | |
| Webhook | Generic HTTP with configurable methods | webhookUrl, method, headers, webhookData pkg/core/notifier/providers/webhook/webhook.go26-41 |
| Telegram | Telegram Bot API | botToken, chatId pkg/core/notifier/providers/telegrambot/telegrambot.go21-25 |
| DingTalk | Robot Webhook with Sign support | webhookUrl, secret pkg/core/notifier/providers/dingtalkbot/dingtalkbot.go27-35 |
| Lark/Feishu | Bot Webhook with Sign support | webhookUrl, secret pkg/core/notifier/providers/larkbot/larkbot.go26-34 |
| WeCom | Enterprise WeChat Bot | webhookUrl pkg/core/notifier/providers/wecombot/wecombot.go21-25 |
| Slack | Incoming Webhook | webhookUrl pkg/core/notifier/providers/slackbot/slackbot.go21-25 |
| Discord | Webhook | webhookUrl pkg/core/notifier/providers/discordbot/discordbot.go21-25 |
| Mattermost | Mattermost API v4 | serverUrl, username, password, channelId pkg/core/notifier/providers/mattermost/mattermost.go20-29 |
| Matrix | Matrix Client API (homeserver) | serverUrl, accessToken, roomId pkg/sdk3rd/matrix/client.go23-55 |
The Mattermost provider (pkg/core/notifier/providers/mattermost) interacts with the Mattermost API v4:
/api/v4/users/login using Username and Password to obtain a session token from the Token header pkg/core/notifier/providers/mattermost/mattermost.go67-80/api/v4/posts. The message is structured as an attachment containing the subject as the title and message as the text pkg/core/notifier/providers/mattermost/mattermost.go83-102The Matrix provider uses a custom SDK client (pkg/sdk3rd/matrix) to communicate with Matrix homeservers:
.well-known/matrix/client if a server URL is provided pkg/sdk3rd/matrix/client.go67-84rand.Read and timestamps pkg/sdk3rd/matrix/client.go86-90The Email provider (pkg/core/notifier/providers/email) uses an internal SMTP tool to send messages. It supports:
SmtpTls and AllowInsecureConnections. It uses xtls.NewInsecureConfig() when skipping verification pkg/core/notifier/providers/email/email.go25-42 internal/tools/smtp/client.go80MESSAGE_FORMAT_PLAIN and MESSAGE_FORMAT_HTML. For HTML messages, it uses bluemonday to sanitize the content and provides a plain-text alternative pkg/core/notifier/providers/email/email.go88-96SenderName) pkg/core/notifier/providers/email/email.go98-102Instant messaging bots support variable replacement and security signatures.
${CERTIMATE_NOTIFIER_SUBJECT} and ${CERTIMATE_NOTIFIER_MESSAGE} within the JSON payload before sending pkg/core/notifier/providers/larkbot/larkbot.go94-98Sources: pkg/core/notifier/providers/email/email.go71-110 pkg/core/notifier/providers/larkbot/larkbot.go68-139 pkg/core/notifier/providers/mattermost/mattermost.go63-105 pkg/sdk3rd/matrix/client.go23-55 internal/tools/smtp/client.go64-112
Notifications in workflows (the bizNotify node) support templating. The UI allows configuring specific provider settings and message content.
Common template variables (processed by the provider implementations) include:
${CERTIMATE_NOTIFIER_SUBJECT}: The subject line of the notification.${CERTIMATE_NOTIFIER_MESSAGE}: The body content of the notification.${SUBJECT} / ${MESSAGE}: Legacy compatibility variables pkg/core/notifier/providers/larkbot/larkbot.go97-98Sources: pkg/core/notifier/providers/larkbot/larkbot.go94-98
The backend exposes a dedicated endpoint for testing notification configurations before they are used in production workflows.
POST /api/notifications/test-pushNotifyTestPushReq containing Provider and AccessId internal/domain/dtos/notify.go7-10NotifyService.TestPush internal/notify/service.go25Access configuration from the database and validates it is a notification access (access.Reserve == "notif") internal/notify/service.go27-32notifier.Provider is instantiated via NewClient() internal/notify/service.go37[Certimate] Notification Testing and message Welcome to use Certimate! is dispatched internal/notify/service.go11-12 internal/notify/service.go42-43Sources: internal/notify/service.go25-50 internal/domain/dtos/notify.go7-13
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.