tsk-44: Record when message was sent (#48)
Closes #44 Reviewed-on: phoenix/textsender-api#48 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.kundeng.us/phoenix/textsender-models/tx0/message"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
type MessageEventResponseStore interface {
|
||||
Create(ctx context.Context, mer *message.MessageEventResponse) error
|
||||
}
|
||||
|
||||
type PGMessageEventResponseStore struct {
|
||||
db *pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewMessageEventResponseStore(db *pgxpool.Pool) *PGMessageEventResponseStore {
|
||||
return &PGMessageEventResponseStore{db: db}
|
||||
}
|
||||
|
||||
func (m *PGMessageEventResponseStore) Create(ctx context.Context, mer *message.MessageEventResponse) error {
|
||||
query := `
|
||||
INSERT INTO message_event_responses (scheduled_message_event_id, response, user_id, sent)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id
|
||||
`
|
||||
|
||||
return m.db.QueryRow(ctx, query, mer.ScheduledMessageEventId, mer.Response, mer.UserId, mer.Sent).Scan(&mer.Id)
|
||||
}
|
||||
Reference in New Issue
Block a user