fix: sync rich-only private messages
This commit is contained in:
parent
ae5bd43ce0
commit
c18f773701
8 changed files with 132 additions and 9 deletions
|
|
@ -3,6 +3,7 @@ package postgres
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -54,7 +55,6 @@ func TestSendPrivateRichMessageSurvivesReadPaths(t *testing.T) {
|
|||
SenderUserID: sender.ID,
|
||||
RecipientUserID: recipient.ID,
|
||||
RandomID: time.Now().UnixNano(),
|
||||
Message: "rich",
|
||||
RichMessage: rich,
|
||||
Date: int(time.Now().Unix()),
|
||||
})
|
||||
|
|
@ -121,4 +121,16 @@ func TestSendPrivateRichMessageSurvivesReadPaths(t *testing.T) {
|
|||
if !sawEvent {
|
||||
t.Fatal("no new_message event for recipient")
|
||||
}
|
||||
|
||||
// The shared store invariant still rejects a command with no text, media, or
|
||||
// rich payload; accepting rich-only must not make truly empty rows possible.
|
||||
_, err = messages.SendPrivateText(ctx, domain.SendPrivateTextRequest{
|
||||
SenderUserID: sender.ID,
|
||||
RecipientUserID: recipient.ID,
|
||||
RandomID: time.Now().UnixNano(),
|
||||
Date: int(time.Now().Unix()),
|
||||
})
|
||||
if !errors.Is(err, domain.ErrMessageEmpty) {
|
||||
t.Fatalf("send empty private message err = %v, want ErrMessageEmpty", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ func (s *MessageStore) sendPrivateTextOnce(ctx context.Context, req domain.SendP
|
|||
if req.RandomID == 0 {
|
||||
return domain.SendPrivateTextResult{}, fmt.Errorf("send private text: missing random id")
|
||||
}
|
||||
if req.Message == "" && req.Media.IsZero() {
|
||||
return domain.SendPrivateTextResult{}, fmt.Errorf("send private text: empty message")
|
||||
if !req.HasContent() {
|
||||
return domain.SendPrivateTextResult{}, domain.ErrMessageEmpty
|
||||
}
|
||||
if req.Date == 0 {
|
||||
req.Date = int(time.Now().Unix())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue