Could it be?
This commit is contained in:
@@ -46,11 +46,6 @@ type AddMessageResponse struct {
|
|||||||
// @Failure 500 {object} AddMessageResponse
|
// @Failure 500 {object} AddMessageResponse
|
||||||
// @Router /message/new [post]
|
// @Router /message/new [post]
|
||||||
func (m *MessageHandler) AddMessage(w http.ResponseWriter, r *http.Request) {
|
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
|
var req RequestAddMessage
|
||||||
if err := ExtractFromRequest(r, &req); err != nil {
|
if err := ExtractFromRequest(r, &req); err != nil {
|
||||||
http.Error(w, "Invalid JSON: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Invalid JSON: "+err.Error(), http.StatusBadRequest)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package mock
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"git.kundeng.us/phoenix/textsender-models/tx0/message"
|
"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
|
var id uuid.UUID
|
||||||
if msg.Id != nil && *msg.Id == uuid.Nil {
|
if msg != nil {
|
||||||
id = uuid.New()
|
if msg.Id == nil || *msg.Id == uuid.Nil {
|
||||||
msg.Id = &id
|
id = uuid.New()
|
||||||
|
msg.Id = &id
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("Message not populated")
|
||||||
}
|
}
|
||||||
|
|
||||||
key := MessageKey{Content: msg.Content, UserId: *msg.UserId}
|
key := MessageKey{Content: msg.Content, UserId: *msg.UserId}
|
||||||
|
|||||||
Reference in New Issue
Block a user