diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2025-01-05 15:35:51 -0800 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2025-01-05 15:36:09 -0800 |
commit | 6109b9ff733d6bfb9fff4d107036f0b6214662d4 (patch) | |
tree | 77496306cdd15f894117975d2fa4c76bf4a52067 /adapters | |
parent | 2984a715b830410b6d6ce2a8aaa1fc8a2388ee99 (diff) | |
download | phoneof-6109b9ff733d6bfb9fff4d107036f0b6214662d4.tar.gz phoneof-6109b9ff733d6bfb9fff4d107036f0b6214662d4.zip |
dynamically specify topic in text
Diffstat (limited to 'adapters')
-rw-r--r-- | adapters/messaging/ntfy.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/adapters/messaging/ntfy.go b/adapters/messaging/ntfy.go index 837c01b..9c68f3a 100644 --- a/adapters/messaging/ntfy.go +++ b/adapters/messaging/ntfy.go @@ -17,7 +17,15 @@ func SendNtfy(topic string, ntfyEndpoint string) Continuation { log.Printf("fren name for message %v is not ntfy so we wont send it there", message) return success(message) } - encodedMsg := fmt.Sprintf(`{"message": "%s", "topic": "%s"}`, utils.Quote(message.Message), utils.Quote(topic)) + content := strings.SplitN(message.Message, " ", 2) + if len(content) < 2 { + log.Printf("no topic %s", content) + return failure(message) + } + + topic := content[0] + msg := content[1] + encodedMsg := fmt.Sprintf(`{"message": "%s", "topic": "%s"}`, utils.Quote(msg), utils.Quote(topic)) url := ntfyEndpoint payload := strings.NewReader(encodedMsg) |