fix for comments in groups

This commit is contained in:
onysd 2026-09-12 19:14:53 +03:00
parent 93e5d4229d
commit 7c0639cf6a
3 changed files with 154 additions and 2 deletions

View file

@ -565,7 +565,10 @@ func (s *ChannelStore) resolveChannelReplyLocked(req domain.SendChannelMessageRe
if target.ReplyTo != nil && target.ReplyTo.TopMessageID > 0 {
reply.TopMessageID = target.ReplyTo.TopMessageID
}
if req.ReplyTo.TopMessageID > 0 && req.ReplyTo.TopMessageID != reply.TopMessageID {
// Mirrors the postgres store: only a forum's top_msg_id selects anything, so
// only there is a disagreement with the computed thread root refused. See
// the comment on the same check in store/postgres/channel_helpers.go.
if channel.Forum && req.ReplyTo.TopMessageID > 0 && req.ReplyTo.TopMessageID != reply.TopMessageID {
return nil, domain.ErrReplyMessageIDInvalid
}
if channel.Forum && reply.TopMessageID > 0 {

View file

@ -884,7 +884,16 @@ WHERE owner_user_id=$1 AND peer_type='user' AND peer_id=$2 AND box_id=$3 AND NOT
if target.ReplyTo != nil && target.ReplyTo.TopMessageID > 0 {
reply.TopMessageID = target.ReplyTo.TopMessageID
}
if req.ReplyTo.TopMessageID > 0 && req.ReplyTo.TopMessageID != reply.TopMessageID {
// Outside a forum the client's top_msg_id decides nothing: the thread root is
// whichever thread the reply target belongs to, which reply.TopMessageID
// already holds, and the caller's value is discarded either way. Refusing the
// mismatch there only broke real clients -- stock tdesktop fills top_msg_id
// with ForumTopic::kGeneralId (1) when it attaches a file in a comments
// thread on a linked discussion group, so every media comment failed with
// REPLY_MESSAGE_ID_INVALID while the same comment sent as text went through.
// Inside a forum the value really does pick a topic, so a disagreement there
// is still a client error worth refusing.
if channel.Forum && req.ReplyTo.TopMessageID > 0 && req.ReplyTo.TopMessageID != reply.TopMessageID {
return nil, domain.ErrReplyMessageIDInvalid
}
if channel.Forum && reply.TopMessageID > 0 {