phoneof/adapters/messaging/db.go
Elizabeth Hunt 2984a715b8
All checks were successful
continuous-integration/drone/push Build is passing
add ntfy integration
2025-01-05 15:29:23 -08:00

30 lines
791 B
Go

package messaging
import (
"database/sql"
"log"
"time"
"git.simponic.xyz/simponic/phoneof/database"
)
func PersistMessageContinuation(dbConn *sql.DB, frenId string, messageId string, sentAt time.Time, frenSent bool) Continuation {
return func(message Message) ContinuationChain {
log.Printf("persisting message %v %s %s %s %v", message, frenId, messageId, sentAt, frenSent)
return func(success Continuation, failure Continuation) ContinuationChain {
_, err := database.SaveMessage(dbConn, &database.Message{
Id: messageId,
FrenId: frenId,
Message: message.Message,
Time: sentAt,
FrenSent: frenSent,
})
if err != nil {
log.Printf("err when saving message %s", err)
return failure(message)
}
return success(message)
}
}
}