Elizabeth Hunt
2984a715b8
All checks were successful
continuous-integration/drone/push Build is passing
30 lines
791 B
Go
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)
|
|
}
|
|
}
|
|
}
|