Separately apply versioned and unversioned group call updates.
This commit is contained in:
parent
7aadb29e0a
commit
8dd4fe3166
|
@ -1182,7 +1182,7 @@ groupCall#55903081 flags:# join_muted:flags.1?true can_change_join_muted:flags.2
|
||||||
|
|
||||||
inputGroupCall#d8aa840f id:long access_hash:long = InputGroupCall;
|
inputGroupCall#d8aa840f id:long access_hash:long = InputGroupCall;
|
||||||
|
|
||||||
groupCallParticipant#56b087c9 flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true just_joined:flags.4?true user_id:int date:int active_date:flags.3?int source:int = GroupCallParticipant;
|
groupCallParticipant#56b087c9 flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true just_joined:flags.4?true versioned:flags.5?true user_id:int date:int active_date:flags.3?int source:int = GroupCallParticipant;
|
||||||
|
|
||||||
phone.groupCall#66ab0bfc call:GroupCall participants:Vector<GroupCallParticipant> participants_next_offset:string users:Vector<User> = phone.GroupCall;
|
phone.groupCall#66ab0bfc call:GroupCall participants:Vector<GroupCallParticipant> participants_next_offset:string users:Vector<User> = phone.GroupCall;
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -11722,7 +11722,7 @@ void ContactsManager::on_update_chat_status(Chat *c, ChatId chat_id, DialogParti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (need_reload_group_call) {
|
if (need_reload_group_call) {
|
||||||
td_->messages_manager_->reload_dialog_group_call(DialogId(chat_id));
|
td_->messages_manager_->on_update_dialog_group_call_rights(DialogId(chat_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
c->is_changed = true;
|
c->is_changed = true;
|
||||||
|
@ -12064,7 +12064,7 @@ void ContactsManager::on_channel_status_changed(Channel *c, ChannelId channel_id
|
||||||
reload_dialog_administrators(DialogId(channel_id), 0, Auto());
|
reload_dialog_administrators(DialogId(channel_id), 0, Auto());
|
||||||
}
|
}
|
||||||
if (need_reload_group_call) {
|
if (need_reload_group_call) {
|
||||||
td_->messages_manager_->reload_dialog_group_call(DialogId(channel_id));
|
td_->messages_manager_->on_update_dialog_group_call_rights(DialogId(channel_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -427,7 +427,9 @@ struct GroupCallManager::GroupCallParticipants {
|
||||||
int64 min_order = std::numeric_limits<int64>::max();
|
int64 min_order = std::numeric_limits<int64>::max();
|
||||||
|
|
||||||
vector<UserId> administrator_user_ids;
|
vector<UserId> administrator_user_ids;
|
||||||
std::map<int32, vector<tl_object_ptr<telegram_api::groupCallParticipant>>> pending_updates_;
|
|
||||||
|
std::map<int32, vector<tl_object_ptr<telegram_api::groupCallParticipant>>> pending_version_updates_;
|
||||||
|
std::map<int32, vector<tl_object_ptr<telegram_api::groupCallParticipant>>> pending_mute_updates_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GroupCallManager::GroupCallRecentSpeakers {
|
struct GroupCallManager::GroupCallRecentSpeakers {
|
||||||
|
@ -870,6 +872,9 @@ void GroupCallManager::on_get_group_call_participants(
|
||||||
group_call->loaded_all_participants = false;
|
group_call->loaded_all_participants = false;
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
|
if (process_pending_group_call_participant_updates(input_group_call_id)) {
|
||||||
|
need_update = false;
|
||||||
|
}
|
||||||
if (need_update) {
|
if (need_update) {
|
||||||
send_update_group_call(group_call, "on_get_group_call_participants");
|
send_update_group_call(group_call, "on_get_group_call_participants");
|
||||||
}
|
}
|
||||||
|
@ -944,13 +949,24 @@ void GroupCallManager::on_update_group_call_participants(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *group_call_participants = add_group_call_participants(input_group_call_id);
|
auto *group_call_participants = add_group_call_participants(input_group_call_id);
|
||||||
auto &pending_updates = group_call_participants->pending_updates_[version];
|
auto &pending_mute_updates = group_call_participants->pending_mute_updates_[version];
|
||||||
if (participants.size() <= pending_updates.size()) {
|
vector<tl_object_ptr<telegram_api::groupCallParticipant>> version_updates;
|
||||||
|
for (auto &participant : participants) {
|
||||||
|
if (GroupCallParticipant::is_versioned_update(participant)) {
|
||||||
|
version_updates.push_back(std::move(participant));
|
||||||
|
} else {
|
||||||
|
pending_mute_updates.push_back(std::move(participant));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!version_updates.empty()) {
|
||||||
|
auto &pending_version_updates = group_call_participants->pending_version_updates_[version];
|
||||||
|
if (version_updates.size() <= pending_version_updates.size()) {
|
||||||
LOG(INFO) << "Receive duplicate updateGroupCallParticipants with version " << version << " in "
|
LOG(INFO) << "Receive duplicate updateGroupCallParticipants with version " << version << " in "
|
||||||
<< input_group_call_id;
|
<< input_group_call_id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pending_updates = std::move(participants);
|
pending_version_updates = std::move(version_updates);
|
||||||
|
}
|
||||||
|
|
||||||
process_pending_group_call_participant_updates(input_group_call_id);
|
process_pending_group_call_participant_updates(input_group_call_id);
|
||||||
}
|
}
|
||||||
|
@ -964,7 +980,6 @@ bool GroupCallManager::process_pending_group_call_participant_updates(InputGroup
|
||||||
if (participants_it == group_call_participants_.end()) {
|
if (participants_it == group_call_participants_.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto &pending_updates = participants_it->second->pending_updates_;
|
|
||||||
auto group_call = get_group_call(input_group_call_id);
|
auto group_call = get_group_call(input_group_call_id);
|
||||||
CHECK(group_call != nullptr && group_call->is_inited);
|
CHECK(group_call != nullptr && group_call->is_inited);
|
||||||
if (group_call->version == -1 || !group_call->is_active) {
|
if (group_call->version == -1 || !group_call->is_active) {
|
||||||
|
@ -974,31 +989,27 @@ bool GroupCallManager::process_pending_group_call_participant_updates(InputGroup
|
||||||
int32 diff = 0;
|
int32 diff = 0;
|
||||||
bool is_left = false;
|
bool is_left = false;
|
||||||
bool need_rejoin = true;
|
bool need_rejoin = true;
|
||||||
while (!pending_updates.empty()) {
|
auto &pending_version_updates = participants_it->second->pending_version_updates_;
|
||||||
auto it = pending_updates.begin();
|
while (!pending_version_updates.empty()) {
|
||||||
|
auto it = pending_version_updates.begin();
|
||||||
auto version = it->first;
|
auto version = it->first;
|
||||||
auto &participants = it->second;
|
auto &participants = it->second;
|
||||||
if (version <= group_call->version) {
|
if (version <= group_call->version) {
|
||||||
for (auto &group_call_participant : participants) {
|
for (auto &group_call_participant : participants) {
|
||||||
GroupCallParticipant participant(group_call_participant);
|
GroupCallParticipant participant(group_call_participant);
|
||||||
on_participant_speaking_in_group_call(input_group_call_id, participant);
|
on_participant_speaking_in_group_call(input_group_call_id, participant);
|
||||||
if (participant.user_id == td_->contacts_manager_->get_my_id()) {
|
if (participant.user_id == td_->contacts_manager_->get_my_id() && version == group_call->version &&
|
||||||
|
participant.is_just_joined) {
|
||||||
process_group_call_participant(input_group_call_id, std::move(participant));
|
process_group_call_participant(input_group_call_id, std::move(participant));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG(INFO) << "Ignore already applied updateGroupCallParticipants with version " << version << " in "
|
LOG(INFO) << "Ignore already applied updateGroupCallParticipants with version " << version << " in "
|
||||||
<< input_group_call_id << " from " << group_call->dialog_id;
|
<< input_group_call_id << " from " << group_call->dialog_id;
|
||||||
pending_updates.erase(it);
|
pending_version_updates.erase(it);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (version < group_call->version + static_cast<int32>(participants.size())) {
|
|
||||||
LOG(INFO) << "Receive " << participants.size() << " group call participant updates with version " << version
|
|
||||||
<< ", but current version is " << group_call->version;
|
|
||||||
sync_group_call_participants(input_group_call_id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version == group_call->version + static_cast<int32>(participants.size())) {
|
if (version == group_call->version + 1) {
|
||||||
group_call->version = version;
|
group_call->version = version;
|
||||||
for (auto &participant : participants) {
|
for (auto &participant : participants) {
|
||||||
GroupCallParticipant group_call_participant(participant);
|
GroupCallParticipant group_call_participant(participant);
|
||||||
|
@ -1011,7 +1022,7 @@ bool GroupCallManager::process_pending_group_call_participant_updates(InputGroup
|
||||||
}
|
}
|
||||||
diff += process_group_call_participant(input_group_call_id, std::move(group_call_participant));
|
diff += process_group_call_participant(input_group_call_id, std::move(group_call_participant));
|
||||||
}
|
}
|
||||||
pending_updates.erase(it);
|
pending_version_updates.erase(it);
|
||||||
} else if (!group_call->syncing_participants) {
|
} else if (!group_call->syncing_participants) {
|
||||||
// found a gap
|
// found a gap
|
||||||
LOG(INFO) << "Receive " << participants.size() << " group call participant updates with version " << version
|
LOG(INFO) << "Receive " << participants.size() << " group call participant updates with version " << version
|
||||||
|
@ -1020,7 +1031,27 @@ bool GroupCallManager::process_pending_group_call_participant_updates(InputGroup
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pending_updates.empty()) {
|
|
||||||
|
auto &pending_mute_updates = participants_it->second->pending_mute_updates_;
|
||||||
|
while (!pending_mute_updates.empty()) {
|
||||||
|
auto it = pending_mute_updates.begin();
|
||||||
|
auto version = it->first;
|
||||||
|
if (version <= group_call->version) {
|
||||||
|
auto &participants = it->second;
|
||||||
|
for (auto &group_call_participant : participants) {
|
||||||
|
GroupCallParticipant participant(group_call_participant);
|
||||||
|
on_participant_speaking_in_group_call(input_group_call_id, participant);
|
||||||
|
int mute_diff = process_group_call_participant(input_group_call_id, std::move(participant));
|
||||||
|
CHECK(mute_diff == 0);
|
||||||
|
}
|
||||||
|
pending_mute_updates.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
on_receive_group_call_version(input_group_call_id, version);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pending_version_updates.empty() && pending_mute_updates.empty()) {
|
||||||
sync_participants_timeout_.cancel_timeout(group_call->group_call_id.get());
|
sync_participants_timeout_.cancel_timeout(group_call->group_call_id.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1974,8 +2005,9 @@ void GroupCallManager::on_receive_group_call_version(InputGroupCallId input_grou
|
||||||
}
|
}
|
||||||
|
|
||||||
// found a gap
|
// found a gap
|
||||||
|
LOG(INFO) << "Receive version " << version << " for group call " << input_group_call_id;
|
||||||
auto *group_call_participants = add_group_call_participants(input_group_call_id);
|
auto *group_call_participants = add_group_call_participants(input_group_call_id);
|
||||||
group_call_participants->pending_updates_[version]; // reserve place for updates
|
group_call_participants->pending_version_updates_[version]; // reserve place for updates
|
||||||
sync_participants_timeout_.add_timeout_in(group_call->group_call_id.get(), 1.0);
|
sync_participants_timeout_.add_timeout_in(group_call->group_call_id.get(), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ GroupCallParticipant::GroupCallParticipant(const tl_object_ptr<telegram_api::gro
|
||||||
is_just_joined = participant->just_joined_;
|
is_just_joined = participant->just_joined_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GroupCallParticipant::is_versioned_update(const tl_object_ptr<telegram_api::groupCallParticipant> &participant) {
|
||||||
|
return participant->just_joined_ || participant->left_ || participant->versioned_;
|
||||||
|
}
|
||||||
|
|
||||||
bool GroupCallParticipant::update_can_be_muted(bool can_manage, bool is_self, bool is_admin) {
|
bool GroupCallParticipant::update_can_be_muted(bool can_manage, bool is_self, bool is_admin) {
|
||||||
bool new_can_be_muted = false;
|
bool new_can_be_muted = false;
|
||||||
bool new_can_be_unmuted = false;
|
bool new_can_be_unmuted = false;
|
||||||
|
|
|
@ -20,10 +20,10 @@ class ContactsManager;
|
||||||
struct GroupCallParticipant {
|
struct GroupCallParticipant {
|
||||||
UserId user_id;
|
UserId user_id;
|
||||||
int32 source = 0;
|
int32 source = 0;
|
||||||
bool is_muted = false;
|
|
||||||
bool can_self_unmute = false;
|
|
||||||
int32 joined_date = 0;
|
int32 joined_date = 0;
|
||||||
int32 active_date = 0;
|
int32 active_date = 0;
|
||||||
|
bool is_muted = false;
|
||||||
|
bool can_self_unmute = false;
|
||||||
|
|
||||||
bool can_be_muted = false;
|
bool can_be_muted = false;
|
||||||
bool can_be_unmuted = false;
|
bool can_be_unmuted = false;
|
||||||
|
@ -37,6 +37,8 @@ struct GroupCallParticipant {
|
||||||
|
|
||||||
explicit GroupCallParticipant(const tl_object_ptr<telegram_api::groupCallParticipant> &participant);
|
explicit GroupCallParticipant(const tl_object_ptr<telegram_api::groupCallParticipant> &participant);
|
||||||
|
|
||||||
|
static bool is_versioned_update(const tl_object_ptr<telegram_api::groupCallParticipant> &participant);
|
||||||
|
|
||||||
bool update_can_be_muted(bool can_manage, bool is_self, bool is_admin);
|
bool update_can_be_muted(bool can_manage, bool is_self, bool is_admin);
|
||||||
|
|
||||||
int64 get_real_order() const {
|
int64 get_real_order() const {
|
||||||
|
|
|
@ -10651,7 +10651,7 @@ void MessagesManager::delete_dialog(DialogId dialog_id) {
|
||||||
close_dialog(d);
|
close_dialog(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::reload_dialog_group_call(DialogId dialog_id) {
|
void MessagesManager::on_update_dialog_group_call_rights(DialogId dialog_id) {
|
||||||
if (td_->auth_manager_->is_bot()) {
|
if (td_->auth_manager_->is_bot()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -397,7 +397,7 @@ class MessagesManager : public Actor {
|
||||||
|
|
||||||
void delete_dialog(DialogId dialog_id);
|
void delete_dialog(DialogId dialog_id);
|
||||||
|
|
||||||
void reload_dialog_group_call(DialogId dialog_id);
|
void on_update_dialog_group_call_rights(DialogId dialog_id);
|
||||||
|
|
||||||
void read_all_dialog_mentions(DialogId dialog_id, Promise<Unit> &&promise);
|
void read_all_dialog_mentions(DialogId dialog_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
|
|
@ -3895,6 +3895,9 @@ class CliClient final : public Actor {
|
||||||
} else if (status_str == "addadmin") {
|
} else if (status_str == "addadmin") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("anon", false, false, false, false, false,
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("anon", false, false, false, false, false,
|
||||||
false, false, false, true, false, false);
|
false, false, false, true, false, false);
|
||||||
|
} else if (status_str == "calladmin") {
|
||||||
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("anon", false, false, false, false, false,
|
||||||
|
false, false, false, false, true, false);
|
||||||
} else if (status_str == "admin") {
|
} else if (status_str == "admin") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("", true, true, true, true, true, true,
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("", true, true, true, true, true, true,
|
||||||
true, true, true, false, false);
|
true, true, true, false, false);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user