Speculatively add channel users added through addChatMembers.

This commit is contained in:
levlam 2022-11-17 18:10:26 +03:00
parent 830806937e
commit 63b528f213
2 changed files with 9 additions and 1 deletions

View File

@ -7756,6 +7756,9 @@ void ContactsManager::add_channel_participants(ChannelId channel_id, const vecto
continue;
}
input_users.push_back(r_input_user.move_as_ok());
speculative_add_channel_user(channel_id, user_id, DialogParticipantStatus::Member(),
DialogParticipantStatus::Left());
}
if (input_users.empty()) {
@ -13395,6 +13398,9 @@ void ContactsManager::speculative_add_channel_participants(ChannelId channel_id,
update_channel_online_member_count(channel_id, false);
}
if (channel_full != nullptr) {
if (channel_full->is_changed) {
channel_full->speculative_version++;
}
update_channel_full(channel_full, channel_id, "speculative_add_channel_participants");
}
if (delta_participant_count == 0) {
@ -13475,6 +13481,8 @@ void ContactsManager::speculative_add_channel_user(ChannelId channel_id, UserId
// must copy the initial c->participant_count before it is speculatibely updated
auto channel_full = get_channel_full_force(channel_id, true, "speculative_add_channel_user");
int32 min_count = 0;
LOG(INFO) << "Speculatively change status of " << user_id << " in " << channel_id << " from " << old_status << " to "
<< new_status;
if (channel_full != nullptr) {
channel_full->is_changed |= speculative_add_count(channel_full->administrator_count,
new_status.is_administrator() - old_status.is_administrator());

View File

@ -32,7 +32,7 @@ int VERBOSITY_NAME(file_loader) = VERBOSITY_NAME(DEBUG) + 2;
namespace {
Result<std::pair<FileFd, string>> try_create_new_file(CSlice path, CSlice file_name) {
LOG(DEBUG) << "Trying to create new file " << file_name << " in the directory \"" << path << '"';
LOG(DEBUG) << "Trying to create new file \"" << file_name << "\" in the directory \"" << path << '"';
auto name = PSTRING() << path << file_name;
auto r_fd = FileFd::open(name, FileFd::Read | FileFd::Write | FileFd::CreateNew, 0640);
if (r_fd.is_error()) {