tsk-54: Tweak instant message endpoint to save contact and message identification (#56)

Closes #54

Reviewed-on: phoenix/textsender-api#56
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
phoenix
2025-12-22 22:39:29 +00:00
committed by phoenix
parent f5f753fe02
commit 6fa5ede358
10 changed files with 45 additions and 28 deletions
@@ -26,6 +26,9 @@ type RecordEventRequest struct {
Response types.JSONB `json:"response"`
UserId uuid.UUID `json:"user_id"`
Sent *time.Time `json:"sent,omitempty"`
Status string `json:"status"`
ContactId *uuid.UUID `json:"contact_id"`
MessageId *uuid.UUID `json:"message_id"`
}
type RecordEventResponse struct {
@@ -62,6 +65,14 @@ func (e *EventResponseHandler) RecordResponse(w http.ResponseWriter, r *http.Req
rp.UserId = req.UserId
rp.Sent = *req.Sent
if req.Status == message.Message_Event_Response_Status_Instant {
rp.Status = req.Status
rp.MessageId = req.MessageId
rp.ContactId = req.ContactId
} else if req.Status == message.Message_Event_Response_Status_Scheduled {
rp.Status = req.Status
}
ctx := r.Context()
if err := e.MessageEventResponseStore.Create(ctx, &rp); err != nil {
resp.Message = err.Error()