tsk-59: Get MessageEventResponse endpoint (#61)
Closes #59 Reviewed-on: phoenix/textsender-api#61 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
@@ -36,16 +36,18 @@ func (m *MockMessageStore) CreateMessage(ctx context.Context, msg *message.Messa
|
||||
return m.Error
|
||||
}
|
||||
|
||||
if msg.Id == uuid.Nil {
|
||||
msg.Id = uuid.New()
|
||||
var id uuid.UUID
|
||||
if msg.Id != nil && msg.Id == uuid.Nil {
|
||||
id = uuid.New()
|
||||
msg.Id = &id
|
||||
}
|
||||
|
||||
key := MessageKey{Content: msg.Content, UserId: msg.UserId}
|
||||
key := MessageKey{Content: msg.Content, UserId: *msg.UserId}
|
||||
if _, exists := m.MessagesByKey[key]; exists {
|
||||
return errors.New("Message already exists")
|
||||
}
|
||||
|
||||
m.Messages[msg.Id] = msg
|
||||
m.Messages[*msg.Id] = msg
|
||||
m.MessagesByKey[key] = msg
|
||||
return nil
|
||||
}
|
||||
@@ -88,7 +90,7 @@ func (m *MockMessageStore) MessageExists(ctx context.Context, msg *message.Messa
|
||||
return false, m.Error
|
||||
}
|
||||
|
||||
_, exists := m.MessagesByKey[MessageKey{Content: msg.Content, UserId: msg.UserId}]
|
||||
_, exists := m.MessagesByKey[MessageKey{Content: msg.Content, UserId: *msg.UserId}]
|
||||
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user