Migrate notifier from portmaster-ui to cmds/notifier, remove some duplicated code, move assets to assets/data and add a small go package in assets to allow embedding icons

This commit is contained in:
Patrick Pacher
2024-03-20 11:10:32 +01:00
parent 4b77945517
commit ac23ce32a1
392 changed files with 1879 additions and 4 deletions

View File

@@ -0,0 +1,36 @@
package main
import (
"fmt"
pbnotify "github.com/safing/portbase/notifications"
)
// Notification represents a notification that is to be delivered to the user.
type Notification struct {
pbnotify.Notification
// systemID holds the ID returned by the dbus interface on Linux or by WinToast library on Windows.
systemID NotificationID
}
// IsSupported returns whether the action is supported on this system.
func IsSupportedAction(a pbnotify.Action) bool {
switch a.Type {
case pbnotify.ActionTypeNone:
return true
default:
return false
}
}
// SelectAction sends an action back to the portmaster.
func (n *Notification) SelectAction(action string) {
new := &pbnotify.Notification{
EventID: n.EventID,
SelectedActionID: action,
}
// FIXME: check response
apiClient.Update(fmt.Sprintf("%s%s", dbNotifBasePath, new.EventID), new, nil)
}