ntfy pub: use default-user and default-password from client.yml

fixes #431
This commit is contained in:
Hunter Kehoe 2022-10-09 08:34:23 -06:00
parent dfec18be3d
commit 85eb9160d8
2 changed files with 7 additions and 1 deletions

View file

@ -5,10 +5,14 @@
#
# default-host: https://ntfy.sh
# Defaults below will be used when a topic does not have its own settings
# Default username and password will be used with "ntfy publish" if no credentials are provided on command line
# Default username and password will be used with "ntfy subscribe" if no credentials are provided in subscription below
# For an empty password, use empty double-quotes ("")
#
# default-user:
# default-password:
# Default command will execute after "ntfy subscribe" receives a message if no command is provided in subscription below
# default-command:
# Subscriptions to topics and their actions. This option is primarily used by the systemd service,

View file

@ -160,6 +160,8 @@ func execPublish(c *cli.Context) error {
fmt.Fprintf(c.App.ErrWriter, "\r%s\r", strings.Repeat(" ", 20))
}
options = append(options, client.WithBasicAuth(user, pass))
} else if conf.DefaultUser != "" && conf.DefaultPassword != nil {
options = append(options, client.WithBasicAuth(conf.DefaultUser, *conf.DefaultPassword))
}
if pid > 0 {
newMessage, err := waitForProcess(pid)