From 7f9681313a6fd1755108ea76cbc879a35df4dbc2 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 29 Nov 2020 15:41:03 +0300 Subject: [PATCH] Update layer 122. --- td/generate/scheme/td_api.tl | 10 ++++---- td/generate/scheme/td_api.tlo | Bin 188672 -> 188724 bytes td/generate/scheme/telegram_api.tl | 8 +++--- td/generate/scheme/telegram_api.tlo | Bin 222768 -> 222856 bytes td/telegram/GroupCallManager.cpp | 37 +++++++++++++++++++--------- td/telegram/GroupCallManager.h | 2 +- td/telegram/MessageContent.cpp | 35 +++++++++++++++----------- td/telegram/Td.cpp | 8 ++++-- td/telegram/Td.h | 2 +- td/telegram/UpdatesManager.cpp | 6 +++-- td/telegram/cli.cpp | 6 ++--- test/online.cpp | 1 + 12 files changed, 71 insertions(+), 44 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 01c91f887..a795329de 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1632,8 +1632,8 @@ messageCall is_video:Bool discard_reason:CallDiscardReason duration:int32 = Mess //@description A message with information about a group call @group_call_id Group call identifier @duration Call duration; for finished calls only messageGroupCall group_call_id:string duration:int32 = MessageContent; -//@description A message with information about an invite to a group call @group_call_id Group call identifier @user_id Invited user identifier -messageInviteToGroupCall group_call_id:string user_id:int32 = MessageContent; +//@description A message with information about an invite to a group call @group_call_id Group call identifier @user_ids Invited user identifiers +messageInviteGroupCallMembers group_call_id:string user_ids:vector = MessageContent; //@description A newly created basic group @title Title of the basic group @member_user_ids User identifiers of members in the basic group messageBasicGroupChatCreate title:string member_user_ids:vector = MessageContent; @@ -4320,9 +4320,9 @@ joinGroupCall group_call_id:string payload:groupCallPayload source:int32 is_mute //@group_call_id Group call identifier @mute_new_members New value of the mute_new_members setting toggleGroupCallMuteNewMembers group_call_id:string mute_new_members:Bool = Ok; -//@description Invites a user to a chat group call by sending a service message of type messageInviteToGroupCall -//@group_call_id Group call identifier @user_id User identifier -inviteGroupCallMember group_call_id:string user_id:int32 = Ok; +//@description Invites users to a group call. Sends a service message of type messageInviteToGroupCall for voice chats +//@group_call_id Group call identifier @user_ids User identifiers +inviteGroupCallMembers group_call_id:string user_ids:vector = Ok; //@description Toggles whether a group call member is muted. Requires can_manage_calls rights to mute other group call members //@group_call_id Group call identifier @user_id User identifier @is_muted Pass true if the user must be muted and false otherwise diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 79d7d7ca86343e5632b019950d138b0d997491dc..3b223a468185d054f660db8de15e2e19bcd0f942 100644 GIT binary patch delta 1241 zcmaJ=Ur1A76!+X_%(jOSQrG?SZeHD;yOaB1wa93sVL_I@h{hhAHA0$Yn}$)uj7T8^ z=?Z6%4?ak}_%JZoOAjVtdkQ0i273^a80bTfJuK*M-#xb(xbNxk`lwQls|?!M4BM=FzZsk?vI?Lph6Tb#3~W)Ta@BwXH{cFh1JH+49(c|k!U45 zMr8AogC0NS#r^cqihio#+hLA%TWPP_x*1*V@CYY7P>;g__`y=bGRTK-?U_ttWn>zm zs9{yN@N$j2z@#EUaxfo+IKxUo@~m`_)76d|e=u9r*p*6g*7g+^d8Q+5fsoDZ!NTjt erp-K_7(4j(Fyi2N+zN6MmIk@5?A9!&4F3hzalsM* delta 1233 zcmaJ=J#11@6z)N4sB|C(^~q0ph1VA70~s)(i5g-twGkDgLrpqREm0C`8$j*AfSM>q z6OEVT8e0>F4jmX!YjALAo2D{!sId+t4ww)JTa%g?(}6*F_njx2lsldGoqN9XednIH zu&hllYYP>F`o-_^;+v|WRFfiFI0Pe7L_DWV#Glhq9|v}p8|Oe^(PIv#S)@4(Jd48T z;27Ed*71@^!VJRf$Gy9x@_R$=HfXZ9)s82~vzDU&j>oJ*2zTPv3LEQ^AbJL*}Ob?c_rF zJS~}V0)Z}B1nJ!JFveMg=wcUmgog5lr^fl*wQqDFe&?iiB9cgqU5f;wS0j=~y#+Q{ z^_B%pEb8PzX7uxjg%vEzH>v6%KYyH|x!a(l>jzaj8gs&FI@Jw%#>88(-fx98!&a;~ zi?j`nl9%5tq~Ozd|5uxMz3$*-wZk`VMU#zn^S{hu~^-aq`uDJC6yWZg@4&V zWIa6hK%^l7{OmI;U}E+WTH6tD%zv?w9H84#_koXPQwk<|%Uo2+R@HVKr)UQ+yF6}h)pAa$ShM3?YD$#O zf{BD5>KRkmf$SLvZl2nSRbD4#*u6!>irY@O4h$R>LEL>{IT2m1i6~s{Ld@fW0ArbU zVY_)3#2Ci8aaKV$$||{A{DDRF5fJ9ur6r@UK7yqf`~*p^8K`c;(-~vx#0TersI+g& dww;YkT#3Zn=#vMkfyTDckU^y@>N6_-@*fqJAjALw diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index d40821f2f..8727a318a 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -170,7 +170,7 @@ messageActionSecureValuesSent#d95c6154 types:Vector = MessageAc messageActionContactSignUp#f3f25f76 = MessageAction; messageActionGeoProximityReached#98e0d697 from_id:Peer to_id:Peer distance:int = MessageAction; messageActionGroupCall#7a0d7f42 flags:# call:InputGroupCall duration:flags.0?int = MessageAction; -messageActionInviteToGroupCall#f25f03a call:InputGroupCall user_id:int = MessageAction; +messageActionInviteToGroupCall#76b9f11a call:InputGroupCall users:Vector = MessageAction; dialog#2c171f72 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -1178,7 +1178,7 @@ 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 user_id:int date:int active_date:flags.3?int source:int = GroupCallParticipant; -phone.groupCall#985c2087 call:GroupCall sources:Vector participants:Vector participants_next_offset:string users:Vector = phone.GroupCall; +phone.groupCall#66ab0bfc call:GroupCall participants:Vector participants_next_offset:string users:Vector = phone.GroupCall; phone.groupParticipants#9cfeb92d count:int participants:Vector next_offset:string users:Vector version:int = phone.GroupParticipants; @@ -1540,11 +1540,11 @@ phone.createGroupCall#e428fa02 channel:InputChannel random_id:int = Updates; phone.joinGroupCall#5f9c8e62 flags:# muted:flags.0?true call:InputGroupCall params:DataJSON = Updates; phone.leaveGroupCall#500377f9 call:InputGroupCall source:int = Updates; phone.editGroupCallMember#63146ae4 flags:# muted:flags.0?true call:InputGroupCall user_id:InputUser = Updates; -phone.inviteToGroupCall#dd698f84 call:InputGroupCall user_id:InputUser = Updates; +phone.inviteToGroupCall#7b393160 call:InputGroupCall users:Vector = Updates; phone.discardGroupCall#7a777135 call:InputGroupCall = Updates; phone.toggleGroupCallSettings#74bbb43d flags:# call:InputGroupCall join_muted:flags.0?Bool = Updates; phone.getGroupCall#c7cb017 call:InputGroupCall = phone.GroupCall; -phone.getGroupParticipants#ae1910a4 call:InputGroupCall offset:string limit:int = phone.GroupParticipants; +phone.getGroupParticipants#c9f1d285 call:InputGroupCall ids:Vector sources:Vector offset:string limit:int = phone.GroupParticipants; phone.checkGroupCall#b74a7bea call:InputGroupCall source:int = Bool; langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index 64da7db6c00e07be1f387dcc7815491b9b3fc1f9..91d19eeed1f575026c22336371a5c3537f87ec98 100644 GIT binary patch delta 838 zcmdmRhPUG^?*FZQDVR*z_gRj2aNd7o-_eAS??RMjZ(2fE=R%gf#~)c18v&Hcgh%0Jp&& zvM@s$S{YrS#=*rt0QEw|RDf1+!kouA`C+vBWC2SKh};A@m>CF%e1VGjOlMgr=On;NjC@}d)p2Tz?WyT7K?i0%R!cag3=6?qjm=8-- zU~XFg7rO#yai}t8Kuj)Ch3P1m!)P$wW)hPKMB;-gKChdo!2&f$jj;rxE|bZ09#&?V=>^=(8q?SKFbl9G7+O|O UKj6dcF+Ju8lgD-&U*<0o0FsRnp#T5? delta 836 zcmeA;%e&zW?*-vbVo%-|H%^$K|OFn32M;f1C9pMau@|B|HzY=?xW0D0nvOy8DCfmsKC7M zpaSz?i3-eV3*cf`fGl_rGEFy>X0o2X#+6xQdWH@-V+lmZ6E&FS0_uznBA{pnr7RG*D#sOL^+A &&promise) : promise_(std::move(promise)) { } - void send(InputGroupCallId group_call_id, UserId user_id) { - auto input_user = td->contacts_manager_->get_input_user(user_id); - CHECK(input_user != nullptr); - + void send(InputGroupCallId group_call_id, vector> input_users) { send_query(G()->net_query_creator().create( - telegram_api::phone_inviteToGroupCall(group_call_id.get_input_group_call(), std::move(input_user)))); + telegram_api::phone_inviteToGroupCall(group_call_id.get_input_group_call(), std::move(input_users)))); } void on_result(uint64 id, BufferSlice packet) override { @@ -511,16 +508,32 @@ void GroupCallManager::toggle_group_call_mute_new_members(InputGroupCallId group td_->create_handler(std::move(promise))->send(flags, group_call_id, mute_new_members); } -void GroupCallManager::invite_group_call_member(InputGroupCallId group_call_id, UserId user_id, - Promise &&promise) { - if (!td_->contacts_manager_->have_input_user(user_id)) { - return promise.set_error(Status::Error(400, "Have no access to the user")); +void GroupCallManager::invite_group_call_members(InputGroupCallId group_call_id, vector &&user_ids, + Promise &&promise) { + vector> input_users; + auto my_user_id = td_->contacts_manager_->get_my_id(); + for (auto user_id : user_ids) { + auto input_user = td_->contacts_manager_->get_input_user(user_id); + if (input_user == nullptr) { + return promise.set_error(Status::Error(400, "User not found")); + } + + if (user_id == my_user_id) { + // can't invite self + continue; + } + input_users.push_back(std::move(input_user)); } - td_->create_handler(std::move(promise))->send(group_call_id, user_id); + + if (input_users.empty()) { + return promise.set_value(Unit()); + } + + td_->create_handler(std::move(promise))->send(group_call_id, std::move(input_users)); } -void GroupCallManager::toggle_group_call_member_is_muted(InputGroupCallId group_call_id, UserId user_id, - bool is_muted, Promise &&promise) { +void GroupCallManager::toggle_group_call_member_is_muted(InputGroupCallId group_call_id, UserId user_id, bool is_muted, + Promise &&promise) { if (!td_->contacts_manager_->have_input_user(user_id)) { return promise.set_error(Status::Error(400, "Have no access to the user")); } diff --git a/td/telegram/GroupCallManager.h b/td/telegram/GroupCallManager.h index 40cba05f7..9dc7b946f 100644 --- a/td/telegram/GroupCallManager.h +++ b/td/telegram/GroupCallManager.h @@ -39,7 +39,7 @@ class GroupCallManager : public Actor { void toggle_group_call_mute_new_members(InputGroupCallId group_call_id, bool mute_new_members, Promise &&promise); - void invite_group_call_member(InputGroupCallId group_call_id, UserId user_id, Promise &&promise); + void invite_group_call_members(InputGroupCallId group_call_id, vector &&user_ids, Promise &&promise); void toggle_group_call_member_is_muted(InputGroupCallId group_call_id, UserId user_id, bool is_muted, Promise &&promise); diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 95ef9d25f..7fdff18a5 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -724,11 +724,11 @@ class MessageGroupCall : public MessageContent { class MessageInviteToGroupCall : public MessageContent { public: InputGroupCallId group_call_id; - UserId user_id; + vector user_ids; MessageInviteToGroupCall() = default; - MessageInviteToGroupCall(InputGroupCallId group_call_id, UserId user_id) - : group_call_id(group_call_id), user_id(user_id) { + MessageInviteToGroupCall(InputGroupCallId group_call_id, vector &&user_ids) + : group_call_id(group_call_id), user_ids(std::move(user_ids)) { } MessageContentType get_type() const override { @@ -1023,7 +1023,7 @@ static void store(const MessageContent *content, StorerT &storer) { case MessageContentType::InviteToGroupCall: { auto m = static_cast(content); store(m->group_call_id, storer); - store(m->user_id, storer); + store(m->user_ids, storer); break; } default: @@ -1416,7 +1416,7 @@ static void parse(unique_ptr &content, ParserT &parser) { case MessageContentType::InviteToGroupCall: { auto m = make_unique(); parse(m->group_call_id, parser); - parse(m->user_id, parser); + parse(m->user_ids, parser); content = std::move(m); break; } @@ -3311,7 +3311,7 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo case MessageContentType::InviteToGroupCall: { auto old_ = static_cast(old_content); auto new_ = static_cast(new_content); - if (old_->group_call_id != new_->group_call_id || old_->user_id != new_->user_id) { + if (old_->group_call_id != new_->group_call_id || old_->user_ids != new_->user_ids) { need_update = true; } if (!old_->group_call_id.is_identical(new_->group_call_id)) { @@ -4557,13 +4557,20 @@ unique_ptr get_action_message_content(Td *td, tl_object_ptr(action); - UserId user_id(invite_to_group_call->user_id_); - if (!user_id.is_valid()) { - LOG(ERROR) << "Receive messageActionInviteToGroupCall with invalid " << user_id << " in " << owner_dialog_id; - break; + + vector user_ids; + user_ids.reserve(invite_to_group_call->users_.size()); + for (auto &user : invite_to_group_call->users_) { + UserId user_id(user); + if (user_id.is_valid()) { + user_ids.push_back(user_id); + } else { + LOG(ERROR) << "Receive messageActionInviteToGroupCall with invalid " << user_id << " in " << owner_dialog_id; + } } - return make_unique(InputGroupCallId(invite_to_group_call->call_), user_id); + return td::make_unique(InputGroupCallId(invite_to_group_call->call_), + std::move(user_ids)); } default: UNREACHABLE(); @@ -4781,9 +4788,9 @@ tl_object_ptr get_message_content_object(const MessageCo } case MessageContentType::InviteToGroupCall: { auto *m = static_cast(content); - return make_tl_object( + return make_tl_object( m->group_call_id.get_group_call_id(), - td->contacts_manager_->get_user_id_object(m->user_id, "MessageInviteToGroupCall")); + td->contacts_manager_->get_user_ids_object(m->user_ids, "MessageInviteToGroupCall")); } default: UNREACHABLE(); @@ -5302,7 +5309,7 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC break; case MessageContentType::InviteToGroupCall: { auto content = static_cast(message_content); - dependencies.user_ids.insert(content->user_id); + dependencies.user_ids.insert(content->user_ids.begin(), content->user_ids.end()); break; } default: diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index c63987551..5e13eeb6e 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6058,12 +6058,16 @@ void Td::on_request(uint64 id, const td_api::toggleGroupCallMuteNewMembers &requ group_call_manager_->toggle_group_call_mute_new_members(group_call_id, request.mute_new_members_, std::move(promise)); } -void Td::on_request(uint64 id, const td_api::inviteGroupCallMember &request) { +void Td::on_request(uint64 id, const td_api::inviteGroupCallMembers &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); TRY_RESULT_PROMISE(promise, group_call_id, InputGroupCallId::from_group_call_id(request.group_call_id_)); - group_call_manager_->invite_group_call_member(group_call_id, UserId(request.user_id_), std::move(promise)); + vector user_ids; + for (auto &user_id : request.user_ids_) { + user_ids.emplace_back(user_id); + } + group_call_manager_->invite_group_call_members(group_call_id, std::move(user_ids), std::move(promise)); } void Td::on_request(uint64 id, const td_api::toggleGroupCallMemberIsMuted &request) { diff --git a/td/telegram/Td.h b/td/telegram/Td.h index b8d201fcc..7348c7a3a 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -698,7 +698,7 @@ class Td final : public NetQueryCallback { void on_request(uint64 id, const td_api::toggleGroupCallMuteNewMembers &request); - void on_request(uint64 id, const td_api::inviteGroupCallMember &request); + void on_request(uint64 id, const td_api::inviteGroupCallMembers &request); void on_request(uint64 id, const td_api::toggleGroupCallMemberIsMuted &request); diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 4448118f4..8b61fe39c 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -618,8 +618,10 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_ } case telegram_api::messageActionInviteToGroupCall::ID: { auto invite_to_group_call = static_cast(action); - if (!is_acceptable_user(UserId(invite_to_group_call->user_id_))) { - return false; + for (auto &user : invite_to_group_call->users_) { + if (!is_acceptable_user(UserId(user))) { + return false; + } } break; } diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 22b7c8fd1..8c9cfc4ef 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2853,10 +2853,10 @@ class CliClient final : public Actor { send_request(td_api::make_object(as_group_call_id(args), op == "tgcmnme")); } else if (op == "igcm") { string group_call_id; - string user_id; - std::tie(group_call_id, user_id) = split(args); + string user_ids; + std::tie(group_call_id, user_ids) = split(args); send_request( - td_api::make_object(as_group_call_id(group_call_id), as_user_id(user_id))); + td_api::make_object(as_group_call_id(group_call_id), as_user_ids(user_ids))); } else if (op == "tgcmim") { string group_call_id; string user_id; diff --git a/test/online.cpp b/test/online.cpp index 308673e23..5f74451ec 100644 --- a/test/online.cpp +++ b/test/online.cpp @@ -12,6 +12,7 @@ #include "td/utils/misc.h" #include "td/utils/Random.h" #include "td/actor/actor.h" +#include "td/actor/ConcurrentScheduler.h" #include "td/actor/PromiseFuture.h" #include "td/actor/MultiPromise.h" #include "td/telegram/td_api_json.h"