fix: Update the channel title after joining if the QR code included a wrong title#8260
fix: Update the channel title after joining if the QR code included a wrong title#8260Hocuri wants to merge 4 commits into
Conversation
| )?; | ||
| ensure!(cnt == 0, "{cnt} chats exist with grpid {grpid}"); | ||
| let mut params: Params = Params::new(); | ||
| params.update_timestamp(Param::GroupNameTimestamp, time())?; |
There was a problem hiding this comment.
It's not clear why this is needed for broadcasts, but not for groups. Why doesn't .set_i64(Param::GroupNameTimestamp, msg.timestamp_sort) in prepare_msg_raw() work, because prepare_msg_raw() isn't called when adding a new subscriber?
There was a problem hiding this comment.
Because of && self.param.get_int(Param::Unpromoted).unwrap_or_default() == 1. Groups are unpromoted right after creating them, broadcast channels are immediately promoted.
There was a problem hiding this comment.
Then the check in prepare_msg_raw() should be fixed, checking for Chattype::OutBroadcast is not necessary and confusing. And the documentation of create_broadcast() says:
/// After creation, the chat contains no recipients and is in _unpromoted_ state;
Should be fixed as well.
But the reason why for groups Param::GroupNameTimestamp is set when they get promoted is to not reveal the group creation time, as far as i remember. For broadcasts it also may make sense. Would be good to have the same logic for groups and broadcasts, maybe just set the timestamp to 1 on chat creation?
Fix #8250. Not sure why anyone would tamper with the link, but maybe the name gets ellipsized because it is very long, or maybe we decide to ellipsize more aggressively in the future.
The fix is easy enough, just set the GroupNameTimestamp when creating the channel, so that
HeaderDef::ChatGroupNameTimestampgets set when sending a message and the logic inapply_chat_name_avatar_and_description_changes()recognizes the incoming name's timestamp as newer thanchat_group_name_timestamp(which is 0 right after joining a chat).The test is somewhat hacky and depends on the title being the last parameter in the invite code URL, but this is fine; if we ever change that, then the test will fail and we need to modify it.