Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: only send notifications when new updates arrive (#1157)
Kyle Mendell3ff957d057e3
diff --git a/.github/workflows/go-linter.yml b/.github/workflows/go-linter.ymlindex 364d4545a..ca09b4637 100644--- a/.github/workflows/go-linter.yml+++ b/.github/workflows/go-linter.yml@@ -31,11 +31,11 @@ jobs:module: [backend, cli, types]include:- module: backend- args: --build-tags=exclude_frontend+ args: --build-tags=exclude_frontend --config=.golangci.yml- module: cli- args: ""+ args: --config=../backend/.golangci.yml- module: types- args: ""+ args: --config=../backend/.golangci.ymlsteps:- name: Checkout codeuses: actions/checkout@v6@@ -49,7 +49,7 @@ jobs:- name: Run Golangci-lintuses: golangci/golangci-lint-action@v9with:- version: v2.6.1+ version: v2.7.2args: ${{ matrix.args }}working-directory: ${{ matrix.module }}only-new-issues: ${{ github.event_name == 'pull_request' }}diff --git a/backend/internal/models/image_update.go b/backend/internal/models/image_update.goindex 0532d6bda..da3695345 100644--- a/backend/internal/models/image_update.go+++ b/backend/internal/models/image_update.go@@ -23,6 +23,8 @@ type ImageUpdateRecord struct {AuthRegistry *string `json:"authRegistry,omitempty" gorm:"column:auth_registry"`UsedCredential bool `json:"usedCredential,omitempty" gorm:"column:used_credential"`+ NotificationSent bool `json:"notificationSent" gorm:"column:notification_sent;default:false"`+BaseModel}diff --git a/backend/internal/services/image_update_service.go b/backend/internal/services/image_update_service.goindex 55d2d1835..1fd1e8e79 100644--- a/backend/internal/services/image_update_service.go+++ b/backend/internal/services/image_update_service.go@@ -555,6 +555,13 @@ func stringToPtr(s string) *string {return &s}+func stringPtrToString(s *string) string {+ if s == nil {+ return ""+ }+ return *s+}+func buildImageUpdateRecord(imageID, repo, tag string, result *imageupdate.Response) *models.ImageUpdateRecord {currentVersion := result.CurrentVersionif currentVersion == "" {@@ -596,6 +603,26 @@ func (s *ImageUpdateService) saveUpdateResultByID(ctx context.Context, imageID srepo, tag := extractRepoAndTagFromImage(dockerImage)updateRecord := buildImageUpdateRecord(imageID, repo, tag, result)+ // Check if there's an existing record to compare state changes+ var existingRecord models.ImageUpdateRecord+ if err := tx.Where("id = ?", imageID).First(&existingRecord).Error; err == nil {+ // Existing record found - check if we need to reset notification_sent+ stateChanged := existingRecord.HasUpdate != updateRecord.HasUpdate+ digestChanged := stringPtrToString(existingRecord.LatestDigest) != stringPtrToString(updateRecord.LatestDigest)+ versionChanged := stringPtrToString(existingRecord.LatestVersion) != stringPtrToString(updateRecord.LatestVersion)++ // Reset notification_sent if the update state changed in any way+ if stateChanged || (updateRecord.HasUpdate && (digestChanged || versionChanged)) {+ updateRecord.NotificationSent = false+ } else {+ // Keep the existing notification_sent value if nothing changed+ updateRecord.NotificationSent = existingRecord.NotificationSent+ }+ } else {+ // New record - start with notification_sent = false+ updateRecord.NotificationSent = false+ }+return tx.Save(updateRecord).Error})}@@ -613,6 +640,34 @@ func (s *ImageUpdateService) getImageIDByRef(ctx context.Context, imageRef strinreturn inspectResponse.ID, nil}+// GetUnnotifiedUpdates returns a map of image IDs that have updates but haven't been notified yet+func (s *ImageUpdateService) GetUnnotifiedUpdates(ctx context.Context) (map[string]*models.ImageUpdateRecord, error) {+ var records []models.ImageUpdateRecord+ if err := s.db.WithContext(ctx).+ Where("has_update = ? AND notification_sent = ?", true, false).+ Find(&records).Error; err != nil {+ return nil, fmt.Errorf("failed to get unnotified updates: %w", err)+ }++ result := make(map[string]*models.ImageUpdateRecord)+ for i := range records {+ result[records[i].ID] = &records[i]+ }+ return result, nil+}++// MarkUpdatesAsNotified marks the given image IDs as having been notified+func (s *ImageUpdateService) MarkUpdatesAsNotified(ctx context.Context, imageIDs []string) error {+ if len(imageIDs) == 0 {+ return nil+ }++ return s.db.WithContext(ctx).+ Model(&models.ImageUpdateRecord{}).+ Where("id IN ?", imageIDs).+ Update("notification_sent", true).Error+}+type batchCred struct {username stringtoken string@@ -926,8 +981,53 @@ func (s *ImageUpdateService) CheckMultipleImages(ctx context.Context, imageRefs"duration", time.Since(startBatch))if s.notificationService != nil {- if notifErr := s.notificationService.SendBatchImageUpdateNotification(ctx, results); notifErr != nil {- slog.WarnContext(ctx, "Failed to send batch update notification", "error", notifErr.Error())+ // Use a context with timeout for notifications+ notifCtx, cancel := context.WithTimeout(ctx, 30*time.Second)+ defer cancel()++ // Get only the updates that haven't been notified yet+ unnotifiedUpdates, err := s.GetUnnotifiedUpdates(notifCtx)+ switch {+ case err != nil:+ slog.WarnContext(ctx, "Failed to get unnotified updates", "error", err.Error())+ case len(unnotifiedUpdates) > 0:+ // Convert unnotified records to the format expected by notification service+ updatesToNotify := make(map[string]*imageupdate.Response)+ imageIDsToMark := make([]string, 0, len(unnotifiedUpdates))++ for imageID, record := range unnotifiedUpdates {+ // Construct image ref from repository and tag+ imageRef := fmt.Sprintf("%s:%s", record.Repository, record.Tag)+ updatesToNotify[imageRef] = &imageupdate.Response{+ HasUpdate: record.HasUpdate,+ UpdateType: record.UpdateType,+ CurrentVersion: record.CurrentVersion,+ LatestVersion: stringPtrToString(record.LatestVersion),+ CurrentDigest: stringPtrToString(record.CurrentDigest),+ LatestDigest: stringPtrToString(record.LatestDigest),+ CheckTime: record.CheckTime,+ ResponseTimeMs: record.ResponseTimeMs,+ Error: stringPtrToString(record.LastError),+ AuthMethod: stringPtrToString(record.AuthMethod),+ AuthUsername: stringPtrToString(record.AuthUsername),+ AuthRegistry: stringPtrToString(record.AuthRegistry),+ UsedCredential: record.UsedCredential,+ }+ imageIDsToMark = append(imageIDsToMark, imageID)+ }++ slog.InfoContext(ctx, "Sending notifications for unnotified updates", "count", len(updatesToNotify))++ if notifErr := s.notificationService.SendBatchImageUpdateNotification(notifCtx, updatesToNotify); notifErr != nil {+ slog.WarnContext(ctx, "Failed to send batch update notification", "error", notifErr.Error())+ } else {+ // Mark the images as notified only if notification was successful+ if markErr := s.MarkUpdatesAsNotified(notifCtx, imageIDsToMark); markErr != nil {+ slog.WarnContext(ctx, "Failed to mark updates as notified", "error", markErr.Error())+ }+ }+ default:+ slog.DebugContext(ctx, "No new updates to notify")}}diff --git a/backend/internal/services/image_update_service_test.go b/backend/internal/services/image_update_service_test.goindex 6a8de2ddf..5523d3f74 100644--- a/backend/internal/services/image_update_service_test.go+++ b/backend/internal/services/image_update_service_test.go@@ -1,11 +1,18 @@package servicesimport (+ "context""testing"+ "time"+ "github.com/getarcaneapp/arcane/backend/internal/database"+ "github.com/getarcaneapp/arcane/backend/internal/models"+ "github.com/getarcaneapp/arcane/types/imageupdate"+ glsqlite "github.com/glebarez/sqlite""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"ref "go.podman.io/image/v5/docker/reference"+ "gorm.io/gorm")// TestParseImageReference tests the parseImageReference function with various image formats@@ -269,3 +276,383 @@ func TestImageUpdateService_DockerReferenceCompatibility(t *testing.T) {})}}++// TestStringPtrToString tests the helper function used for pointer comparison fix+func TestStringPtrToString(t *testing.T) {+ tests := []struct {+ name string+ ptr *string+ want string+ }{+ {+ name: "nil pointer returns empty string",+ ptr: nil,+ want: "",+ },+ {+ name: "valid pointer returns value",+ ptr: stringToPtr("test-value"),+ want: "test-value",+ },+ {+ name: "empty string pointer returns empty string",+ ptr: stringToPtr(""),+ want: "",+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ result := stringPtrToString(tt.ptr)+ assert.Equal(t, tt.want, result)+ })+ }+}++// TestStringToPtr tests the helper function for creating string pointers+func TestStringToPtr(t *testing.T) {+ tests := []struct {+ name string+ input string+ wantNil bool+ }{+ {+ name: "empty string returns nil",+ input: "",+ wantNil: true,+ },+ {+ name: "non-empty string returns pointer",+ input: "test",+ wantNil: false,+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ result := stringToPtr(tt.input)+ if tt.wantNil {+ assert.Nil(t, result)+ } else {+ require.NotNil(t, result)+ assert.Equal(t, tt.input, *result)+ }+ })+ }+}++// setupImageUpdateTestDB creates an in-memory SQLite database for testing+func setupImageUpdateTestDB(t *testing.T) *database.DB {+ t.Helper()+ db, err := gorm.Open(glsqlite.Open(":memory:"), &gorm.Config{})+ require.NoError(t, err)+ require.NoError(t, db.AutoMigrate(&models.ImageUpdateRecord{}))+ return &database.DB{DB: db}+}++// TestNotificationSentLogic tests the notification_sent flag behavior+func TestImageUpdateService_NotificationSentLogic(t *testing.T) {+ db := setupImageUpdateTestDB(t)++ imageID := "sha256:test123"+ repo := "docker.io/library/nginx"+ tag := "latest"++ t.Run("new record starts with notification_sent=false", func(t *testing.T) {+ result := &imageupdate.Response{+ HasUpdate: true,+ UpdateType: "digest",+ CurrentVersion: "1.0",+ LatestVersion: "2.0",+ CurrentDigest: "sha256:old",+ LatestDigest: "sha256:new",+ CheckTime: time.Now(),+ ResponseTimeMs: 100,+ }++ updateRecord := buildImageUpdateRecord(imageID, repo, tag, result)++ // New record should have NotificationSent = false+ assert.False(t, updateRecord.NotificationSent)++ err := db.Create(updateRecord).Error+ require.NoError(t, err)++ // Verify it was saved correctly+ var saved models.ImageUpdateRecord+ err = db.First(&saved, "id = ?", imageID).Error+ require.NoError(t, err)+ assert.False(t, saved.NotificationSent)+ })+}++// TestNotificationSentReset tests that notification_sent resets when update state changes+func TestImageUpdateService_NotificationSentReset(t *testing.T) {+ db := setupImageUpdateTestDB(t)++ imageID := "sha256:test456"+ repo := "docker.io/library/redis"+ tag := "alpine"++ tests := []struct {+ name string+ existingRecord *models.ImageUpdateRecord+ newResult *imageupdate.Response+ expectNotifReset bool+ reason string+ }{+ {+ name: "digest changed - should reset",+ existingRecord: &models.ImageUpdateRecord{+ ID: imageID,+ Repository: repo,+ Tag: tag,+ HasUpdate: true,+ UpdateType: "digest",+ CurrentVersion: "7.0",+ LatestDigest: stringToPtr("sha256:old"),+ NotificationSent: true,+ },+ newResult: &imageupdate.Response{+ HasUpdate: true,+ UpdateType: "digest",+ CurrentVersion: "7.0",+ LatestDigest: "sha256:new",+ CheckTime: time.Now(),+ ResponseTimeMs: 50,+ },+ expectNotifReset: true,+ reason: "digest changed from old to new",+ },+ {+ name: "version changed - should reset",+ existingRecord: &models.ImageUpdateRecord{+ ID: imageID,+ Repository: repo,+ Tag: tag,+ HasUpdate: true,+ UpdateType: "tag",+ CurrentVersion: "7.0",+ LatestVersion: stringToPtr("7.0.1"),+ NotificationSent: true,+ },+ newResult: &imageupdate.Response{+ HasUpdate: true,+ UpdateType: "tag",+ CurrentVersion: "7.0",+ LatestVersion: "7.0.2",+ CheckTime: time.Now(),+ ResponseTimeMs: 50,+ },+ expectNotifReset: true,+ reason: "version changed from 7.0.1 to 7.0.2",+ },+ {+ name: "update state changed - should reset",+ existingRecord: &models.ImageUpdateRecord{+ ID: imageID,+ Repository: repo,+ Tag: tag,+ HasUpdate: false,+ UpdateType: "digest",+ CurrentVersion: "7.0",+ NotificationSent: true,+ },+ newResult: &imageupdate.Response{+ HasUpdate: true,+ UpdateType: "digest",+ CurrentVersion: "7.0",+ CheckTime: time.Now(),+ ResponseTimeMs: 50,+ },+ expectNotifReset: true,+ reason: "HasUpdate changed from false to true",+ },+ {+ name: "nothing changed - should keep flag",+ existingRecord: &models.ImageUpdateRecord{+ ID: imageID,+ Repository: repo,+ Tag: tag,+ HasUpdate: true,+ UpdateType: "digest",+ CurrentVersion: "7.0",+ LatestDigest: stringToPtr("sha256:same"),+ LatestVersion: stringToPtr("7.0.1"),+ NotificationSent: true,+ },+ newResult: &imageupdate.Response{+ HasUpdate: true,+ UpdateType: "digest",+ CurrentVersion: "7.0",+ LatestDigest: "sha256:same",+ LatestVersion: "7.0.1",+ CheckTime: time.Now(),+ ResponseTimeMs: 50,+ },+ expectNotifReset: false,+ reason: "nothing changed",+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ // Clean up any existing record+ db.Exec("DELETE FROM image_updates WHERE id = ?", imageID)++ // Insert existing record+ err := db.Create(tt.existingRecord).Error+ require.NoError(t, err)++ // Verify it was marked as notified+ var check models.ImageUpdateRecord+ err = db.First(&check, "id = ?", imageID).Error+ require.NoError(t, err)+ assert.True(t, check.NotificationSent, "existing record should be marked as notified")++ // Simulate comparison logic from saveUpdateResultByID+ updateRecord := buildImageUpdateRecord(imageID, repo, tag, tt.newResult)++ var existingRecord models.ImageUpdateRecord+ err = db.Where("id = ?", imageID).First(&existingRecord).Error+ require.NoError(t, err)++ // This is the logic we're testing - comparing string values not pointers+ stateChanged := existingRecord.HasUpdate != updateRecord.HasUpdate+ digestChanged := stringPtrToString(existingRecord.LatestDigest) != stringPtrToString(updateRecord.LatestDigest)+ versionChanged := stringPtrToString(existingRecord.LatestVersion) != stringPtrToString(updateRecord.LatestVersion)++ if stateChanged || (updateRecord.HasUpdate && (digestChanged || versionChanged)) {+ updateRecord.NotificationSent = false+ } else {+ updateRecord.NotificationSent = existingRecord.NotificationSent+ }++ // Save the updated record+ err = db.Save(updateRecord).Error+ require.NoError(t, err)++ // Verify the result+ var updated models.ImageUpdateRecord+ err = db.First(&updated, "id = ?", imageID).Error+ require.NoError(t, err)++ if tt.expectNotifReset {+ assert.False(t, updated.NotificationSent, "notification_sent should be reset because: %s", tt.reason)+ } else {+ assert.True(t, updated.NotificationSent, "notification_sent should be preserved because: %s", tt.reason)+ }+ })+ }+}++// TestGetUnnotifiedUpdates tests retrieving updates that haven't been notified+func TestImageUpdateService_GetUnnotifiedUpdates(t *testing.T) {+ ctx := context.Background()+ db := setupImageUpdateTestDB(t)+ svc := &ImageUpdateService{db: db}++ // Create test records+ records := []models.ImageUpdateRecord{+ {+ ID: "sha256:img1",+ Repository: "nginx",+ Tag: "latest",+ HasUpdate: true,+ NotificationSent: false,+ },+ {+ ID: "sha256:img2",+ Repository: "redis",+ Tag: "alpine",+ HasUpdate: true,+ NotificationSent: true, // Already notified+ },+ {+ ID: "sha256:img3",+ Repository: "postgres",+ Tag: "14",+ HasUpdate: false, // No update+ NotificationSent: false,+ },+ {+ ID: "sha256:img4",+ Repository: "traefik",+ Tag: "latest",+ HasUpdate: true,+ NotificationSent: false,+ },+ }++ for _, rec := range records {+ err := db.Create(&rec).Error+ require.NoError(t, err)+ }++ // Get unnotified updates+ unnotified, err := svc.GetUnnotifiedUpdates(ctx)+ require.NoError(t, err)++ // Should only return img1 and img4 (has_update=true AND notification_sent=false)+ assert.Len(t, unnotified, 2, "should return 2 unnotified updates")+ assert.Contains(t, unnotified, "sha256:img1")+ assert.Contains(t, unnotified, "sha256:img4")+ assert.NotContains(t, unnotified, "sha256:img2", "img2 already notified")+ assert.NotContains(t, unnotified, "sha256:img3", "img3 has no update")+}++// TestMarkUpdatesAsNotified tests marking images as notified+func TestImageUpdateService_MarkUpdatesAsNotified(t *testing.T) {+ ctx := context.Background()+ db := setupImageUpdateTestDB(t)+ svc := &ImageUpdateService{db: db}++ // Create test records+ imageIDs := []string{"sha256:img1", "sha256:img2", "sha256:img3"}+ for _, id := range imageIDs {+ rec := models.ImageUpdateRecord{+ ID: id,+ Repository: "test/repo",+ Tag: "latest",+ HasUpdate: true,+ NotificationSent: false,+ }+ err := db.Create(&rec).Error+ require.NoError(t, err)+ }++ // Mark img1 and img2 as notified+ err := svc.MarkUpdatesAsNotified(ctx, []string{"sha256:img1", "sha256:img2"})+ require.NoError(t, err)++ // Verify img1 and img2 are marked+ var img1 models.ImageUpdateRecord+ err = db.First(&img1, "id = ?", "sha256:img1").Error+ require.NoError(t, err)+ assert.True(t, img1.NotificationSent)++ var img2 models.ImageUpdateRecord+ err = db.First(&img2, "id = ?", "sha256:img2").Error+ require.NoError(t, err)+ assert.True(t, img2.NotificationSent)++ // Verify img3 is still false+ var img3 models.ImageUpdateRecord+ err = db.First(&img3, "id = ?", "sha256:img3").Error+ require.NoError(t, err)+ assert.False(t, img3.NotificationSent)+}++// TestMarkUpdatesAsNotified_EmptyList tests handling of empty ID list+func TestImageUpdateService_MarkUpdatesAsNotified_EmptyList(t *testing.T) {+ ctx := context.Background()+ db := setupImageUpdateTestDB(t)+ svc := &ImageUpdateService{db: db}++ // Should not error on empty list+ err := svc.MarkUpdatesAsNotified(ctx, []string{})+ require.NoError(t, err)++ err = svc.MarkUpdatesAsNotified(ctx, nil)+ require.NoError(t, err)+}diff --git a/backend/internal/services/notification_service.go b/backend/internal/services/notification_service.goindex 54fa8e202..1960a6f7c 100644--- a/backend/internal/services/notification_service.go+++ b/backend/internal/services/notification_service.go@@ -23,6 +23,8 @@ import ("github.com/getarcaneapp/arcane/types/imageupdate")+const logoURLPath = "/api/app-images/logo?full=true"+type NotificationService struct {db *database.DBconfig *config.Config@@ -393,9 +395,11 @@ func (s *NotificationService) sendEmailNotification(ctx context.Context, imageRe}func (s *NotificationService) renderEmailTemplate(imageRef string, updateInfo *imageupdate.Response) (string, string, error) {+ logoURL := s.config.AppUrl + logoURLPathdata := map[string]interface{}{- "LogoURL": "https://raw.githubusercontent.com/getarcaneapp/arcane/main/backend/resources/images/logo-full.svg",+ "LogoURL": logoURL,"AppURL": s.config.AppUrl,+ "Environment": "Local Docker","ImageRef": imageRef,"HasUpdate": updateInfo.HasUpdate,"UpdateType": updateInfo.UpdateType,@@ -595,9 +599,11 @@ func (s *NotificationService) sendEmailContainerUpdateNotification(ctx context.C}func (s *NotificationService) renderContainerUpdateEmailTemplate(containerName, imageRef, oldDigest, newDigest string) (string, string, error) {+ logoURL := s.config.AppUrl + logoURLPathdata := map[string]interface{}{- "LogoURL": "https://raw.githubusercontent.com/getarcaneapp/arcane/main/backend/resources/images/logo-full.svg",+ "LogoURL": logoURL,"AppURL": s.config.AppUrl,+ "Environment": "Local Docker","ContainerName": containerName,"ImageRef": imageRef,"OldDigest": truncateDigest(oldDigest),@@ -660,6 +666,36 @@ func (s *NotificationService) TestNotification(ctx context.Context, provider modif testType == "image-update" {return s.sendEmailNotification(ctx, "nginx:latest", testUpdate, setting.Config)}+ if testType == "batch-image-update" {+ // Create test batch updates with multiple images+ testUpdates := map[string]*imageupdate.Response{+ "nginx:latest": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:abc123def456789012345678901234567890",+ LatestDigest: "sha256:xyz789ghi012345678901234567890123456",+ CheckTime: time.Now(),+ ResponseTimeMs: 100,+ },+ "postgres:16-alpine": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:def456abc123789012345678901234567890",+ LatestDigest: "sha256:ghi789xyz012345678901234567890123456",+ CheckTime: time.Now(),+ ResponseTimeMs: 120,+ },+ "redis:7.2-alpine": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:123456789abc012345678901234567890def",+ LatestDigest: "sha256:456789012def345678901234567890123abc",+ CheckTime: time.Now(),+ ResponseTimeMs: 95,+ },+ }+ return s.sendBatchEmailNotification(ctx, testUpdates, setting.Config)+ }return s.sendTestEmail(ctx, setting.Config)default:return fmt.Errorf("unknown provider: %s", provider)@@ -720,8 +756,9 @@ func (s *NotificationService) sendTestEmail(ctx context.Context, config models.J}func (s *NotificationService) renderTestEmailTemplate() (string, string, error) {+ logoURL := s.config.AppUrl + logoURLPathdata := map[string]interface{}{- "LogoURL": "https://raw.githubusercontent.com/getarcaneapp/arcane/main/backend/resources/images/logo-full.svg",+ "LogoURL": logoURL,"AppURL": s.config.AppUrl,}@@ -989,11 +1026,19 @@ func (s *NotificationService) sendBatchEmailNotification(ctx context.Context, up}func (s *NotificationService) renderBatchEmailTemplate(updates map[string]*imageupdate.Response) (string, string, error) {+ // Build list of image names+ imageList := make([]string, 0, len(updates))+ for imageRef := range updates {+ imageList = append(imageList, imageRef)+ }++ logoURL := s.config.AppUrl + logoURLPathdata := map[string]interface{}{- "LogoURL": "https://raw.githubusercontent.com/getarcaneapp/arcane/main/backend/resources/images/logo-full.svg",+ "LogoURL": logoURL,"AppURL": s.config.AppUrl,"UpdateCount": len(updates),"CheckTime": time.Now().Format(time.RFC1123),+ "ImageList": imageList,}htmlContent, err := resources.FS.ReadFile("email-templates/batch-image-updates_html.tmpl")diff --git a/backend/resources/email-templates/batch-image-updates_html.tmpl b/backend/resources/email-templates/batch-image-updates_html.tmplindex 2fddc10b8..9443c22f8 100644--- a/backend/resources/email-templates/batch-image-updates_html.tmpl+++ b/backend/resources/email-templates/batch-image-updates_html.tmpl@@ -2,5 +2,5 @@<table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="text-align:center;margin-bottom:32px"><tbody><tr><td><img alt="Arcane" height="auto" src="{{.LogoURL}}" style="display:inline-block;outline:none;border:none;text-decoration:none;width:180px;height:auto" width="180"/></td></tr></tbody></table><div style="background-color:rgba(30, 41, 59, 0.6);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border:1px solid rgba(148, 163, 184, 0.1);padding:32px;border-radius:16px;box-shadow:0 8px 32px 0 rgba(0, 0, 0, 0.37)"><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation"><tbody style="width:100%"><tr style="width:100%"><td data-id="__react-email-column"><h1 style="font-size:24px;font-weight:bold;margin:0;color:#f1f5f9">Image Updates Available</h1></td><td align="right" data-id="__react-email-column"></td></tr></tbody></table><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="margin-top:24px"><tbody><tr><td><p style="font-size:16px;line-height:24px;color:#cbd5e1;margin:0 0 16px 0;margin-top:0;margin-right:0;margin-bottom:16px;margin-left:0">{{.UpdateCount}} container images have updates available.</p></td></tr></tbody></table><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="margin-top:20px;background-color:rgba(15, 23, 42, 0.5);border:1px solid rgba(148, 163, 184, 0.1);padding:20px;border-radius:12px"><tbody><tr><td><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="margin-bottom:0"><tbody style="width:100%"><tr style="width:100%"><td data-id="__react-email-column" style="width:160px;vertical-align:top;padding-right:12px"><p style="font-size:14px;line-height:24px;font-weight:600;color:#94a3b8;margin:8px 0;margin-top:8px;margin-right:0;margin-bottom:8px;margin-left:0">Updates Available:</p></td><td data-id="__react-email-column"><p style="font-size:24px;line-height:24px;font-weight:700;color:#34d399;margin:8px 0;margin-top:8px;margin-right:0;margin-bottom:8px;margin-left:0">{{.UpdateCount}}</p></td></tr></tbody></table><hr style="width:100%;border:none;border-top:1px solid #eaeaea;border-color:rgba(148, 163, 184, 0.2);margin:4px 0"/><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="margin-bottom:0"><tbody style="width:100%"><tr style="width:100%"><td data-id="__react-email-column" style="width:160px;vertical-align:top;padding-right:12px"><p style="font-size:14px;line-height:24px;font-weight:600;color:#94a3b8;margin:8px 0;margin-top:8px;margin-right:0;margin-bottom:8px;margin-left:0">Checked At:</p></td><td data-id="__react-email-column">-<p style="font-size:14px;line-height:24px;color:#e2e8f0;margin:8px 0;word-break:break-word;margin-top:8px;margin-right:0;margin-bottom:8px;margin-left:0">{{.CheckTime}}</p></td></tr></tbody></table></td></tr></tbody></table><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="margin-top:24px"><tbody><tr><td><p style="font-size:13px;line-height:20px;color:#94a3b8;margin:0;margin-top:0;margin-bottom:0;margin-left:0;margin-right:0">Log in to Arcane to view details and update your containers.</p></td></tr></tbody></table></div><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="text-align:center;margin-top:32px;padding-top:24px"><tbody><tr><td><p style="font-size:14px;line-height:20px;margin:0;margin-top:0;margin-bottom:0;margin-left:0;margin-right:0"><a href="{{.AppURL}}" style="color:#a78bfa;text-decoration-line:none;text-decoration:none;font-weight:500" target="_blank">-Open Arcane Dashboard →</a></p></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table><!--/$--></body></html>{{end}}\ No newline at end of file+<p style="font-size:14px;line-height:24px;color:#e2e8f0;margin:8px 0;word-break:break-word;margin-top:8px;margin-right:0;margin-bottom:8px;margin-left:0">{{.CheckTime}}</p></td></tr></tbody></table></td></tr></tbody></table><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="margin-top:24px;background-color:rgba(15, 23, 42, 0.3);border:1px solid rgba(148, 163, 184, 0.1);padding:16px;border-radius:8px"><tbody><tr><td><p style="font-size:14px;line-height:24px;font-weight:600;color:#94a3b8;margin:0 0 12px 0;margin-top:0;margin-right:0;margin-bottom:12px;margin-left:0">Images with Updates:</p>{{range .ImageList}}<p style="font-size:13px;line-height:20px;color:#cbd5e1;margin:4px 0;font-family:monospace">• {{.}}</p>{{end}}</td></tr></tbody></table><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="margin-top:24px"><tbody><tr><td>+<p style="font-size:13px;line-height:20px;color:#94a3b8;margin:0;margin-top:0;margin-bottom:0;margin-left:0;margin-right:0">Log in to Arcane to view details and update your containers.</p></td></tr></tbody></table></div><table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="text-align:center;margin-top:32px;padding-top:24px"><tbody><tr><td><p style="font-size:14px;line-height:20px;margin:0;margin-top:0;margin-bottom:0;margin-left:0;margin-right:0"><a href="{{.AppURL}}" style="color:#a78bfa;text-decoration-line:none;text-decoration:none;font-weight:500" target="_blank">Open Arcane Dashboard →</a></p></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table><!--/$--></body></html>{{end}}\ No newline at end of filediff --git a/backend/resources/email-templates/batch-image-updates_text.tmpl b/backend/resources/email-templates/batch-image-updates_text.tmplindex d654ad657..7b1caafa7 100644--- a/backend/resources/email-templates/batch-image-updates_text.tmpl+++ b/backend/resources/email-templates/batch-image-updates_text.tmpl@@ -12,6 +12,11 @@ Checked At:{{.CheckTime}}+Images with Updates:++{{range .ImageList}}• {{.}}+{{end}}+Log in to Arcane to view details and update your containers.Open Arcane Dashboard → {{.AppURL}}{{end}}\ No newline at end of filediff --git a/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.down.sql b/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.down.sqlnew file mode 100644index 000000000..42144d243--- /dev/null+++ b/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.down.sql@@ -0,0 +1,4 @@+-- Remove notification_sent column+-- PostgreSQL automatically preserves existing indexes on other columns+ALTER TABLE IF EXISTS image_updates+ DROP COLUMN notification_sent;diff --git a/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.up.sql b/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.up.sqlnew file mode 100644index 000000000..8bde48fae--- /dev/null+++ b/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.up.sql@@ -0,0 +1,4 @@+-- Add notification_sent column to track if updates have been sent+-- Existing indexes on repository and tag are preserved automatically+ALTER TABLE IF EXISTS image_updates+ ADD COLUMN notification_sent BOOLEAN DEFAULT false;diff --git a/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.down.sql b/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.down.sqlnew file mode 100644index 000000000..aabf89385--- /dev/null+++ b/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.down.sql@@ -0,0 +1,16 @@+-- SQLite doesn't support DROP COLUMN directly, so we need to recreate the table+-- Create backup without notification_sent column+CREATE TABLE image_updates_backup AS SELECT+ id, repository, tag, has_update, update_type, current_version,+ latest_version, current_digest, latest_digest, check_time,+ response_time_ms, last_error, auth_method, auth_username,+ auth_registry, used_credential, created_at, updated_at+FROM image_updates;++DROP TABLE image_updates;++ALTER TABLE image_updates_backup RENAME TO image_updates;++-- Recreate indexes that were lost during table recreation+CREATE INDEX IF NOT EXISTS idx_image_update_repository ON image_updates(repository);+CREATE INDEX IF NOT EXISTS idx_image_update_tag ON image_updates(tag);diff --git a/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.up.sql b/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.up.sqlnew file mode 100644index 000000000..3c304e99e--- /dev/null+++ b/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.up.sql@@ -0,0 +1,3 @@+-- Add notification_sent column to track if updates have been sent+-- Existing indexes on repository and tag are preserved automatically+ALTER TABLE image_updates ADD COLUMN notification_sent INTEGER DEFAULT 0;diff --git a/cli/pkg/config/cmd.go b/cli/pkg/config/cmd.goindex 5e75954e7..51d177029 100644--- a/cli/pkg/config/cmd.go+++ b/cli/pkg/config/cmd.go@@ -6,8 +6,8 @@ import ("net/http""time"- "github.com/spf13/cobra""github.com/getarcaneapp/arcane/cli/internal/config"+ "github.com/spf13/cobra")var (diff --git a/email-templates/build.ts b/email-templates/build.tsindex cee905a01..5d0f18a21 100644--- a/email-templates/build.ts+++ b/email-templates/build.ts@@ -52,7 +52,23 @@ async function buildTemplateFile(Component: any, templateName: string, isPlainTe});// Normalize quotes- const normalized = rendered.replace(/"/g, '"');+ let normalized = rendered.replace(/"/g, '"');++ // Post-process: Replace special placeholders with Go template syntax+ // This allows us to inject Go template loops that can't be rendered by React+ if (isPlainText) {+ // For plain text, use simple line-by-line rendering+ normalized = normalized.replace(+ /IMAGELIST_PLACEHOLDER/g,+ '{{range .ImageList}}• {{.}}\n{{end}}'+ );+ } else {+ // For HTML, wrap each item in a paragraph tag with proper styling+ normalized = normalized.replace(+ /<p[^>]*>IMAGELIST_PLACEHOLDER<\/p>/g,+ '{{range .ImageList}}<p style="font-size:13px;line-height:20px;color:#cbd5e1;margin:4px 0;font-family:monospace">• {{.}}</p>{{end}}'+ );+ }// Enforce line length: prefer tag boundaries, never spacesconst maxLen = isPlainText ? 78 : 998; // RFC-safediff --git a/email-templates/emails/batch-image-updates.tsx b/email-templates/emails/batch-image-updates.tsxindex d1a668865..bca2dcfad 100644--- a/email-templates/emails/batch-image-updates.tsx+++ b/email-templates/emails/batch-image-updates.tsx@@ -8,18 +8,32 @@ interface BatchImageUpdatesEmailProps {appURL: string;updateCount: number;checkTime: string;+ imageList?: string[];}-export const BatchImageUpdatesEmail = ({ logoURL, appURL, updateCount, checkTime }: BatchImageUpdatesEmailProps) => {+export const BatchImageUpdatesEmail = ({+ logoURL,+ appURL,+ updateCount,+ checkTime,+ imageList = [],+}: BatchImageUpdatesEmailProps) => {+ // Handle both array (preview) and string (template placeholder)+ const images = Array.isArray(imageList) ? imageList : [];++ // For template generation, always include image list section with placeholder text+ // This will be replaced with Go template range syntax+ const showImageList = images.length > 0 || typeof imageList === 'string';+return (<BaseTemplate logoURL={logoURL} appURL={appURL}><CardHeader title="Image Updates Available" /><Section style={{ marginTop: '24px' }}><Text style={mainTextStyle}>- {updateCount === 1- ? `1 container image has an update available.`- : `${updateCount} container images have updates available.`}+ {updateCount === 1 ?+ `1 container image has an update available.`+ : `${updateCount} container images have updates available.`}</Text></Section>@@ -45,6 +59,19 @@ export const BatchImageUpdatesEmail = ({ logoURL, appURL, updateCount, checkTime</Row></Section>+ {showImageList && (+ <Section style={imageListSectionStyle}>+ <Text style={imageListHeaderStyle}>Images with Updates:</Text>+ {images.length > 0 ?+ images.map((image, index) => (+ <Text key={index} style={imageItemStyle}>+ • {image}+ </Text>+ ))+ : <Text style={imageItemStyle}>IMAGELIST_PLACEHOLDER</Text>}+ </Section>+ )}+<Section style={{ marginTop: '24px' }}><Text style={footerStyle}>Log in to Arcane to view details and update your containers.</Text></Section>@@ -112,14 +139,47 @@ const footerStyle = {margin: '0',};+const imageListSectionStyle = {+ marginTop: '24px',+ backgroundColor: 'rgba(15, 23, 42, 0.3)',+ border: '1px solid rgba(148, 163, 184, 0.1)',+ padding: '16px',+ borderRadius: '8px',+};++const imageListHeaderStyle = {+ fontSize: '14px',+ fontWeight: '600' as const,+ color: '#94a3b8',+ margin: '0 0 12px 0',+};++const imageItemStyle = {+ fontSize: '13px',+ lineHeight: '20px',+ color: '#cbd5e1',+ margin: '4px 0',+ fontFamily: 'monospace',+};+BatchImageUpdatesEmail.TemplateProps = {...sharedTemplateProps,updateCount: '{{.UpdateCount}}',checkTime: '{{.CheckTime}}',+ imageList: 'TEMPLATE_PLACEHOLDER', // This triggers the image list section to render};BatchImageUpdatesEmail.PreviewProps = {...sharedPreviewProps,updateCount: 7,checkTime: '2025-10-27 15:30:00 UTC',+ imageList: [+ 'ghcr.io/linuxserver/plex:latest',+ 'postgres:16-alpine',+ 'redis:7.2-alpine',+ 'nginx:latest',+ 'traefik:v3.0',+ 'portainer/portainer-ce:latest',+ 'grafana/grafana:latest',+ ],};diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 6be8543e6..ced9b033b 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -1350,6 +1350,7 @@"notifications_email_tls_mode_description": "StartTLS (default) upgrades from plain connection. SSL/TLS uses encryption from start. None uses no encryption.","notifications_email_test_simple": "Simple Test Email","notifications_email_test_image_update": "Image Update Email",+ "notifications_email_test_batch_image_update": "Batch Image Updates Email","notifications_apprise_title": "Apprise Integration","notifications_apprise_description": "Configure Apprise API for unified notifications across multiple services","notifications_apprise_enabled_label": "Enable Apprise",diff --git a/frontend/src/routes/(app)/settings/notifications/+page.svelte b/frontend/src/routes/(app)/settings/notifications/+page.svelteindex ad3afb547..56d3f4022 100644--- a/frontend/src/routes/(app)/settings/notifications/+page.svelte+++ b/frontend/src/routes/(app)/settings/notifications/+page.svelte@@ -697,23 +697,27 @@<DropdownMenu.Trigger><Button variant="outline" disabled={isReadOnly || isTesting}>{#if isTesting}- <Spinner class="mr-2 h-4 w-4" />+ <Spinner class="size-4" />{:else}- <SendEmailIcon class="mr-2 h-4 w-4" />+ <SendEmailIcon class="size-4" />{/if}{m.notifications_email_test_button()}- <ArrowDownIcon class="ml-2 h-4 w-4" />+ <ArrowDownIcon class="ml-2 size-4" /></Button></DropdownMenu.Trigger><DropdownMenu.Content align="start"><DropdownMenu.Item onclick={() => testNotification('email', 'simple')}>- <SendEmailIcon class="mr-2 h-4 w-4" />+ <SendEmailIcon class="size-4" />{m.notifications_email_test_simple()}</DropdownMenu.Item><DropdownMenu.Item onclick={() => testNotification('email', 'image-update')}>- <SendEmailIcon class="mr-2 h-4 w-4" />+ <SendEmailIcon class="size-4" />{m.notifications_email_test_image_update()}</DropdownMenu.Item>+ <DropdownMenu.Item onclick={() => testNotification('email', 'batch-image-update')}>+ <SendEmailIcon class="size-4" />+ {m.notifications_email_test_batch_image_update()}+ </DropdownMenu.Item></DropdownMenu.Content></DropdownMenu.Root></div>diff --git a/types/auth/auth.go b/types/auth/auth.goindex aa89a62f5..e6de056a3 100644--- a/types/auth/auth.go+++ b/types/auth/auth.go@@ -25,9 +25,9 @@ type PasswordChange struct {// LoginResponse represents the successful login response data.type LoginResponse struct {- Token string `json:"token" doc:"JWT access token"`- RefreshToken string `json:"refreshToken" doc:"Refresh token for obtaining new access tokens"`- ExpiresAt time.Time `json:"expiresAt" doc:"Expiration time of the access token"`+ Token string `json:"token" doc:"JWT access token"`+ RefreshToken string `json:"refreshToken" doc:"Refresh token for obtaining new access tokens"`+ ExpiresAt time.Time `json:"expiresAt" doc:"Expiration time of the access token"`User user.User `json:"user" doc:"Authenticated user information"`}