summaryrefslogtreecommitdiff
path: root/api/api.go
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2025-01-05 15:16:26 -0800
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2025-01-05 15:29:23 -0800
commit2984a715b830410b6d6ce2a8aaa1fc8a2388ee99 (patch)
tree09dc00606931885e8b345791cd1a301335dd494c /api/api.go
parentd86746bb0ddcb7dcfc6225f9fe37f6034c958913 (diff)
downloadphoneof-2984a715b830410b6d6ce2a8aaa1fc8a2388ee99.tar.gz
phoneof-2984a715b830410b6d6ce2a8aaa1fc8a2388ee99.zip
add ntfy integration
Diffstat (limited to 'api/api.go')
-rw-r--r--api/api.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/api/api.go b/api/api.go
index 07db731..cb5101b 100644
--- a/api/api.go
+++ b/api/api.go
@@ -99,19 +99,15 @@ func MakeMux(argv *args.Arguments, dbConn *sql.DB) *http.ServeMux {
LogRequestContinuation(requestContext, r, w)(chat.ValidateFren, FailurePassingContinuation)(chat.FetchMessagesContinuation, FailurePassingContinuation)(template.TemplateContinuation("messages.html", false), FailurePassingContinuation)(LogExecutionTimeContinuation, LogExecutionTimeContinuation)(IdContinuation, IdContinuation)
})
- messageHandler := messaging.HttpSmsMessagingAdapter{
- ApiToken: os.Getenv("HTTPSMS_API_TOKEN"),
- FromPhoneNumber: os.Getenv("FROM_PHONE_NUMBER"),
- ToPhoneNumber: os.Getenv("TO_PHONE_NUMBER"),
- Endpoint: argv.HttpSmsEndpoint,
- }
- sendMessageContinuation := chat.SendMessageContinuation(&messageHandler)
+ httpsms := messaging.HttpSmsContinuation(os.Getenv("HTTPSMS_API_TOKEN"), os.Getenv("FROM_PHONE_NUMBER"), os.Getenv("TO_PHONE_NUMBER"), argv.HttpSmsEndpoint)
+ ntfy := messaging.SendNtfy(argv.NtfyTopic, argv.NtfyEndpoint)
+ sendMessageContinuation := chat.SendMessageContinuation(messaging.Compose(ntfy, httpsms))
mux.HandleFunc("POST /chat", func(w http.ResponseWriter, r *http.Request) {
requestContext := makeRequestContext()
LogRequestContinuation(requestContext, r, w)(chat.ValidateFren, FailurePassingContinuation)(sendMessageContinuation, FailurePassingContinuation)(template.TemplateContinuation("chat.html", true), FailurePassingContinuation)(LogExecutionTimeContinuation, LogExecutionTimeContinuation)(IdContinuation, IdContinuation)
})
- smsEventProcessor := chat.ChatEventProcessorContinuation(os.Getenv("HTTPSMS_SIGNING_KEY"))
+ smsEventProcessor := chat.ChatEventProcessorContinuation(os.Getenv("TO_PHONE_NUMBER"), os.Getenv("HTTPSMS_SIGNING_KEY"), ntfy)
mux.HandleFunc("POST /chat/event", func(w http.ResponseWriter, r *http.Request) {
requestContext := makeRequestContext()
LogRequestContinuation(requestContext, r, w)(smsEventProcessor, FailurePassingContinuation)(LogExecutionTimeContinuation, LogExecutionTimeContinuation)(IdContinuation, IdContinuation)