forum: project the forum's own channel with member state in getForumTopics
messages.getForumTopics returned every chat via tgChannels -> tgChannelChatMin, so the forum's own channel came back as a min object with left unset. A client with no other object for that peer (a fresh account browsing a public forum by username) then rendered the forum as already joined: topic list visible, no Join button, but no messages. Render the primary channel with tgChannelChatForView so a non-member preview carries left=true; keep the other referenced channels as min. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
b52d3f3f64
commit
a9fbb1f80d
2 changed files with 41 additions and 1 deletions
|
|
@ -81,6 +81,21 @@ func TestGetForumTopicsVisibleToPublicNonMember(t *testing.T) {
|
|||
t.Fatalf("non-member did not see the Test topic: %+v", res.Topics)
|
||||
}
|
||||
|
||||
// The forum's own channel must come back with left=true so the client still
|
||||
// offers a Join button instead of treating the forum as already joined.
|
||||
var forumChat *tg.Channel
|
||||
for _, c := range res.Chats {
|
||||
if ch, ok := c.(*tg.Channel); ok && ch.ID == channel.ID {
|
||||
forumChat = ch
|
||||
}
|
||||
}
|
||||
if forumChat == nil {
|
||||
t.Fatalf("forum channel missing from getForumTopics chats: %+v", res.Chats)
|
||||
}
|
||||
if !forumChat.Left {
|
||||
t.Fatalf("non-member forum chat = %#v, want left=true", forumChat)
|
||||
}
|
||||
|
||||
// A private forum still refuses a non-member.
|
||||
priv, err := r.onChannelsCreateChannel(ownerCtx, &tg.ChannelsCreateChannelRequest{Title: "Private Forum", Megagroup: true})
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue