mirror of https://github.com/jlelse/GoBlog
Improve code style
This commit is contained in:
parent
40d4aa9de0
commit
eb87b9e3a1
11
ntfy.go
11
ntfy.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/carlmjohnson/requests"
|
"github.com/carlmjohnson/requests"
|
||||||
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ntfy *configNtfy) enabled() bool {
|
func (ntfy *configNtfy) enabled() bool {
|
||||||
|
@ -19,14 +20,8 @@ func (a *goBlog) sendNtfy(cfg *configNtfy, msg string) error {
|
||||||
if !cfg.enabled() {
|
if !cfg.enabled() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
topic := cfg.Topic
|
topic := strings.TrimPrefix(cfg.Topic, "ntfy.sh/")
|
||||||
if strings.HasPrefix(topic, "ntfy.sh/") { // Old configuration example
|
server, _ := lo.Coalesce(cfg.Server, "https://ntfy.sh")
|
||||||
topic = strings.TrimPrefix(topic, "ntfy.sh/")
|
|
||||||
}
|
|
||||||
server := "https://ntfy.sh"
|
|
||||||
if cfg.Server != "" {
|
|
||||||
server = cfg.Server
|
|
||||||
}
|
|
||||||
builder := requests.
|
builder := requests.
|
||||||
URL(server + "/" + topic).
|
URL(server + "/" + topic).
|
||||||
Client(a.httpClient).
|
Client(a.httpClient).
|
||||||
|
|
Loading…
Reference in New Issue