Skip to content

Modern Docker Management, Designed for Everyone

feat: add support for Matrix notifications (#1679)

singularity0821a62fc2517a9e
diff --git a/backend/internal/models/notification.go b/backend/internal/models/notification.go
index f288377d7..e7a1339f8 100644
--- a/backend/internal/models/notification.go
+++ b/backend/internal/models/notification.go
@@ -15,6 +15,7 @@ const (
NotificationProviderNtfy NotificationProvider = "ntfy"
NotificationProviderPushover NotificationProvider = "pushover"
NotificationProviderGotify NotificationProvider = "gotify"
+ NotificationProviderMatrix NotificationProvider = "matrix"
NotificationProviderGeneric NotificationProvider = "generic"
)
@@ -27,6 +28,7 @@ var validNotificationProviders = map[NotificationProvider]struct{}{
NotificationProviderNtfy: {},
NotificationProviderPushover: {},
NotificationProviderGotify: {},
+ NotificationProviderMatrix: {},
NotificationProviderGeneric: {},
}
@@ -168,6 +170,16 @@ type GotifyConfig struct {
Events map[NotificationEventType]bool `json:"events,omitempty"`
}
+type MatrixConfig struct {
+ Host string `json:"host"`
+ Port int `json:"port,omitempty"`
+ Rooms string `json:"rooms"`
+ Username string `json:"username,omitempty"`
+ Password string `json:"password,omitempty"`
+ DisableTLSVerification bool `json:"disableTlsVerification"`
+ Events map[NotificationEventType]bool `json:"events,omitempty"`
+}
+
type GenericConfig struct {
WebhookURL string `json:"webhookUrl"`
Method string `json:"method,omitempty"`
diff --git a/backend/internal/services/notification_service.go b/backend/internal/services/notification_service.go
index 2ab4a5b04..c64d17fc3 100644
--- a/backend/internal/services/notification_service.go
+++ b/backend/internal/services/notification_service.go
@@ -144,6 +144,8 @@ func (s *NotificationService) SendImageUpdateNotification(ctx context.Context, i
sendErr = s.sendPushoverNotification(ctx, imageRef, updateInfo, setting.Config)
case models.NotificationProviderGotify:
sendErr = s.sendGotifyNotification(ctx, imageRef, updateInfo, setting.Config)
+ case models.NotificationProviderMatrix:
+ sendErr = s.sendMatrixNotification(ctx, imageRef, updateInfo, setting.Config)
case models.NotificationProviderGeneric:
sendErr = s.sendGenericNotification(ctx, imageRef, updateInfo, setting.Config)
default:
@@ -241,6 +243,8 @@ func (s *NotificationService) SendContainerUpdateNotification(ctx context.Contex
sendErr = s.sendPushoverContainerUpdateNotification(ctx, containerName, imageRef, oldDigest, newDigest, setting.Config)
case models.NotificationProviderGotify:
sendErr = s.sendGotifyContainerUpdateNotification(ctx, containerName, imageRef, oldDigest, newDigest, setting.Config)
+ case models.NotificationProviderMatrix:
+ sendErr = s.sendMatrixContainerUpdateNotification(ctx, containerName, imageRef, oldDigest, newDigest, setting.Config)
case models.NotificationProviderGeneric:
sendErr = s.sendGenericContainerUpdateNotification(ctx, containerName, imageRef, oldDigest, newDigest, setting.Config)
default:
@@ -307,6 +311,8 @@ func (s *NotificationService) SendVulnerabilityNotification(ctx context.Context,
sendErr = s.sendPushoverVulnerabilityNotification(ctx, payload, setting.Config)
case models.NotificationProviderGotify:
sendErr = s.sendGotifyVulnerabilityNotification(ctx, payload, setting.Config)
+ case models.NotificationProviderMatrix:
+ sendErr = s.sendMatrixVulnerabilityNotification(ctx, payload, setting.Config)
case models.NotificationProviderGeneric:
sendErr = s.sendGenericVulnerabilityNotification(ctx, payload, setting.Config)
default:
@@ -766,6 +772,8 @@ func (s *NotificationService) TestNotification(ctx context.Context, provider mod
return s.sendPushoverVulnerabilityNotification(ctx, payload, setting.Config)
case models.NotificationProviderGotify:
return s.sendGotifyVulnerabilityNotification(ctx, payload, setting.Config)
+ case models.NotificationProviderMatrix:
+ return s.sendMatrixVulnerabilityNotification(ctx, payload, setting.Config)
case models.NotificationProviderGeneric:
return s.sendGenericVulnerabilityNotification(ctx, payload, setting.Config)
default:
@@ -832,6 +840,8 @@ func (s *NotificationService) TestNotification(ctx context.Context, provider mod
return s.sendPushoverNotification(ctx, "test/image:latest", testUpdate, setting.Config)
case models.NotificationProviderGotify:
return s.sendGotifyNotification(ctx, "test/image:latest", testUpdate, setting.Config)
+ case models.NotificationProviderMatrix:
+ return s.sendMatrixNotification(ctx, "test/image:latest", testUpdate, setting.Config)
case models.NotificationProviderGeneric:
return s.sendGenericNotification(ctx, "test/image:latest", testUpdate, setting.Config)
default:
@@ -994,6 +1004,8 @@ func (s *NotificationService) SendBatchImageUpdateNotification(ctx context.Conte
sendErr = s.sendBatchPushoverNotification(ctx, updatesWithChanges, setting.Config)
case models.NotificationProviderGotify:
sendErr = s.sendBatchGotifyNotification(ctx, updatesWithChanges, setting.Config)
+ case models.NotificationProviderMatrix:
+ sendErr = s.sendBatchMatrixNotification(ctx, updatesWithChanges, setting.Config)
case models.NotificationProviderGeneric:
sendErr = s.sendBatchGenericNotification(ctx, updatesWithChanges, setting.Config)
default:
@@ -2265,6 +2277,37 @@ func (s *NotificationService) sendGotifyVulnerabilityNotification(ctx context.Co
return nil
}
+func (s *NotificationService) sendMatrixVulnerabilityNotification(ctx context.Context, payload VulnerabilityNotificationPayload, config models.JSON) error {
+ var matrixConfig models.MatrixConfig
+ configBytes, err := json.Marshal(config)
+ if err != nil {
+ return fmt.Errorf("failed to marshal Matrix config: %w", err)
+ }
+ if err := json.Unmarshal(configBytes, &matrixConfig); err != nil {
+ return fmt.Errorf("failed to unmarshal Matrix config: %w", err)
+ }
+ if matrixConfig.Password != "" {
+ if decrypted, err := crypto.Decrypt(matrixConfig.Password); err == nil {
+ matrixConfig.Password = decrypted
+ }
+ }
+ message := fmt.Sprintf("⚠️ Vulnerability Found (Fix Available)\n\nCVE: %s\nSeverity: %s\nImage: %s\nFixed version: %s\n",
+ payload.CVEID, payload.Severity, payload.ImageName, payload.FixedVersion)
+ if payload.CVELink != "" {
+ message += fmt.Sprintf("Link: %s\n", payload.CVELink)
+ }
+ if payload.PkgName != "" {
+ message += fmt.Sprintf("Package: %s\n", payload.PkgName)
+ }
+ if payload.InstalledVersion != "" {
+ message += fmt.Sprintf("Installed version: %s\n", payload.InstalledVersion)
+ }
+ if err := notifications.SendMatrix(ctx, matrixConfig, message); err != nil {
+ return fmt.Errorf("failed to send Matrix notification: %w", err)
+ }
+ return nil
+}
+
func (s *NotificationService) sendGenericVulnerabilityNotification(ctx context.Context, payload VulnerabilityNotificationPayload, config models.JSON) error {
var genericConfig models.GenericConfig
configBytes, err := json.Marshal(config)
@@ -2463,6 +2506,128 @@ func (s *NotificationService) sendBatchGotifyNotification(ctx context.Context, u
return nil
}
+func (s *NotificationService) sendMatrixNotification(ctx context.Context, imageRef string, updateInfo *imageupdate.Response, config models.JSON) error {
+ var matrixConfig models.MatrixConfig
+ configBytes, err := json.Marshal(config)
+ if err != nil {
+ return fmt.Errorf("failed to marshal Matrix config: %w", err)
+ }
+ if err := json.Unmarshal(configBytes, &matrixConfig); err != nil {
+ return fmt.Errorf("failed to unmarshal Matrix config: %w", err)
+ }
+
+ if matrixConfig.Password != "" {
+ if decrypted, err := crypto.Decrypt(matrixConfig.Password); err == nil {
+ matrixConfig.Password = decrypted
+ }
+ }
+
+ updateStatus := "No Update"
+ if updateInfo.HasUpdate {
+ updateStatus = "⚠️ Update Available"
+ }
+
+ message := fmt.Sprintf("🔔 Container Image Update Notification\n\n"+
+ "Image: %s\n"+
+ "Status: %s\n"+
+ "Update Type: %s\n",
+ imageRef, updateStatus, updateInfo.UpdateType)
+
+ if updateInfo.CurrentDigest != "" {
+ message += fmt.Sprintf("Current Digest: %s\n", updateInfo.CurrentDigest)
+ }
+ if updateInfo.LatestDigest != "" {
+ message += fmt.Sprintf("Latest Digest: %s\n", updateInfo.LatestDigest)
+ }
+
+ if err := notifications.SendMatrix(ctx, matrixConfig, message); err != nil {
+ return fmt.Errorf("failed to send Matrix notification: %w", err)
+ }
+
+ return nil
+}
+
+func (s *NotificationService) sendMatrixContainerUpdateNotification(ctx context.Context, containerName, imageRef, oldDigest, newDigest string, config models.JSON) error {
+ var matrixConfig models.MatrixConfig
+ configBytes, err := json.Marshal(config)
+ if err != nil {
+ return fmt.Errorf("failed to marshal Matrix config: %w", err)
+ }
+ if err := json.Unmarshal(configBytes, &matrixConfig); err != nil {
+ return fmt.Errorf("failed to unmarshal Matrix config: %w", err)
+ }
+
+ if matrixConfig.Password != "" {
+ if decrypted, err := crypto.Decrypt(matrixConfig.Password); err == nil {
+ matrixConfig.Password = decrypted
+ }
+ }
+
+ message := fmt.Sprintf("✅ Container Successfully Updated\n\n"+
+ "Your container has been updated with the latest image version.\n\n"+
+ "Container: %s\n"+
+ "Image: %s\n"+
+ "Status: ✅ Updated Successfully\n",
+ containerName, imageRef)
+
+ if oldDigest != "" {
+ message += fmt.Sprintf("Previous Version: %s\n", oldDigest)
+ }
+ if newDigest != "" {
+ message += fmt.Sprintf("Current Version: %s\n", newDigest)
+ }
+
+ if err := notifications.SendMatrix(ctx, matrixConfig, message); err != nil {
+ return fmt.Errorf("failed to send Matrix notification: %w", err)
+ }
+
+ return nil
+}
+
+func (s *NotificationService) sendBatchMatrixNotification(ctx context.Context, updates map[string]*imageupdate.Response, config models.JSON) error {
+ var matrixConfig models.MatrixConfig
+ configBytes, err := json.Marshal(config)
+ if err != nil {
+ return fmt.Errorf("failed to marshal Matrix config: %w", err)
+ }
+ if err := json.Unmarshal(configBytes, &matrixConfig); err != nil {
+ return fmt.Errorf("failed to unmarshal Matrix config: %w", err)
+ }
+
+ if matrixConfig.Password != "" {
+ if decrypted, err := crypto.Decrypt(matrixConfig.Password); err == nil {
+ matrixConfig.Password = decrypted
+ }
+ }
+
+ // Build batch message content
+ title := "Container Image Updates Available"
+ description := fmt.Sprintf("%d container image(s) have updates available.", len(updates))
+ if len(updates) == 1 {
+ description = "1 container image has an update available."
+ }
+
+ message := fmt.Sprintf("%s\n\n%s\n\n", title, description)
+
+ for imageRef, update := range updates {
+ message += fmt.Sprintf("%s\n"+
+ "• Type: %s\n"+
+ "• Current: %s\n"+
+ "• Latest: %s\n\n",
+ imageRef,
+ update.UpdateType,
+ update.CurrentDigest,
+ update.LatestDigest,
+ )
+ }
+
+ if err := notifications.SendMatrix(ctx, matrixConfig, message); err != nil {
+ return fmt.Errorf("failed to send batch Matrix notification: %w", err)
+ }
+
+ return nil
+}
+
// MigrateDiscordWebhookUrlToFields migrates legacy Discord webhookUrl to separate webhookId and token fields.
// This should be called during bootstrap to ensure existing Discord configurations are preserved.
func (s *NotificationService) MigrateDiscordWebhookUrlToFields(ctx context.Context) error {
@@ -2594,6 +2759,8 @@ func (s *NotificationService) SendPruneReportNotification(ctx context.Context, r
sendErr = s.sendPushoverPruneNotification(ctx, result, setting.Config)
case models.NotificationProviderGotify:
sendErr = s.sendGotifyPruneNotification(ctx, result, setting.Config)
+ case models.NotificationProviderMatrix:
+ sendErr = s.sendMatrixPruneNotification(ctx, result, setting.Config)
case models.NotificationProviderGeneric:
sendErr = s.sendGenericPruneNotification(ctx, result, setting.Config)
default:
@@ -2864,6 +3031,27 @@ func (s *NotificationService) sendGotifyPruneNotification(ctx context.Context, r
return notifications.SendGotify(ctx, gotifyConfig, message)
}
+func (s *NotificationService) sendMatrixPruneNotification(ctx context.Context, result *system.PruneAllResult, config models.JSON) error {
+ var matrixConfig models.MatrixConfig
+ if err := s.unmarshalConfigInternal(config, &matrixConfig); err != nil {
+ return err
+ }
+
+ message := fmt.Sprintf("Total Space Reclaimed: %s\n"+
+ "Breakdown:\n"+
+ "Containers: %s\n"+
+ "Images: %s\n"+
+ "Volumes: %s\n"+
+ "Build Cache: %s",
+ s.formatBytesInternal(result.SpaceReclaimed),
+ s.formatBytesInternal(result.ContainerSpaceReclaimed),
+ s.formatBytesInternal(result.ImageSpaceReclaimed),
+ s.formatBytesInternal(result.VolumeSpaceReclaimed),
+ s.formatBytesInternal(result.BuildCacheSpaceReclaimed))
+
+ return notifications.SendMatrix(ctx, matrixConfig, message)
+}
+
func (s *NotificationService) sendGenericPruneNotification(ctx context.Context, result *system.PruneAllResult, config models.JSON) error {
var genericConfig models.GenericConfig
if err := s.unmarshalConfigInternal(config, &genericConfig); err != nil {
diff --git a/backend/internal/utils/notifications/matrix_sender.go b/backend/internal/utils/notifications/matrix_sender.go
new file mode 100644
index 000000000..26610c68f
--- /dev/null
+++ b/backend/internal/utils/notifications/matrix_sender.go
@@ -0,0 +1,79 @@
+package notifications
+
+import (
+ "context"
+ "fmt"
+ "net/url"
+ "strings"
+
+ "github.com/getarcaneapp/arcane/backend/internal/models"
+ "github.com/nicholas-fedor/shoutrrr"
+ shoutrrrTypes "github.com/nicholas-fedor/shoutrrr/pkg/types"
+)
+
+// BuildMatrixURL converts MatrixConfig to Shoutrrr URL format
+// URL example: matrix://user:password@host[:port]/[?rooms=!roomID1[,roomAlias2]][&disableTLS=yes]
+func BuildMatrixURL(config models.MatrixConfig) (string, error) {
+ if config.Host == "" {
+ return "", fmt.Errorf("matrix host is required")
+ }
+
+ // Build the base URL
+ u := &url.URL{
+ Scheme: "matrix",
+ }
+
+ // Add authentication if provided (username can be empty)
+ if config.Password != "" {
+ u.User = url.UserPassword(config.Username, config.Password)
+ }
+
+ host := config.Host
+ // Set host and port
+ if config.Port > 0 {
+ u.Host = fmt.Sprintf("%s:%d", host, config.Port)
+ } else {
+ u.Host = host
+ }
+
+ // Add query parameters
+ q := u.Query()
+
+ if config.Rooms != "" {
+ q.Set("rooms", config.Rooms)
+ }
+
+ if config.DisableTLSVerification {
+ q.Set("disabletls", "yes")
+ }
+
+ rawQuery := q.Encode()
+ rawQuery = strings.ReplaceAll(rawQuery, "%21", "!") // required by Matrix notification syntax
+
+ u.RawQuery = rawQuery
+
+ return u.String(), nil
+}
+
+// SendMatrix sends a message via Shoutrrr Matrix using proper service configuration
+func SendMatrix(ctx context.Context, config models.MatrixConfig, message string) error {
+ shoutrrrURL, err := BuildMatrixURL(config)
+ if err != nil {
+ return fmt.Errorf("failed to build shoutrrr Matrix URL: %w", err)
+ }
+
+ sender, err := shoutrrr.CreateSender(shoutrrrURL)
+ if err != nil {
+ return fmt.Errorf("failed to create shoutrrr Matrix sender: %w", err)
+ }
+
+ params := &shoutrrrTypes.Params{}
+
+ errs := sender.Send(message, params)
+ for _, err := range errs {
+ if err != nil {
+ return fmt.Errorf("failed to send Matrix message via shoutrrr: %w", err)
+ }
+ }
+ return nil
+}
diff --git a/backend/internal/utils/notifications/matrix_sender_test.go b/backend/internal/utils/notifications/matrix_sender_test.go
new file mode 100644
index 000000000..77f1deefb
--- /dev/null
+++ b/backend/internal/utils/notifications/matrix_sender_test.go
@@ -0,0 +1,93 @@
+package notifications
+
+import (
+ "testing"
+
+ "github.com/getarcaneapp/arcane/backend/internal/models"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func TestBuildMatrixURL(t *testing.T) {
+ tests := []struct {
+ name string
+ config models.MatrixConfig
+ wantErr bool
+ expected string
+ }{
+ {
+ name: "basic config (host + token)",
+ config: models.MatrixConfig{
+ Host: "matrix.example.com",
+ Password: "t0ken",
+ },
+ wantErr: false,
+ expected: "matrix://:[email protected]",
+ },
+ {
+ name: "config with host + token + room",
+ config: models.MatrixConfig{
+ Host: "matrix.example.com",
+ Password: "t0ken",
+ Rooms: "!roomId",
+ },
+ wantErr: false,
+ expected: "matrix://:[email protected]?rooms=!roomId",
+ },
+ {
+ name: "config with host + username + password + room",
+ config: models.MatrixConfig{
+ Host: "matrix.example.com",
+ Username: "A12345678901234",
+ Password: "passw0rd",
+ Rooms: "!roomId",
+ },
+ wantErr: false,
+ expected: "matrix://A12345678901234:[email protected]?rooms=!roomId",
+ },
+ {
+ name: "config with host + port + username + password + room",
+ config: models.MatrixConfig{
+ Host: "matrix.example.com",
+ Port: 8443,
+ Username: "A12345678901234",
+ Password: "passw0rd",
+ Rooms: "!roomId",
+ },
+ wantErr: false,
+ expected: "matrix://A12345678901234:[email protected]:8443?rooms=!roomId",
+ },
+ {
+ name: "config with all options",
+ config: models.MatrixConfig{
+ Host: "matrix.example.com",
+ Port: 8443,
+ Username: "A12345678901234",
+ Password: "passw0rd",
+ Rooms: "!room1",
+ DisableTLSVerification: true,
+ },
+ wantErr: false,
+ expected: "matrix://A12345678901234:[email protected]:8443?disabletls=yes&rooms=!room1",
+ },
+ {
+ name: "missing host",
+ config: models.MatrixConfig{
+ Username: "A12345678901234",
+ },
+ wantErr: true,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ gotURL, err := BuildMatrixURL(tt.config)
+ if tt.wantErr {
+ require.Error(t, err)
+ } else {
+ require.NoError(t, err)
+ assert.Equal(t, tt.expected, gotURL)
+ }
+ })
+ }
+}
diff --git a/frontend/messages/de.json b/frontend/messages/de.json
index 0e8b5a37b..44ceb026d 100644
--- a/frontend/messages/de.json
+++ b/frontend/messages/de.json
@@ -1820,6 +1820,25 @@
"notifications_gotify_title_help": "Optionaler Titel für Benachrichtigungen überschreiben",
"notifications_gotify_disable_tls_label": "TLS deaktivieren",
"notifications_gotify_disable_tls_help": "HTTP anstelle von HTTPS verwenden (nicht empfohlen für die Produktion)",
+ "notifications_matrix_description": "Benachrichtigungen via Matrix senden, wenn Containerupdates erkannt werden",
+ "notifications_matrix_enabled_label": "Matrix-Benachrichtigungen aktivieren",
+ "notifications_matrix_host_label": "Server Host",
+ "notifications_matrix_host_placeholder": "matrix.example.com",
+ "notifications_matrix_host_help": "Ihr Matrix Server Hostname oder IP-Adresse",
+ "notifications_matrix_port_label": "Port (optional)",
+ "notifications_matrix_port_placeholder": "443",
+ "notifications_matrix_port_help": "Server-Port. Bei 0 belassen, um Standard (443 für HTTPS, 80 für HTTP) zu verwenden",
+ "notifications_matrix_rooms_label": "Matrix Raum (optional)",
+ "notifications_matrix_rooms_placeholder": "!raumId oder raumAlias",
+ "notifications_matrix_rooms_help": "Ihre Matrix Raum ID (mit '!' als Prefix) oder ihr Raum Alias",
+ "notifications_matrix_username_label": "Benutzername",
+ "notifications_matrix_username_placeholder": "Benutzername",
+ "notifications_matrix_username_help": "Benutzername für Authentifizierung (leer wenn Token benutzt wird)",
+ "notifications_matrix_password_label": "Passwort oder Token",
+ "notifications_matrix_password_placeholder": "••••••••",
+ "notifications_matrix_password_help": "Passwort oder Token for Authentifizierung",
+ "notifications_matrix_disable_tls_label": "TLS deaktivieren",
+ "notifications_matrix_disable_tls_help": "HTTP anstelle von HTTPS verwenden (nicht empfohlen für die Produktion)",
"notifications_generic_title": "Allgemeiner Webhook",
"notifications_generic_description": "Sende Benachrichtigungen an jeden Webhook-Endpunkt, der HTTP-POST-Anfragen akzeptiert",
"notifications_generic_enabled_label": "Generische Webhook Benachrichtigungen aktivieren",
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 4f614d3d1..a13fcd839 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -1823,6 +1823,25 @@
"notifications_gotify_title_help": "Optional title override for notifications",
"notifications_gotify_disable_tls_label": "Disable TLS",
"notifications_gotify_disable_tls_help": "Use HTTP instead of HTTPS (not recommended for production)",
+ "notifications_matrix_description": "Send notifications via Matrix when container updates are detected",
+ "notifications_matrix_enabled_label": "Enable Matrix Notifications",
+ "notifications_matrix_host_label": "Server Host",
+ "notifications_matrix_host_placeholder": "matrix.example.com",
+ "notifications_matrix_host_help": "Your Matrix server hostname or IP address",
+ "notifications_matrix_port_label": "Port (Optional)",
+ "notifications_matrix_port_placeholder": "443",
+ "notifications_matrix_port_help": "Server port. Leave at 0 to use default (443 for HTTPS, 80 for HTTP)",
+ "notifications_matrix_rooms_label": "Matrix Room (Optional)",
+ "notifications_matrix_rooms_placeholder": "!roomId or roomAlias",
+ "notifications_matrix_rooms_help": "Your Matrix room ID (prefixed with '!') or alias",
+ "notifications_matrix_username_label": "Username",
+ "notifications_matrix_username_placeholder": "username",
+ "notifications_matrix_username_help": "Username for authentication (emtpy when token is used)",
+ "notifications_matrix_password_label": "Password or token",
+ "notifications_matrix_password_placeholder": "••••••••",
+ "notifications_matrix_password_help": "Password or token for authentication",
+ "notifications_matrix_disable_tls_label": "Disable TLS",
+ "notifications_matrix_disable_tls_help": "Use HTTP instead of HTTPS (not recommended for production)",
"notifications_generic_title": "Generic Webhook",
"notifications_generic_description": "Send notifications to any webhook endpoint that accepts HTTP POST requests",
"notifications_generic_enabled_label": "Enable Generic Webhook Notifications",
diff --git a/frontend/src/lib/types/notification-providers.ts b/frontend/src/lib/types/notification-providers.ts
index 8ae16eab3..c398c6b94 100644
--- a/frontend/src/lib/types/notification-providers.ts
+++ b/frontend/src/lib/types/notification-providers.ts
@@ -6,6 +6,7 @@ export const NOTIFICATION_PROVIDER_KEYS = [
'email',
'generic',
'gotify',
+ 'matrix',
'ntfy',
'pushover',
'signal',
@@ -102,6 +103,16 @@ export interface GotifyFormValues extends BaseProviderFormValues {
disableTls: boolean;
}
+
+export interface MatrixFormValues extends BaseProviderFormValues {
+ host: string;
+ port: number;
+ rooms: string;
+ username: string;
+ password: string;
+ disableTlsVerification: boolean;
+}
+
export interface GenericFormValues extends BaseProviderFormValues {
webhookUrl: string;
method: string;
@@ -128,6 +139,7 @@ export type ProviderFormValues =
| NtfyFormValues
| PushoverFormValues
| GotifyFormValues
+ | MatrixFormValues
| GenericFormValues;
// Map provider keys to their form value types
@@ -140,6 +152,7 @@ export type ProviderFormValuesMap = {
ntfy: NtfyFormValues;
pushover: PushoverFormValues;
gotify: GotifyFormValues;
+ matrix: MatrixFormValues;
generic: GenericFormValues;
};
@@ -428,6 +441,24 @@ export function gotifySettingsToFormValues(settings?: NotificationSettings): Got
};
}
+export function matrixSettingsToFormValues(settings?: NotificationSettings): MatrixFormValues {
+ const cfg = (settings?.config ?? {}) as Record<string, unknown>;
+ const events = (cfg?.events ?? {}) as Record<string, boolean>;
+ return {
+ enabled: settings?.enabled ?? false,
+ host: (cfg?.host as string) || '',
+ port: (cfg?.port as number) || 0,
+ rooms: (cfg?.rooms as string) || '',
+ username: (cfg?.username as string) || '',
+ password: (cfg?.password as string) || '',
+ disableTlsVerification: (cfg?.disableTlsVerification as boolean) ?? false,
+ eventImageUpdate: events?.image_update ?? true,
+ eventContainerUpdate: events?.container_update ?? true,
+ eventVulnerabilityFound: events?.vulnerability_found ?? true,
+ eventPruneReport: events?.prune_report ?? true
+ };
+}
+
export function genericSettingsToFormValues(settings?: NotificationSettings): GenericFormValues {
const cfg = (settings?.config ?? {}) as Record<string, unknown>;
const events = (cfg?.events ?? {}) as Record<string, boolean>;
@@ -527,6 +558,27 @@ export function gotifyFormValuesToSettings(values: GotifyFormValues): Notificati
};
}
+export function matrixFormValuesToSettings(values: MatrixFormValues): NotificationSettings {
+ return {
+ provider: 'matrix',
+ enabled: values.enabled,
+ config: {
+ host: values.host,
+ port: values.port,
+ rooms: values.rooms,
+ username: values.username,
+ password: values.password,
+ disableTlsVerification: values.disableTlsVerification,
+ events: {
+ image_update: values.eventImageUpdate,
+ container_update: values.eventContainerUpdate,
+ vulnerability_found: values.eventVulnerabilityFound,
+ prune_report: values.eventPruneReport
+ }
+ }
+ };
+}
+
export function genericFormValuesToSettings(values: GenericFormValues): NotificationSettings {
// Parse customHeaders string (format: "key1:value1, key2:value2") into object
const customHeaders: Record<string, string> = {};
diff --git a/frontend/src/lib/types/notification.type.ts b/frontend/src/lib/types/notification.type.ts
index 81bd0bc29..b2fde77b5 100644
--- a/frontend/src/lib/types/notification.type.ts
+++ b/frontend/src/lib/types/notification.type.ts
@@ -7,6 +7,7 @@ export type NotificationProvider =
| 'ntfy'
| 'pushover'
| 'gotify'
+ | 'matrix'
| 'generic';
export type EmailTLSMode = 'none' | 'starttls' | 'ssl';
diff --git a/frontend/src/routes/(app)/settings/notifications/+page.svelte b/frontend/src/routes/(app)/settings/notifications/+page.svelte
index 657a78fc4..0ebf300b3 100644
--- a/frontend/src/routes/(app)/settings/notifications/+page.svelte
+++ b/frontend/src/routes/(app)/settings/notifications/+page.svelte
@@ -19,6 +19,7 @@
type NtfyFormValues,
type PushoverFormValues,
type GotifyFormValues,
+ type MatrixFormValues,
type GenericFormValues,
type AppriseFormValues,
type NotificationProviderKey,
@@ -31,6 +32,7 @@
ntfySettingsToFormValues,
pushoverSettingsToFormValues,
gotifySettingsToFormValues,
+ matrixSettingsToFormValues,
genericSettingsToFormValues,
appriseSettingsToFormValues,
discordFormValuesToSettings,
@@ -41,6 +43,7 @@
ntfyFormValuesToSettings,
pushoverFormValuesToSettings,
gotifyFormValuesToSettings,
+ matrixFormValuesToSettings,
genericFormValuesToSettings,
appriseFormValuesToSettings
} from '$lib/types/notification-providers';
@@ -54,6 +57,7 @@
NtfyProviderForm,
PushoverProviderForm,
GotifyProviderForm,
+ MatrixProviderForm,
GenericProviderForm,
AppriseProviderForm
} from './providers';
@@ -87,6 +91,7 @@
let ntfyFormRef: NtfyProviderForm;
let pushoverFormRef: PushoverProviderForm;
let gotifyFormRef: GotifyProviderForm;
+ let matrixFormRef: MatrixProviderForm;
let genericFormRef: GenericProviderForm;
// Saved settings from server (used to detect if settings exist)
@@ -99,6 +104,7 @@
ntfy: null,
pushover: null,
gotify: null,
+ matrix: null,
generic: null
});
@@ -111,6 +117,7 @@
let ntfyValues = $state<NtfyFormValues>(ntfySettingsToFormValues());
let pushoverValues = $state<PushoverFormValues>(pushoverSettingsToFormValues());
let gotifyValues = $state<GotifyFormValues>(gotifySettingsToFormValues());
+ let matrixValues = $state<MatrixFormValues>(matrixSettingsToFormValues());
let genericValues = $state<GenericFormValues>(genericSettingsToFormValues());
let appriseValues = $state<AppriseFormValues>(appriseSettingsToFormValues());
@@ -123,6 +130,7 @@
let ntfyBaseline = $state<NtfyFormValues>(ntfySettingsToFormValues());
let pushoverBaseline = $state<PushoverFormValues>(pushoverSettingsToFormValues());
let gotifyBaseline = $state<GotifyFormValues>(gotifySettingsToFormValues());
+ let matrixBaseline = $state<MatrixFormValues>(matrixSettingsToFormValues());
let genericBaseline = $state<GenericFormValues>(genericSettingsToFormValues());
let appriseBaseline = $state<AppriseFormValues>(appriseSettingsToFormValues());
@@ -135,6 +143,7 @@
const ntfyHasChanges = $derived(JSON.stringify(ntfyValues) !== JSON.stringify(ntfyBaseline));
const pushoverHasChanges = $derived(JSON.stringify(pushoverValues) !== JSON.stringify(pushoverBaseline));
const gotifyHasChanges = $derived(JSON.stringify(gotifyValues) !== JSON.stringify(gotifyBaseline));
+ const matrixHasChanges = $derived(JSON.stringify(matrixValues) !== JSON.stringify(matrixBaseline));
const genericHasChanges = $derived(JSON.stringify(genericValues) !== JSON.stringify(genericBaseline));
const appriseHasChanges = $derived(JSON.stringify(appriseValues) !== JSON.stringify(appriseBaseline));
const hasChanges = $derived(
@@ -146,6 +155,7 @@
ntfyHasChanges ||
pushoverHasChanges ||
gotifyHasChanges ||
+ matrixHasChanges ||
genericHasChanges ||
appriseHasChanges
);
@@ -193,6 +203,9 @@
gotifyValues = gotifySettingsToFormValues(savedSettings.gotify ?? undefined);
gotifyBaseline = { ...gotifyValues };
+ matrixValues = matrixSettingsToFormValues(savedSettings.matrix ?? undefined);
+ matrixBaseline = { ...matrixValues };
+
genericValues = genericSettingsToFormValues(savedSettings.generic ?? undefined);
genericBaseline = { ...genericValues };
@@ -216,6 +229,7 @@
const ntfyValid = ntfyFormRef?.isValid() ?? true;
const pushoverValid = pushoverFormRef?.isValid() ?? true;
const gotifyValid = gotifyFormRef?.isValid() ?? true;
+ const matrixValid = matrixFormRef?.isValid() ?? true;
const genericValid = genericFormRef?.isValid() ?? true;
if (
@@ -228,6 +242,7 @@
ntfyValid &&
pushoverValid &&
gotifyValid &&
+ matrixValid &&
genericValid
)
) {
@@ -344,6 +359,19 @@
}
}
+ // Save Matrix settings if changed
+ if (matrixHasChanges) {
+ try {
+ const settings = matrixFormValuesToSettings(matrixValues);
+ await notificationService.updateSettings('matrix', settings);
+ savedSettings.matrix = settings;
+ matrixBaseline = { ...matrixValues };
+ } catch (error: any) {
+ const errorMsg = error?.response?.data?.error || error.message || 'Unknown error';
+ errors.push(m.notifications_saved_failed({ provider: 'Matrix', error: errorMsg }));
+ }
+ }
+
// Save Generic settings if changed
if (genericHasChanges) {
try {
@@ -391,6 +419,7 @@
ntfyValues = { ...ntfyBaseline };
pushoverValues = { ...pushoverBaseline };
gotifyValues = { ...gotifyBaseline };
+ matrixValues = { ...matrixBaseline };
genericValues = { ...genericBaseline };
appriseValues = { ...appriseBaseline };
}
@@ -562,6 +591,16 @@
/>
</Tabs.Content>
+ <Tabs.Content value="matrix" class="mt-4 space-y-4">
+ <MatrixProviderForm
+ bind:this={matrixFormRef}
+ bind:values={matrixValues}
+ disabled={isReadOnly}
+ {isTesting}
+ onTest={() => testNotification('matrix')}
+ />
+ </Tabs.Content>
+
<Tabs.Content value="generic" class="mt-4 space-y-4">
<GenericProviderForm
bind:this={genericFormRef}
diff --git a/frontend/src/routes/(app)/settings/notifications/providers/MatrixProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/MatrixProviderForm.svelte
new file mode 100644
index 000000000..9c8459cac
--- /dev/null
+++ b/frontend/src/routes/(app)/settings/notifications/providers/MatrixProviderForm.svelte
@@ -0,0 +1,160 @@
+<script lang="ts">
+ import { ArcaneButton } from '$lib/components/arcane-button/index.js';
+ import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';
+ import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';
+ import { Label } from '$lib/components/ui/label';
+ import * as Select from '$lib/components/ui/select/index.js';
+ import { m } from '$lib/paraglide/messages';
+ import { SendEmailIcon } from '$lib/icons';
+ import { z } from 'zod/v4';
+ import type { MatrixFormValues } from '$lib/types/notification-providers';
+ import ProviderFormWrapper from './ProviderFormWrapper.svelte';
+ import EventSubscriptions from './EventSubscriptions.svelte';
+
+ interface Props {
+ values: MatrixFormValues;
+ disabled?: boolean;
+ isTesting?: boolean;
+ onTest?: () => void;
+ }
+
+ let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();
+
+ const schema = z
+ .object({
+ enabled: z.boolean(),
+ host: z.string(),
+ port: z.coerce.number().int().min(0).max(65535),
+ rooms: z.string(),
+ username: z.string(),
+ password: z.string(),
+ disableTlsVerification: z.boolean(),
+ eventImageUpdate: z.boolean(),
+ eventContainerUpdate: z.boolean(),
+ eventVulnerabilityFound: z.boolean(),
+ eventPruneReport: z.boolean()
+ })
+ .superRefine((d, ctx) => {
+ if (!d.enabled) return;
+ if (!d.host.trim()) {
+ ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['host'] });
+ }
+ });
+
+ const validation = $derived.by(() => schema.safeParse(values));
+
+ const fieldErrors = $derived.by(() => {
+ const errs: Partial<Record<keyof MatrixFormValues, string>> = {};
+ if (validation.success) return errs;
+ for (const issue of validation.error.issues) {
+ const key = issue.path?.[0] as keyof MatrixFormValues | undefined;
+ if (!key || errs[key]) continue;
+ errs[key] = issue.message;
+ }
+ return errs;
+ });
+
+ export function isValid(): boolean {
+ return validation.success;
+ }
+</script>
+
+<ProviderFormWrapper
+ id="matrix"
+ title="Matrix"
+ description={m.notifications_matrix_description()}
+ enabledLabel={m.notifications_matrix_enabled_label()}
+ bind:enabled={values.enabled}
+ {disabled}
+>
+ <div class="grid grid-cols-1 gap-4 md:grid-cols-4">
+ <div class="md:col-span-3">
+ <TextInputWithLabel
+ bind:value={values.host}
+ {disabled}
+ label={m.notifications_matrix_host_label()}
+ placeholder={m.notifications_matrix_host_placeholder()}
+ type="text"
+ autocomplete="off"
+ helpText={m.notifications_matrix_host_help()}
+ error={fieldErrors.host}
+ />
+ </div>
+ <div class="md:col-span-1">
+ <TextInputWithLabel
+ bind:value={values.port}
+ {disabled}
+ label={m.notifications_matrix_port_label()}
+ placeholder={m.notifications_matrix_port_placeholder()}
+ type="number"
+ autocomplete="off"
+ helpText={m.notifications_matrix_port_help()}
+ error={fieldErrors.port}
+ />
+ </div>
+ </div>
+
+ <TextInputWithLabel
+ bind:value={values.rooms}
+ {disabled}
+ label={m.notifications_matrix_rooms_label()}
+ placeholder={m.notifications_matrix_rooms_placeholder()}
+ type="text"
+ autocomplete="off"
+ helpText={m.notifications_matrix_rooms_help()}
+ error={fieldErrors.rooms}
+ />
+
+ <TextInputWithLabel
+ bind:value={values.username}
+ {disabled}
+ label={m.notifications_matrix_username_label()}
+ placeholder={m.notifications_matrix_username_placeholder()}
+ type="text"
+ autocomplete="off"
+ helpText={m.notifications_matrix_username_help()}
+ error={fieldErrors.username}
+ />
+
+ <TextInputWithLabel
+ bind:value={values.password}
+ {disabled}
+ label={m.notifications_matrix_password_label()}
+ placeholder={m.notifications_matrix_password_placeholder()}
+ type="password"
+ autocomplete="off"
+ helpText={m.notifications_matrix_password_help()}
+ error={fieldErrors.password}
+ />
+
+ <SwitchWithLabel
+ id="matrix-disable-tls"
+ bind:checked={values.disableTlsVerification}
+ {disabled}
+ label={m.notifications_matrix_disable_tls_label()}
+ description={m.notifications_matrix_disable_tls_help()}
+ />
+
+ <EventSubscriptions
+ providerId="matrix"
+ bind:eventImageUpdate={values.eventImageUpdate}
+ bind:eventContainerUpdate={values.eventContainerUpdate}
+ bind:eventVulnerabilityFound={values.eventVulnerabilityFound}
+ bind:eventPruneReport={values.eventPruneReport}
+ {disabled}
+ />
+
+ {#if onTest}
+ <div class="pt-2">
+ <ArcaneButton
+ action="base"
+ tone="outline"
+ onclick={onTest}
+ disabled={disabled || isTesting}
+ loading={isTesting}
+ icon={SendEmailIcon}
+ customLabel={m.notifications_test_notification()}
+ />
+ </div>
+ {/if}
+</ProviderFormWrapper>
diff --git a/frontend/src/routes/(app)/settings/notifications/providers/index.ts b/frontend/src/routes/(app)/settings/notifications/providers/index.ts
index bc61c67fe..6e09eb249 100644
--- a/frontend/src/routes/(app)/settings/notifications/providers/index.ts
+++ b/frontend/src/routes/(app)/settings/notifications/providers/index.ts
@@ -9,4 +9,5 @@ export { default as EventSubscriptions } from './EventSubscriptions.svelte';
export { default as NtfyProviderForm } from './NtfyProviderForm.svelte';
export { default as PushoverProviderForm } from './PushoverProviderForm.svelte';
export { default as GotifyProviderForm } from './GotifyProviderForm.svelte';
+export { default as MatrixProviderForm } from './MatrixProviderForm.svelte';
export { default as GenericProviderForm } from './GenericProviderForm.svelte';
diff --git a/types/notification/notification.go b/types/notification/notification.go
index 2a9b628c8..e234c512a 100644
--- a/types/notification/notification.go
+++ b/types/notification/notification.go
@@ -27,6 +27,9 @@ const (
// NotificationProviderPushover is the builtin Pushover notification provider.
NotificationProviderPushover Provider = "pushover"
+ // NotificationProviderMatrix is the builtin Matrix webhook notification provider.
+ NotificationProviderMatrix Provider = "matrix"
+
// NotificationProviderGeneric is the builtin Generic webhook notification provider.
NotificationProviderGeneric Provider = "generic"
)