From 798791223057067befb91e6786fbb0905469c180 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 15 Mar 2021 18:53:51 +0300 Subject: [PATCH] Use string as groupCallParticipant.order. --- td/generate/scheme/td_api.tl | 4 ++-- td/telegram/GroupCallParticipant.cpp | 6 +++++- td/telegram/GroupCallParticipantOrder.cpp | 8 ++++++-- td/telegram/GroupCallParticipantOrder.h | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index c7ed24a2b..f72b2efb2 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2162,8 +2162,8 @@ groupCallJoinResponseStream = GroupCallJoinResponse; //@is_muted_for_current_user True, if the participant is muted for the current user //@can_unmute_self True, if the participant is muted for all users, but can unmute themself //@volume_level Participant's volume level; 1-20000 in hundreds of percents -//@order User's order in the group call participant list. The bigger is order, the higher is user in the list. If order is 0, the user must be removed from the participant list -groupCallParticipant participant:MessageSender source:int32 bio:string is_speaking:Bool is_hand_raised:Bool can_be_muted_for_all_users:Bool can_be_unmuted_for_all_users:Bool can_be_muted_for_current_user:Bool can_be_unmuted_for_current_user:Bool is_muted_for_all_users:Bool is_muted_for_current_user:Bool can_unmute_self:Bool volume_level:int32 order:int64 = GroupCallParticipant; +//@order User's order in the group call participant list. Orders must be compared lexicographically. The bigger is order, the higher is user in the list. If order is empty, the user must be removed from the participant list +groupCallParticipant participant:MessageSender source:int32 bio:string is_speaking:Bool is_hand_raised:Bool can_be_muted_for_all_users:Bool can_be_unmuted_for_all_users:Bool can_be_muted_for_current_user:Bool can_be_unmuted_for_current_user:Bool is_muted_for_all_users:Bool is_muted_for_current_user:Bool can_unmute_self:Bool volume_level:int32 order:string = GroupCallParticipant; //@class CallProblem @description Describes the exact type of a problem with a call diff --git a/td/telegram/GroupCallParticipant.cpp b/td/telegram/GroupCallParticipant.cpp index 69c09d1b5..88231bb72 100644 --- a/td/telegram/GroupCallParticipant.cpp +++ b/td/telegram/GroupCallParticipant.cpp @@ -36,12 +36,16 @@ GroupCallParticipant::GroupCallParticipant(const tl_object_ptractive_date_; } if (joined_date < 0 || active_date < 0) { - LOG(ERROR) << "Receive invalid " << to_string(participant); + LOG(ERROR) << "Receive invalid active_date/joined_date in " << to_string(participant); joined_date = 0; active_date = 0; } if ((participant->flags_ & telegram_api::groupCallParticipant::RAISE_HAND_RATING_MASK) != 0) { raise_hand_rating = participant->raise_hand_rating_; + if (raise_hand_rating < 0) { + LOG(ERROR) << "Receive invalid raise_hand_rating in " << to_string(participant); + raise_hand_rating = 0; + } } } is_just_joined = participant->just_joined_; diff --git a/td/telegram/GroupCallParticipantOrder.cpp b/td/telegram/GroupCallParticipantOrder.cpp index 810d02589..08486c441 100644 --- a/td/telegram/GroupCallParticipantOrder.cpp +++ b/td/telegram/GroupCallParticipantOrder.cpp @@ -6,6 +6,9 @@ // #include "td/telegram/GroupCallParticipantOrder.h" +#include "td/utils/logging.h" +#include "td/utils/misc.h" + #include #include @@ -20,8 +23,9 @@ bool GroupCallParticipantOrder::is_valid() const { return *this != GroupCallParticipantOrder(); } -int64 GroupCallParticipantOrder::get_group_call_participant_order_object() const { - return (static_cast(active_date) << 32) + joined_date; +string GroupCallParticipantOrder::get_group_call_participant_order_object() const { + return PSTRING() << lpad0(to_string(active_date), 10) << lpad0(to_string(raise_hand_rating), 19) + << lpad0(to_string(joined_date), 10); } bool operator==(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) { diff --git a/td/telegram/GroupCallParticipantOrder.h b/td/telegram/GroupCallParticipantOrder.h index abc196132..973974465 100644 --- a/td/telegram/GroupCallParticipantOrder.h +++ b/td/telegram/GroupCallParticipantOrder.h @@ -34,7 +34,7 @@ class GroupCallParticipantOrder { bool is_valid() const; - int64 get_group_call_participant_order_object() const; + string get_group_call_participant_order_object() const; }; bool operator==(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs);