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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user