forked from mtusi2026/mtusi2026lab3
fix(messages): check chat membership on idempotent replay
This commit is contained in:
@@ -83,6 +83,17 @@ func (s *MessageService) Create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if inserted == 0 {
|
if inserted == 0 {
|
||||||
|
isMember, err := q.IsChatMember(ctx, db.IsChatMemberParams{
|
||||||
|
ChatID: chatID,
|
||||||
|
UserID: userID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return model.Message{}, err
|
||||||
|
}
|
||||||
|
if !isMember {
|
||||||
|
return model.Message{}, ErrMessageChatNotFound
|
||||||
|
}
|
||||||
|
|
||||||
stored, err := q.GetIdempotentMessage(ctx, db.GetIdempotentMessageParams{
|
stored, err := q.GetIdempotentMessage(ctx, db.GetIdempotentMessageParams{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
|
|||||||
Reference in New Issue
Block a user