From d16bc36bae712091529645eb8efbeb60f05a4263 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 22 Dec 2020 17:48:50 +0400 Subject: [PATCH] Update API scheme. --- Telegram/Resources/tl/api.tl | 4 +- Telegram/SourceFiles/api/api_sending.cpp | 3 +- Telegram/SourceFiles/apiwrap.cpp | 3 +- Telegram/SourceFiles/data/data_group_call.cpp | 60 +++++++------------ Telegram/SourceFiles/data/data_group_call.h | 2 - Telegram/lib_webrtc | 2 +- 6 files changed, 28 insertions(+), 46 deletions(-) diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index 9dd424472..ce5735679 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -63,7 +63,7 @@ inputMediaPhoto#b3ba0635 flags:# id:InputPhoto ttl_seconds:flags.0?int = InputMe inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia; inputMediaContact#f8ab7dfb phone_number:string first_name:string last_name:string vcard:string = InputMedia; inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true force_file:flags.4?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; -inputMediaDocument#23ab23d2 flags:# id:InputDocument ttl_seconds:flags.0?int = InputMedia; +inputMediaDocument#33473058 flags:# id:InputDocument ttl_seconds:flags.0?int query:flags.1?string = InputMedia; inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia; inputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = InputMedia; inputMediaDocumentExternal#fb52dc99 flags:# url:string ttl_seconds:flags.0?int = InputMedia; @@ -1195,7 +1195,7 @@ groupCall#55903081 flags:# join_muted:flags.1?true can_change_join_muted:flags.2 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 just_joined:flags.4?true user_id:int date:int active_date:flags.3?int source:int = GroupCallParticipant; +groupCallParticipant#56b087c9 flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true just_joined:flags.4?true versioned:flags.5?true user_id:int date:int active_date:flags.3?int source:int = GroupCallParticipant; phone.groupCall#66ab0bfc call:GroupCall participants:Vector participants_next_offset:string users:Vector = phone.GroupCall; diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp index e2e370145..967048a39 100644 --- a/Telegram/SourceFiles/api/api_sending.cpp +++ b/Telegram/SourceFiles/api/api_sending.cpp @@ -182,7 +182,8 @@ void SendExistingDocument( return MTP_inputMediaDocument( MTP_flags(0), document->mtpInput(), - MTPint()); + MTPint(), // ttl_seconds + MTPstring()); // query }; SendExistingMedia( std::move(message), diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index fa6e25ac9..f116c33cf 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -4645,7 +4645,8 @@ void ApiWrap::uploadAlbumMedia( fields.vid(), fields.vaccess_hash(), fields.vfile_reference()), - MTP_int(data.vttl_seconds().value_or_empty())); + MTP_int(data.vttl_seconds().value_or_empty()), + MTPstring()); // query sendAlbumWithUploaded(item, groupId, media); } break; } diff --git a/Telegram/SourceFiles/data/data_group_call.cpp b/Telegram/SourceFiles/data/data_group_call.cpp index f74c8007b..22a1a5961 100644 --- a/Telegram/SourceFiles/data/data_group_call.cpp +++ b/Telegram/SourceFiles/data/data_group_call.cpp @@ -312,36 +312,6 @@ void GroupCall::applyParticipantsSlice( } } -void GroupCall::applyParticipantsMutes( - const MTPDupdateGroupCallParticipants &update) { - for (const auto &participant : update.vparticipants().v) { - participant.match([&](const MTPDgroupCallParticipant &data) { - if (data.is_left()) { - return; - } - const auto userId = data.vuser_id().v; - const auto user = _peer->owner().user(userId); - const auto i = ranges::find( - _participants, - user, - &Participant::user); - if (i != end(_participants)) { - const auto was = *i; - i->muted = data.is_muted(); - i->canSelfUnmute = !i->muted || data.is_can_self_unmute(); - if (!i->canSelfUnmute) { - i->speaking = false; - _speakingByActiveFinishes.remove(i->user); - } - _participantUpdates.fire({ - .was = was, - .now = *i, - }); - } - }); - } -} - void GroupCall::applyLastSpoke( uint32 ssrc, LastSpokeTimes when, @@ -563,17 +533,29 @@ bool GroupCall::inCall() const { void GroupCall::applyUpdate(const MTPDupdateGroupCallParticipants &update) { const auto version = update.vversion().v; - if (version < _version) { - return; - } else if (version == _version) { - applyParticipantsMutes(update); - return; - } else if (version != _version + 1) { - applyParticipantsMutes(update); - reload(); + const auto applyUpdate = [&] { + if (version < _version) { + return false; + } + auto versionShouldIncrement = false; + for (const auto &participant : update.vparticipants().v) { + const auto versioned = participant.match([&]( + const MTPDgroupCallParticipant &data) { + return data.is_versioned(); + }); + if (versioned) { + versionShouldIncrement = true; + break; + } + } + return versionShouldIncrement + ? (version == _version + 1) + : (version == _version); + }(); + if (!applyUpdate) { return; } - _version = update.vversion().v; + _version = version; applyUpdateChecked(update); } diff --git a/Telegram/SourceFiles/data/data_group_call.h b/Telegram/SourceFiles/data/data_group_call.h index 3b778f8ec..2aad686a3 100644 --- a/Telegram/SourceFiles/data/data_group_call.h +++ b/Telegram/SourceFiles/data/data_group_call.h @@ -91,8 +91,6 @@ private: void applyParticipantsSlice( const QVector &list, ApplySliceSource sliceSource); - void applyParticipantsMutes( - const MTPDupdateGroupCallParticipants &update); void requestUnknownParticipants(); void changePeerEmptyCallFlag(); void checkFinishSpeakingByActive(); diff --git a/Telegram/lib_webrtc b/Telegram/lib_webrtc index beb63dd9a..4bc51d6f6 160000 --- a/Telegram/lib_webrtc +++ b/Telegram/lib_webrtc @@ -1 +1 @@ -Subproject commit beb63dd9a68662cf96c4b3b165bad3907323ea89 +Subproject commit 4bc51d6f6d5740159fdb51cb1593e80ce149ed4e