diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index 4f628984c..617bf5d1b 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -1537,8 +1537,8 @@ void GroupCallManager::on_sync_group_call_participants_failed(InputGroupCallId i } GroupCallParticipantOrder GroupCallManager::get_real_participant_order( - const GroupCallParticipant &participant, const GroupCallParticipantOrder &min_order) const { - auto real_order = participant.get_real_order(); + bool can_manage, const GroupCallParticipant &participant, const GroupCallParticipantOrder &min_order) const { + auto real_order = participant.get_real_order(can_manage); if (real_order >= min_order) { return real_order; } @@ -1576,6 +1576,7 @@ void GroupCallManager::process_group_call_participants( } auto min_order = GroupCallParticipantOrder::max(); + bool can_manage = can_manage_group_call(input_group_call_id); for (auto &participant : participants) { GroupCallParticipant group_call_participant(participant); if (!group_call_participant.is_valid()) { @@ -1587,7 +1588,7 @@ void GroupCallManager::process_group_call_participants( continue; } - auto real_order = group_call_participant.get_real_order(); + auto real_order = group_call_participant.get_real_order(can_manage); if (real_order > min_order) { LOG(ERROR) << "Receive call participant with order " << real_order << " after call participant with order " << min_order; @@ -1642,7 +1643,7 @@ void GroupCallManager::process_group_call_participants( participants_it->second->min_order = min_order; for (auto &participant : participants_it->second->participants) { - auto real_order = get_real_participant_order(participant, min_order); + auto real_order = get_real_participant_order(can_manage, participant, min_order); if (old_min_order > real_order && real_order >= min_order) { CHECK(!participant.order.is_valid() || participant.order == old_min_order); participant.order = real_order; @@ -1718,7 +1719,7 @@ int GroupCallManager::process_group_call_participant(InputGroupCallId input_grou participant.update_from(old_participant); participant.is_just_joined = false; - participant.order = get_real_participant_order(participant, participants->min_order); + participant.order = get_real_participant_order(can_manage, participant, participants->min_order); update_group_call_participant_can_be_muted(can_manage, participants, participant); LOG(INFO) << "Edit " << old_participant << " to " << participant; @@ -1744,7 +1745,7 @@ int GroupCallManager::process_group_call_participant(InputGroupCallId input_grou } else { LOG(INFO) << "Receive new " << participant; } - participant.order = get_real_participant_order(participant, participants->min_order); + participant.order = get_real_participant_order(can_manage, participant, participants->min_order); participant.is_just_joined = false; update_group_call_participant_can_be_muted(can_manage, participants, participant); participants->participants.push_back(std::move(participant)); @@ -3315,7 +3316,8 @@ DialogId GroupCallManager::set_group_call_participant_is_speaking_by_source(Inpu if (is_speaking) { participant.local_active_date = max(participant.local_active_date, date); } - participant.order = get_real_participant_order(participant, participants_it->second->min_order); + bool can_manage = can_manage_group_call(input_group_call_id); + participant.order = get_real_participant_order(can_manage, participant, participants_it->second->min_order); if (participant.order.is_valid()) { send_update_group_call_participant(input_group_call_id, participant); } diff --git a/td/telegram/GroupCallManager.h b/td/telegram/GroupCallManager.h index 465c0b0cf..b8a4ab336 100644 --- a/td/telegram/GroupCallManager.h +++ b/td/telegram/GroupCallManager.h @@ -180,7 +180,7 @@ class GroupCallManager : public Actor { void on_sync_group_call_participants_failed(InputGroupCallId input_group_call_id); - GroupCallParticipantOrder get_real_participant_order(const GroupCallParticipant &participant, + GroupCallParticipantOrder get_real_participant_order(bool can_manage, const GroupCallParticipant &participant, const GroupCallParticipantOrder &min_order) const; void process_group_call_participants(InputGroupCallId group_call_id, diff --git a/td/telegram/GroupCallParticipant.cpp b/td/telegram/GroupCallParticipant.cpp index 88231bb72..e15d5d958 100644 --- a/td/telegram/GroupCallParticipant.cpp +++ b/td/telegram/GroupCallParticipant.cpp @@ -6,6 +6,7 @@ // #include "td/telegram/GroupCallParticipant.h" +#include "td/telegram/Global.h" #include "td/telegram/MessagesManager.h" #include "td/telegram/Td.h" @@ -56,8 +57,12 @@ bool GroupCallParticipant::is_versioned_update(const tl_object_ptrjust_joined_ || participant->left_ || participant->versioned_; } -GroupCallParticipantOrder GroupCallParticipant::get_real_order() const { - return GroupCallParticipantOrder(max(active_date, local_active_date), 0, joined_date); +GroupCallParticipantOrder GroupCallParticipant::get_real_order(bool can_manage) const { + auto date = td::max(active_date, local_active_date); + if (date < G()->unix_time() - 300) { + date = 0; + } + return GroupCallParticipantOrder(date, can_manage ? raise_hand_rating : 0, joined_date); } bool GroupCallParticipant::get_is_muted_by_themselves() const { diff --git a/td/telegram/GroupCallParticipant.h b/td/telegram/GroupCallParticipant.h index 54b1bf686..20247947e 100644 --- a/td/telegram/GroupCallParticipant.h +++ b/td/telegram/GroupCallParticipant.h @@ -72,7 +72,7 @@ struct GroupCallParticipant { bool set_pending_is_muted(bool is_muted, bool can_manage, bool is_admin); - GroupCallParticipantOrder get_real_order() const; + GroupCallParticipantOrder get_real_order(bool can_manage) const; bool is_valid() const { return dialog_id.is_valid();