mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00

* implement ntfy notification * fix notification fields order * fix schema for ntfy --------- Co-authored-by: yusing <yusing@6uo.me>
26 lines
484 B
Go
26 lines
484 B
Go
package notif
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
)
|
|
|
|
func formatMarkdown(extras LogFields) string {
|
|
msg := bytes.NewBufferString("")
|
|
for _, field := range extras {
|
|
msg.WriteString("#### ")
|
|
msg.WriteString(field.Name)
|
|
msg.WriteRune('\n')
|
|
msg.WriteString(field.Value)
|
|
msg.WriteRune('\n')
|
|
}
|
|
return msg.String()
|
|
}
|
|
|
|
func formatDiscord(extras LogFields) (string, error) {
|
|
fields, err := json.Marshal(extras)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return string(fields), nil
|
|
}
|