From 96acefc6c6fb6871ecaefdb5280bf0c46a2e25a2 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 14 Dec 2020 16:52:25 +0300 Subject: [PATCH] Update layer 122. --- td/generate/scheme/telegram_api.tl | 11 ++++++----- td/generate/scheme/telegram_api.tlo | Bin 224064 -> 224296 bytes td/telegram/GroupCallManager.cpp | 17 +++++++++++++---- td/telegram/StickersManager.cpp | 4 ++-- td/telegram/UpdatesManager.cpp | 14 ++++++++++++-- td/telegram/UpdatesManager.h | 10 ++++++---- 6 files changed, 39 insertions(+), 17 deletions(-) diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 26dc4dbb8..bc3a06eca 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -109,12 +109,12 @@ userStatusLastWeek#7bf09fc = UserStatus; userStatusLastMonth#77ebc742 = UserStatus; chatEmpty#9ba2d800 id:int = Chat; -chat#3bda1bde flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; +chat#3bda1bde flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true deactivated:flags.5?true call_active:flags.23?true call_not_empty:flags.24?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; chatForbidden#7328bdb id:int title:string = Chat; channel#d31a961e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat; channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat; -chatFull#1b7c9db3 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int = ChatFull; +chatFull#dc8c181 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall = ChatFull; channelFull#ef3a6acd flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall = ChatFull; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; @@ -352,8 +352,9 @@ updatePeerBlocked#246a4b22 peer_id:Peer blocked:Bool = Update; updateChannelUserTyping#ff2abe9f flags:# channel_id:int top_msg_id:flags.0?int user_id:int action:SendMessageAction = Update; updatePinnedMessages#ed85eab5 flags:# pinned:flags.0?true peer:Peer messages:Vector pts:int pts_count:int = Update; updatePinnedChannelMessages#8588878b flags:# pinned:flags.0?true channel_id:int messages:Vector pts:int pts_count:int = Update; +updateChat#1330a196 chat_id:int = Update; updateGroupCallParticipants#f2ebdb4e call:InputGroupCall participants:Vector version:int = Update; -updateGroupCall#5724806e channel_id:int call:GroupCall = Update; +updateGroupCall#a45eb99b chat_id:int call:GroupCall = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -534,7 +535,7 @@ inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet; inputStickerSetAnimatedEmoji#28703c8 = InputStickerSet; inputStickerSetDice#e67f520e emoticon:string = InputStickerSet; -stickerSet#eeb46f27 flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumb:flags.4?PhotoSize thumb_dc_id:flags.4?int count:int hash:int = StickerSet; +stickerSet#40e237a8 flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector thumb_dc_id:flags.4?int count:int hash:int = StickerSet; messages.stickerSet#b60a24a6 set:StickerSet packs:Vector documents:Vector = messages.StickerSet; @@ -1547,7 +1548,7 @@ phone.discardCall#b2cbc1c0 flags:# video:flags.0?true peer:InputPhoneCall durati phone.setCallRating#59ead627 flags:# user_initiative:flags.0?true peer:InputPhoneCall rating:int comment:string = Updates; phone.saveCallDebug#277add7e peer:InputPhoneCall debug:DataJSON = Bool; phone.sendSignalingData#ff7a9383 peer:InputPhoneCall data:bytes = Bool; -phone.createGroupCall#e428fa02 channel:InputChannel random_id:int = Updates; +phone.createGroupCall#bd3dabe0 peer:InputPeer 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; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index 4c470231e2d94df8fb0646eaa0d6495aa985843c..d8a062fd16f66399b586657cb76eebe78bada80a 100644 GIT binary patch delta 2704 zcmaJ@Z)j6j6wi4{HA=$bR;0{0BW7EmalC@CI4X-+r_6M#*s*@-wn$r7XJAoNS6Buq zI>`qemFqlZi(s)I3Mv#LMCZm*TH9!&R{JM${)@HRKgKrIwstabFYmsSWCQy?opO~zNV}nSyXT`imy5M8To!E7lq}b@zCUCSCRQE={XdiU zzgzH`yL!8)MpY4PSk;jayMr5TFIO|q+V|K8JKteVJG{)ct3D`xeN>m<&>qois}wwy zN|nZEWk*DIdf%ep5>FqXZz1I2nHR8-xxHGZJFI24&+|31U8>F~3qixaxF#B{fgNX4c zr1(Pg3W21qfRpRWuPQp0`ofAQxzy_BHyIt88W1LF-!(B2?o+bo#V zAR0VzgJ_Q2Af!X9U=7DK_ff>z&g;zRQhku*b_ppJE*S>kG?&5yq)QD@WYvQ?#nSL% zB?hSo))<&Gr3BVKxC}ip$mei}Vwq6ZLJ^L|;48l1h=aL+8df^Zs{gdBKMtl>uZH6U zDpjNim*0dK2c5e~w3z;a+p_N1Ey^d$MawP4Kh%2*Y`}eWcgQzu*m{ThTHZ*17eQ!%IK0eMS=HoIYA@iuEDvRj2 z57qql?0pK<5D}U0hyi_|ElcjDd-q%`q`SG#5Z<#0~}MEqSVBcbVJH_(&1Eazob~l_}Q{9sSa*ms-?oPIHwWkm+yWt;Lncn#DI3*U8VO^y^9`bD6z?oBqxj z)@p1ngm=-uS13mD1(;X=AMDrjU$(r)!8Yyrw$8m_yUUffNk1b5w)>PN{hs2Fk5K;$ zXw8#@{@Ew^dGz)wVLg_Dpv*=3-4==pg7IVi5=uIRxLST=VQQODAF^*14lGsPVC$=e z4>9=(tif=Npv4nQ)rL@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ZVKxR6L~}8+fXGv^42t_0x+f?1yS@>mRpiJJC5nFU2!J;PTm` z6PpJ}vfTqD4=Gm})Wk+JXL1cvM2*Qm2>IL*8`LYQ9U?^55Rt1`Z8c_W5f^iOKygkz z&izC5rYs4l%#bW-1tR&AxKB9xkdB3gZq8Aho#-EPO~QIb*R*gFzDyFpxnu`wvJtCZReNcpE;y~=#H&1w6z zo88(yyZ6aCTRk2Xqv^rn023DO6;d$p2DrFG;Wtp9oUGBX^erEvD_JmMJqY?IUlN5H ztP+G8E%}i0Gw@lmcJ0DN{|F01BkP1lQM<#10vm+4bNTfvP%5O%=O-eEgf3n7(vN~S qWI8P9pXZSB+tO+f#_Vy-UN745*E52Io=wWf!hc1ugu?4ZPsV@2d6E?X diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index 38c7efa3d..3c41d1ffb 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -33,11 +33,11 @@ class CreateGroupCallQuery : public Td::ResultHandler { void send(DialogId dialog_id) { dialog_id_ = dialog_id; - auto input_channel = td->contacts_manager_->get_input_channel(dialog_id.get_channel_id()); - CHECK(input_channel != nullptr); + auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create( - telegram_api::phone_createGroupCall(std::move(input_channel), Random::secure_int32()))); + telegram_api::phone_createGroupCall(std::move(input_peer), Random::secure_int32()))); } void on_result(uint64 id, BufferSlice packet) override { @@ -597,8 +597,18 @@ void GroupCallManager::create_voice_chat(DialogId dialog_id, Promisemessages_manager_->have_dialog_force(dialog_id)) { return promise.set_error(Status::Error(400, "Chat not found")); } + if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) { + return promise.set_error(Status::Error(400, "Can't access chat")); + } switch (dialog_id.get_type()) { + case DialogType::Chat: { + auto chat_id = dialog_id.get_chat_id(); + if (!td_->contacts_manager_->get_chat_permissions(chat_id).can_manage_calls()) { + return promise.set_error(Status::Error(400, "Not enough rights in the chat")); + } + break; + } case DialogType::Channel: { auto channel_id = dialog_id.get_channel_id(); switch (td_->contacts_manager_->get_channel_type(channel_id)) { @@ -618,7 +628,6 @@ void GroupCallManager::create_voice_chat(DialogId dialog_id, Promisethumb_ != nullptr) { + for (auto &thumb : set->thumbs_) { auto photo_size = get_photo_size(td_->file_manager_.get(), {set_id.get(), s->access_hash}, 0, 0, "", - DcId::create(set->thumb_dc_id_), DialogId(), std::move(set->thumb_), + DcId::create(set->thumb_dc_id_), DialogId(), std::move(thumb), is_animated ? PhotoFormat::Tgs : PhotoFormat::Webp, false); if (photo_size.get_offset() == 0) { if (!thumbnail.file_id.is_valid()) { diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 7425b174f..c44cddab4 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -1704,6 +1704,10 @@ void UpdatesManager::on_update(tl_object_ptrmessages_manager_->on_update_service_notification(std::move(update), true, Promise()); } +void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { + // nothing to do +} + void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { CHECK(update != nullptr); td_->messages_manager_->on_update_read_channel_inbox(std::move(update)); @@ -2148,8 +2152,14 @@ void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { - send_closure(G()->group_call_manager(), &GroupCallManager::on_update_group_call, std::move(update->call_), - DialogId(ChannelId(update->channel_id_))); + DialogId dialog_id(ChatId(update->chat_id_)); + if (!td_->messages_manager_->have_dialog(dialog_id)) { + dialog_id = DialogId(ChannelId(update->chat_id_)); + if (!td_->messages_manager_->have_dialog(dialog_id)) { + dialog_id = DialogId(); + } + } + send_closure(G()->group_call_manager(), &GroupCallManager::on_update_group_call, std::move(update->call_), dialog_id); } void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index 36ac2de72..05fd0782a 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -238,6 +238,8 @@ class UpdatesManager : public Actor { void on_update(tl_object_ptr update, bool /*force_apply*/); + void on_update(tl_object_ptr update, bool /*force_apply*/); + void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool /*force_apply*/); @@ -245,16 +247,16 @@ class UpdatesManager : public Actor { void on_update(tl_object_ptr update, bool force_apply); void on_update(tl_object_ptr update, bool force_apply); void on_update(tl_object_ptr update, bool /*force_apply*/); - void on_update(tl_object_ptr update, bool force_apply); - void on_update(tl_object_ptr update, bool force_apply); - void on_update(tl_object_ptr update, bool force_apply); + void on_update(tl_object_ptr update, bool /*force_apply*/); + void on_update(tl_object_ptr update, bool /*force_apply*/); + void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool force_apply); - void on_update(tl_object_ptr update, bool force_apply); + void on_update(tl_object_ptr update, bool /*force_apply*/); void on_update(tl_object_ptr update, bool /*force_apply*/);