From 5dab7c9f2bcb5405373c150f09565d2de37ede2f Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 2 Oct 2023 16:05:11 +0200 Subject: [PATCH] Improve update notifications --- updates/notify.go | 34 ++++++++++++++++++++++++++-------- updates/upgrader.go | 4 ++-- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/updates/notify.go b/updates/notify.go index 5445cb2c..3f9a22b6 100644 --- a/updates/notify.go +++ b/updates/notify.go @@ -2,6 +2,7 @@ package updates import ( "fmt" + "strings" "sync/atomic" "time" @@ -58,14 +59,21 @@ func notifyUpdateSuccess(forced bool) { }) case updateSuccessPending: + msg := fmt.Sprintf( + `%d updates are available for download: + +- %s + +Press "Download Now" or check for updates later to download and automatically apply all pending updates. You will be notified of important updates that need restarting.`, + len(updateState.PendingDownload), + strings.Join(updateState.PendingDownload, "\n- "), + ) + notifications.Notify(¬ifications.Notification{ EventID: updateSuccess, Type: notifications.Info, Title: fmt.Sprintf("%d Updates Available", len(updateState.PendingDownload)), - Message: fmt.Sprintf( - `%d updates are available for download. Press "Download Now" or check for updates later to download and automatically apply all pending updates. You will be notified of important updates that need restarting.`, - len(updateState.PendingDownload), - ), + Message: msg, AvailableActions: []*notifications.Action{ { ID: "ack", @@ -84,14 +92,24 @@ func notifyUpdateSuccess(forced bool) { }) case updateSuccessDownloaded: + msg := fmt.Sprintf( + `%d updates were downloaded and applied: + +- %s`, + len(updateState.LastDownload), + strings.Join(updateState.LastDownload, "\n- "), + ) + if enableSoftwareUpdates() { + msg += "\n\nYou will be notified of important updates that need restarting." + } else { + msg += "\n\nAutomatic software updates are disabled, and you will be notified when a new software update is ready to be downloaded and applied." + } + notifications.Notify(¬ifications.Notification{ EventID: updateSuccess, Type: notifications.Info, Title: fmt.Sprintf("%d Updates Applied", len(updateState.LastDownload)), - Message: fmt.Sprintf( - `%d updates were downloaded and applied. You will be notified of important updates that need restarting.`, - len(updateState.LastDownload), - ), + Message: msg, Expires: time.Now().Add(1 * time.Minute).Unix(), AvailableActions: []*notifications.Action{ { diff --git a/updates/upgrader.go b/updates/upgrader.go index 6e946762..d350b760 100644 --- a/updates/upgrader.go +++ b/updates/upgrader.go @@ -113,12 +113,12 @@ func upgradeCoreNotify() error { EventID: "updates:core-update-available", Type: notifications.Info, Title: fmt.Sprintf( - "Portmaster Update v%s", + "Portmaster Update v%s Is Ready!", pmCoreUpdate.Version(), ), Category: "Core", Message: fmt.Sprintf( - `A new Portmaster version is available! Restart the Portmaster to upgrade to %s.`, + `A new Portmaster version is ready to go! Restart the Portmaster to upgrade to %s.`, pmCoreUpdate.Version(), ), ShowOnSystem: true,