From 6109b9ff733d6bfb9fff4d107036f0b6214662d4 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 5 Jan 2025 15:35:51 -0800 Subject: dynamically specify topic in text --- adapters/messaging/ntfy.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'adapters/messaging') 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) -- cgit v1.2.3-70-g09d2