notification icons

This commit is contained in:
Hunter Kehoe 2022-07-16 13:31:03 -06:00
parent cbcd0e3f0d
commit d519fd999b
14 changed files with 197 additions and 13 deletions

View file

@ -47,6 +47,7 @@ type Message struct { // TODO combine with server.message
Priority int
Tags []string
Click string
Icon *Icon
Attachment *Attachment
// Additional fields
@ -65,6 +66,13 @@ type Attachment struct {
Owner string `json:"-"` // IP address of uploader, used for rate limiting
}
// Icon represents a message icon
type Icon struct {
Url string `json:"url"`
Type string `json:"type,omitempty"`
Size int64 `json:"size,omitempty"`
}
type subscription struct {
ID string
topicURL string

View file

@ -56,6 +56,11 @@ func WithClick(url string) PublishOption {
return WithHeader("X-Click", url)
}
// WithIcon makes the notification use the given URL as its icon
func WithIcon(icon string) PublishOption {
return WithHeader("X-Icon", icon)
}
// WithActions adds custom user actions to the notification. The value can be either a JSON array or the
// simple format definition. See https://ntfy.sh/docs/publish/#action-buttons for details.
func WithActions(value string) PublishOption {