Simplify GroupCallManager::process_group_call_participants_from_updates.
This commit is contained in:
parent
7fc19c3733
commit
841ef6dc7f
@ -720,8 +720,17 @@ void GroupCallManager::on_update_group_call_participants(
|
|||||||
LOG(INFO) << "Ignore already applied updateGroupCallParticipants in " << input_group_call_id;
|
LOG(INFO) << "Ignore already applied updateGroupCallParticipants in " << input_group_call_id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (group_call->version + static_cast<int32>(participants.size()) == version) {
|
if (version == group_call->version + static_cast<int32>(participants.size())) {
|
||||||
process_group_call_participants_from_updates(input_group_call_id, std::move(participants));
|
group_call->version += static_cast<int32>(participants.size());
|
||||||
|
auto diff = process_group_call_participants_from_updates(input_group_call_id, std::move(participants));
|
||||||
|
if (diff != 0 && (group_call->participant_count != 0 || diff > 0)) {
|
||||||
|
group_call->participant_count += diff;
|
||||||
|
if (group_call->participant_count < 0) {
|
||||||
|
LOG(ERROR) << "Participant count became negative in " << input_group_call_id;
|
||||||
|
group_call->participant_count = 0;
|
||||||
|
}
|
||||||
|
send_update_group_call(group_call);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,29 +782,13 @@ void GroupCallManager::process_group_call_participants(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCallManager::process_group_call_participants_from_updates(
|
int32 GroupCallManager::process_group_call_participants_from_updates(
|
||||||
InputGroupCallId input_group_call_id, vector<tl_object_ptr<telegram_api::groupCallParticipant>> &&participants) {
|
InputGroupCallId input_group_call_id, vector<tl_object_ptr<telegram_api::groupCallParticipant>> &&participants) {
|
||||||
if (!need_group_call_participants(input_group_call_id)) {
|
int32 diff = 0;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto group_call = get_group_call(input_group_call_id);
|
|
||||||
CHECK(group_call != nullptr && group_call->is_inited);
|
|
||||||
CHECK(group_call->version == -1);
|
|
||||||
group_call->version += static_cast<int32>(participants.size());
|
|
||||||
|
|
||||||
auto old_participant_count = group_call->participant_count;
|
|
||||||
for (auto &participant : participants) {
|
for (auto &participant : participants) {
|
||||||
group_call->participant_count +=
|
diff += process_group_call_participant(input_group_call_id, GroupCallParticipant(participant));
|
||||||
process_group_call_participant(input_group_call_id, GroupCallParticipant(participant));
|
|
||||||
}
|
|
||||||
if (group_call->participant_count < 0) {
|
|
||||||
LOG(ERROR) << "Participant count became negative in " << input_group_call_id;
|
|
||||||
group_call->participant_count = 0;
|
|
||||||
}
|
|
||||||
if (group_call->participant_count != old_participant_count) {
|
|
||||||
send_update_group_call(group_call);
|
|
||||||
}
|
}
|
||||||
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GroupCallManager::process_group_call_participant(InputGroupCallId input_group_call_id,
|
int GroupCallManager::process_group_call_participant(InputGroupCallId input_group_call_id,
|
||||||
|
@ -117,7 +117,7 @@ class GroupCallManager : public Actor {
|
|||||||
vector<tl_object_ptr<telegram_api::groupCallParticipant>> &&participants,
|
vector<tl_object_ptr<telegram_api::groupCallParticipant>> &&participants,
|
||||||
bool is_load);
|
bool is_load);
|
||||||
|
|
||||||
void process_group_call_participants_from_updates(
|
int32 process_group_call_participants_from_updates(
|
||||||
InputGroupCallId group_call_id, vector<tl_object_ptr<telegram_api::groupCallParticipant>> &&participants);
|
InputGroupCallId group_call_id, vector<tl_object_ptr<telegram_api::groupCallParticipant>> &&participants);
|
||||||
|
|
||||||
int process_group_call_participant(InputGroupCallId group_call_id, GroupCallParticipant &&participant);
|
int process_group_call_participant(InputGroupCallId group_call_id, GroupCallParticipant &&participant);
|
||||||
|
Loading…
Reference in New Issue
Block a user