Could it be?

This commit is contained in:
phoenix
2026-01-01 14:28:55 -05:00
parent 400490b633
commit a0bab48f40
2 changed files with 8 additions and 8 deletions
-5
View File
@@ -46,11 +46,6 @@ type AddMessageResponse struct {
// @Failure 500 {object} AddMessageResponse
// @Router /message/new [post]
func (m *MessageHandler) AddMessage(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
var req RequestAddMessage
if err := ExtractFromRequest(r, &req); err != nil {
http.Error(w, "Invalid JSON: "+err.Error(), http.StatusBadRequest)
+8 -3
View File
@@ -3,6 +3,7 @@ package mock
import (
"context"
"errors"
"fmt"
"sync"
"git.kundeng.us/phoenix/textsender-models/tx0/message"
@@ -37,9 +38,13 @@ func (m *MockMessageStore) CreateMessage(ctx context.Context, msg *message.Messa
}
var id uuid.UUID
if msg.Id != nil && *msg.Id == uuid.Nil {
id = uuid.New()
msg.Id = &id
if msg != nil {
if msg.Id == nil || *msg.Id == uuid.Nil {
id = uuid.New()
msg.Id = &id
}
} else {
return fmt.Errorf("Message not populated")
}
key := MessageKey{Content: msg.Content, UserId: *msg.UserId}