ntfy

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ntfy sends reminders as push notifications through ntfy (https://ntfy.sh or a self-hosted server). It is a notify-only channel: the notification opens the subscription in the web when tapped.

Index

Constants

View Source
const DefaultServer = "https://ntfy.sh"

DefaultServer is the public ntfy service.

View Source
const Name = "ntfy"

Name is the channel name in channel_links.

Variables

This section is empty.

Functions

func Publish

func Publish(ctx context.Context, client *http.Client, cfg Config, n Notification) error

Publish posts a notification to the server.

func Topic

func Topic(raw string) (string, error)

Topic validates a topic a member typed. A pasted address such as https://ntfy.sh/my-topic is accepted too: its last part is the topic.

Types

type Channel

type Channel struct {
	notify.OneWay
	// Config returns the current server settings, read for every message.
	Config func(ctx context.Context) Config
	// Client must come from a netguard.Guard: the server address is typed
	// by a person.
	Client *http.Client
	// PublicURL is the instance's public address ("" if unknown).
	PublicURL string
}

Channel is the ntfy channel. Its chat id is the member's topic.

func (*Channel) Name

func (c *Channel) Name() string

func (*Channel) Send

func (c *Channel) Send(ctx context.Context, topic string, m actions.Message) (string, error)

Send publishes the message to a topic.

type Config

type Config struct {
	Server string `json:"server"`
	// Token is an ntfy access token (tk_…) for servers that need one to
	// publish. Optional.
	Token string `json:"token,omitempty"`
}

Config is the ntfy server every member's topic lives on.

type Notification

type Notification struct {
	Topic    string       `json:"topic"`
	Title    string       `json:"title,omitempty"`
	Message  string       `json:"message,omitempty"`
	Tags     []string     `json:"tags,omitempty"`
	Priority int          `json:"priority,omitempty"`
	Click    string       `json:"click,omitempty"`
	Actions  []viewAction `json:"actions,omitempty"`
}

Notification is the body of ntfy's JSON publish API.

func FromMessage

func FromMessage(topic string, m actions.Message, link string) Notification

FromMessage turns a message into a notification for a topic. link ("" for none) is opened when the notification is tapped and by its one button.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL