dynamically specify topic in text
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
2984a715b8
commit
6109b9ff73
@ -10,4 +10,4 @@ RUN go build -o /app/phoneof
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["/app/phoneof", "--server", "--migrate", "--port", "8080", "--template-path", "/app/templates", "--database-path", "/app/db/phoneof.db", "--static-path", "/app/static", "--scheduler", "--httpsms-endpoint", "https://httpsms.internal.simponic.xyz", "--ntfy-endpoint", "https://ntfy.simponic.hatecomputers.club", "--ntfy-topic", "sms"]
|
||||
CMD ["/app/phoneof", "--server", "--migrate", "--port", "8080", "--template-path", "/app/templates", "--database-path", "/app/db/phoneof.db", "--static-path", "/app/static", "--scheduler", "--httpsms-endpoint", "https://httpsms.internal.simponic.xyz", "--ntfy-endpoint", "https://ntfy.simponic.hatecomputers.club"]
|
||||
|
@ -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)
|
||||
|
@ -18,7 +18,6 @@ type Arguments struct {
|
||||
HttpSmsEndpoint string
|
||||
|
||||
NtfyEndpoint string
|
||||
NtfyTopic string
|
||||
|
||||
Port int
|
||||
Server bool
|
||||
@ -63,8 +62,7 @@ func GetArgs() (*Arguments, error) {
|
||||
|
||||
httpSmsEndpoint := flag.String("httpsms-endpoint", "https://httpsms.com", "HTTPSMS endpoint")
|
||||
|
||||
ntfyTopic := flag.String("ntfy-topic", "sms", "NTFY endpoint")
|
||||
ntfyEndpoint := flag.String("ntfy-endpoint", "https://ntfy.simponic.hatecomputers.club", "HTTPSMS endpoint")
|
||||
ntfyEndpoint := flag.String("ntfy-endpoint", "https://ntfy.simponic.hatecomputers.club", "NTFY endpoint")
|
||||
|
||||
scheduler := flag.Bool("scheduler", false, "Run scheduled jobs via cron")
|
||||
migrate := flag.Bool("migrate", false, "Run the migrations")
|
||||
@ -83,7 +81,6 @@ func GetArgs() (*Arguments, error) {
|
||||
Migrate: *migrate,
|
||||
Scheduler: *scheduler,
|
||||
HttpSmsEndpoint: *httpSmsEndpoint,
|
||||
NtfyTopic: *ntfyTopic,
|
||||
NtfyEndpoint: *ntfyEndpoint,
|
||||
}
|
||||
err := validateArgs(args)
|
||||
|
Loading…
Reference in New Issue
Block a user