mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Update API scheme on layer 160.
Leave plain scheme in api.tl.
This commit is contained in:
parent
41edd41b92
commit
17a5c27658
7 changed files with 63 additions and 78 deletions
|
@ -2520,8 +2520,8 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
_session->api().transcribes().apply(data);
|
_session->api().transcribes().apply(data);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateStories: {
|
case mtpc_updateStory: {
|
||||||
_session->data().stories().apply(update.c_updateStories());
|
_session->data().stories().apply(update.c_updateStory());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,8 +276,29 @@ Main::Session &Stories::session() const {
|
||||||
return _owner->session();
|
return _owner->session();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stories::apply(const MTPDupdateStories &data) {
|
void Stories::apply(const MTPDupdateStory &data) {
|
||||||
applyChanges(parse(data.vstories()));
|
const auto peerId = peerFromUser(data.vuser_id());
|
||||||
|
const auto peer = _owner->peer(peerId);
|
||||||
|
const auto i = ranges::find(_all, peer, &StoriesList::user);
|
||||||
|
const auto id = parseAndApply(peer, data.vstory());
|
||||||
|
if (i != end(_all)) {
|
||||||
|
auto added = false;
|
||||||
|
if (id && !i->ids.contains(id)) {
|
||||||
|
i->ids.emplace(id);
|
||||||
|
++i->total;
|
||||||
|
added = true;
|
||||||
|
}
|
||||||
|
if (added) {
|
||||||
|
ranges::rotate(begin(_all), i, i + 1);
|
||||||
|
}
|
||||||
|
} else if (id) {
|
||||||
|
_all.insert(begin(_all), StoriesList{
|
||||||
|
.user = peer->asUser(),
|
||||||
|
.ids = { id },
|
||||||
|
.readTill = 0,
|
||||||
|
.total = 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
_allChanged.fire({});
|
_allChanged.fire({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,19 +315,11 @@ StoriesList Stories::parse(const MTPUserStories &stories) {
|
||||||
const auto &list = data.vstories().v;
|
const auto &list = data.vstories().v;
|
||||||
result.ids.reserve(list.size());
|
result.ids.reserve(list.size());
|
||||||
for (const auto &story : list) {
|
for (const auto &story : list) {
|
||||||
story.match([&](const MTPDstoryItem &data) {
|
if (const auto id = parseAndApply(result.user, story)) {
|
||||||
if (const auto story = parseAndApply(result.user, data)) {
|
result.ids.emplace(id);
|
||||||
result.ids.emplace(story->id());
|
} else {
|
||||||
} else {
|
|
||||||
applyDeleted({ peerFromUser(userId), data.vid().v });
|
|
||||||
--result.total;
|
|
||||||
}
|
|
||||||
}, [&](const MTPDstoryItemSkipped &data) {
|
|
||||||
result.ids.emplace(data.vid().v);
|
|
||||||
}, [&](const MTPDstoryItemDeleted &data) {
|
|
||||||
applyDeleted({ peerFromUser(userId), data.vid().v });
|
|
||||||
--result.total;
|
--result.total;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
result.total = std::max(result.total, int(result.ids.size()));
|
result.total = std::max(result.total, int(result.ids.size()));
|
||||||
return result;
|
return result;
|
||||||
|
@ -339,6 +352,23 @@ Story *Stories::parseAndApply(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StoryId Stories::parseAndApply(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const MTPstoryItem &story) {
|
||||||
|
return story.match([&](const MTPDstoryItem &data) {
|
||||||
|
if (const auto story = parseAndApply(peer, data)) {
|
||||||
|
return story->id();
|
||||||
|
}
|
||||||
|
applyDeleted({ peer->id, data.vid().v });
|
||||||
|
return StoryId();
|
||||||
|
}, [&](const MTPDstoryItemSkipped &data) {
|
||||||
|
return StoryId(data.vid().v);
|
||||||
|
}, [&](const MTPDstoryItemDeleted &data) {
|
||||||
|
applyDeleted({ peer->id, data.vid().v });
|
||||||
|
return StoryId();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Stories::updateDependentMessages(not_null<Data::Story*> story) {
|
void Stories::updateDependentMessages(not_null<Data::Story*> story) {
|
||||||
const auto i = _dependentMessages.find(story);
|
const auto i = _dependentMessages.find(story);
|
||||||
if (i != end(_dependentMessages)) {
|
if (i != end(_dependentMessages)) {
|
||||||
|
@ -603,25 +633,6 @@ void Stories::pushToBack(StoriesList &&list) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stories::applyChanges(StoriesList &&list) {
|
|
||||||
const auto i = ranges::find(_all, list.user, &StoriesList::user);
|
|
||||||
if (i != end(_all)) {
|
|
||||||
auto added = false;
|
|
||||||
for (const auto id : list.ids) {
|
|
||||||
if (!i->ids.contains(id)) {
|
|
||||||
i->ids.emplace(id);
|
|
||||||
++i->total;
|
|
||||||
added = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (added) {
|
|
||||||
ranges::rotate(begin(_all), i, i + 1);
|
|
||||||
}
|
|
||||||
} else if (!list.ids.empty()) {
|
|
||||||
_all.insert(begin(_all), std::move(list));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stories::loadAround(FullStoryId id) {
|
void Stories::loadAround(FullStoryId id) {
|
||||||
const auto i = ranges::find(_all, id.peer, [](const StoriesList &list) {
|
const auto i = ranges::find(_all, id.peer, [](const StoriesList &list) {
|
||||||
return list.user->id;
|
return list.user->id;
|
||||||
|
|
|
@ -122,7 +122,7 @@ public:
|
||||||
not_null<Data::Story*> dependency);
|
not_null<Data::Story*> dependency);
|
||||||
|
|
||||||
void loadMore();
|
void loadMore();
|
||||||
void apply(const MTPDupdateStories &data);
|
void apply(const MTPDupdateStory &data);
|
||||||
void loadAround(FullStoryId id);
|
void loadAround(FullStoryId id);
|
||||||
|
|
||||||
[[nodiscard]] const std::vector<StoriesList> &all();
|
[[nodiscard]] const std::vector<StoriesList> &all();
|
||||||
|
@ -148,6 +148,9 @@ private:
|
||||||
[[nodiscard]] Story *parseAndApply(
|
[[nodiscard]] Story *parseAndApply(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const MTPDstoryItem &data);
|
const MTPDstoryItem &data);
|
||||||
|
StoryId parseAndApply(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const MTPstoryItem &story);
|
||||||
void processResolvedStories(
|
void processResolvedStories(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const QVector<MTPStoryItem> &list);
|
const QVector<MTPStoryItem> &list);
|
||||||
|
@ -155,7 +158,6 @@ private:
|
||||||
void finalizeResolve(FullStoryId id);
|
void finalizeResolve(FullStoryId id);
|
||||||
|
|
||||||
void pushToBack(StoriesList &&list);
|
void pushToBack(StoriesList &&list);
|
||||||
void applyChanges(StoriesList &&list);
|
|
||||||
void applyDeleted(FullStoryId id);
|
void applyDeleted(FullStoryId id);
|
||||||
void removeDependencyStory(not_null<Story*> story);
|
void removeDependencyStory(not_null<Story*> story);
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,3 @@
|
||||||
///////////////////////////////
|
|
||||||
/////////////////// Layer cons
|
|
||||||
///////////////////////////////
|
|
||||||
|
|
||||||
//invokeAfterMsg#cb9f372d msg_id:long query:!X = X;
|
|
||||||
//invokeAfterMsgs#3dc4b4f0 msg_ids:Vector<long> query:!X = X;
|
|
||||||
//invokeWithLayer1#53835315 query:!X = X;
|
|
||||||
//invokeWithLayer2#289dd1f6 query:!X = X;
|
|
||||||
//invokeWithLayer3#b7475268 query:!X = X;
|
|
||||||
//invokeWithLayer4#dea0d430 query:!X = X;
|
|
||||||
//invokeWithLayer5#417a57ae query:!X = X;
|
|
||||||
//invokeWithLayer6#3a64d54d query:!X = X;
|
|
||||||
//invokeWithLayer7#a5be56d3 query:!X = X;
|
|
||||||
//invokeWithLayer8#e9abd9fd query:!X = X;
|
|
||||||
//invokeWithLayer9#76715a63 query:!X = X;
|
|
||||||
//invokeWithLayer10#39620c41 query:!X = X;
|
|
||||||
//invokeWithLayer11#a6b88fdf query:!X = X;
|
|
||||||
//invokeWithLayer12#dda60d3c query:!X = X;
|
|
||||||
//invokeWithLayer13#427c8ea2 query:!X = X;
|
|
||||||
//invokeWithLayer14#2b9b08fa query:!X = X;
|
|
||||||
//invokeWithLayer15#b4418b64 query:!X = X;
|
|
||||||
//invokeWithLayer16#cf5f0987 query:!X = X;
|
|
||||||
//invokeWithLayer17#50858a19 query:!X = X;
|
|
||||||
//invokeWithLayer18#1c900537 query:!X = X;
|
|
||||||
//invokeWithLayer#da9b0d0d layer:int query:!X = X; // after 18 layer
|
|
||||||
|
|
||||||
///////////////////////////////
|
|
||||||
///////// Main application API
|
|
||||||
///////////////////////////////
|
|
||||||
|
|
||||||
boolFalse#bc799737 = Bool;
|
boolFalse#bc799737 = Bool;
|
||||||
boolTrue#997275b5 = Bool;
|
boolTrue#997275b5 = Bool;
|
||||||
|
|
||||||
|
@ -110,7 +80,7 @@ storage.fileMp4#b3cea0e4 = storage.FileType;
|
||||||
storage.fileWebp#1081464c = storage.FileType;
|
storage.fileWebp#1081464c = storage.FileType;
|
||||||
|
|
||||||
userEmpty#d3bc4b7a id:long = User;
|
userEmpty#d3bc4b7a id:long = User;
|
||||||
user#8f97c628 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_available:flags2.3?true stories_unavailable:flags2.4?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus usernames:flags2.0?Vector<Username> = User;
|
user#8f97c628 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_available:flags2.3?true stories_unavailable:flags2.4?true stories_hidden:flags2.5?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus usernames:flags2.0?Vector<Username> = User;
|
||||||
|
|
||||||
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
|
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
|
||||||
userProfilePhoto#82d1f706 flags:# has_video:flags.0?true personal:flags.2?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto;
|
userProfilePhoto#82d1f706 flags:# has_video:flags.0?true personal:flags.2?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto;
|
||||||
|
@ -410,7 +380,7 @@ updateChannelPinnedTopics#fe198602 flags:# channel_id:long order:flags.0?Vector<
|
||||||
updateUser#20529438 user_id:long = Update;
|
updateUser#20529438 user_id:long = Update;
|
||||||
updateAutoSaveSettings#ec05b097 = Update;
|
updateAutoSaveSettings#ec05b097 = Update;
|
||||||
updateGroupInvitePrivacyForbidden#ccf08ad6 user_id:long = Update;
|
updateGroupInvitePrivacyForbidden#ccf08ad6 user_id:long = Update;
|
||||||
updateStories#66fad7b5 stories:UserStories = Update;
|
updateStory#205a4133 user_id:long story:StoryItem = Update;
|
||||||
updateReadStories#feb5345a user_id:long max_id:int = Update;
|
updateReadStories#feb5345a user_id:long max_id:int = Update;
|
||||||
updateStoryID#1bf335b9 id:int random_id:long = Update;
|
updateStoryID#1bf335b9 id:int random_id:long = Update;
|
||||||
|
|
||||||
|
@ -1557,7 +1527,7 @@ storyViews#d36760cf flags:# views_count:int recent_viewers:flags.0?Vector<long>
|
||||||
|
|
||||||
storyItemDeleted#51e6ee4f id:int = StoryItem;
|
storyItemDeleted#51e6ee4f id:int = StoryItem;
|
||||||
storyItemSkipped#a1d8cf8f id:int date:int = StoryItem;
|
storyItemSkipped#a1d8cf8f id:int date:int = StoryItem;
|
||||||
storyItem#8fcd96ac flags:# pinned:flags.5?true expired:flags.6?true public:flags.7?true id:int date:int caption:flags.0?string entities:flags.1?Vector<MessageEntity> media:MessageMedia privacy:flags.2?Vector<PrivacyRule> views:flags.3?StoryViews = StoryItem;
|
storyItem#8fcd96ac flags:# pinned:flags.5?true expired:flags.6?true id:int date:int caption:flags.0?string entities:flags.1?Vector<MessageEntity> media:MessageMedia privacy:flags.2?Vector<PrivacyRule> views:flags.3?StoryViews = StoryItem;
|
||||||
|
|
||||||
userStories#8611a200 flags:# user_id:long max_read_id:flags.0?int stories:Vector<StoryItem> = UserStories;
|
userStories#8611a200 flags:# user_id:long max_read_id:flags.0?int stories:Vector<StoryItem> = UserStories;
|
||||||
|
|
||||||
|
@ -1727,6 +1697,7 @@ contacts.resolvePhone#8af94344 phone:string = contacts.ResolvedPeer;
|
||||||
contacts.exportContactToken#f8654027 = ExportedContactToken;
|
contacts.exportContactToken#f8654027 = ExportedContactToken;
|
||||||
contacts.importContactToken#13005788 token:string = User;
|
contacts.importContactToken#13005788 token:string = User;
|
||||||
contacts.editCloseFriends#ba6705f0 id:Vector<long> = Bool;
|
contacts.editCloseFriends#ba6705f0 id:Vector<long> = Bool;
|
||||||
|
contacts.toggleStoriesHidden#753fb865 id:InputUser hidden:Bool = Bool;
|
||||||
|
|
||||||
messages.getMessages#63c66506 id:Vector<InputMessage> = messages.Messages;
|
messages.getMessages#63c66506 id:Vector<InputMessage> = messages.Messages;
|
||||||
messages.getDialogs#a0f4cb4f flags:# exclude_pinned:flags.0?true folder_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:long = messages.Dialogs;
|
messages.getDialogs#a0f4cb4f flags:# exclude_pinned:flags.0?true folder_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:long = messages.Dialogs;
|
||||||
|
@ -2115,7 +2086,7 @@ stories.sendStory#8b5c6986 flags:# pinned:flags.2?true media:InputMedia caption:
|
||||||
stories.editStory#2aae7a41 flags:# id:int media:flags.0?InputMedia caption:flags.1?string entities:flags.1?Vector<MessageEntity> privacy_rules:flags.2?Vector<InputPrivacyRule> = Updates;
|
stories.editStory#2aae7a41 flags:# id:int media:flags.0?InputMedia caption:flags.1?string entities:flags.1?Vector<MessageEntity> privacy_rules:flags.2?Vector<InputPrivacyRule> = Updates;
|
||||||
stories.deleteStories#b5d501d7 id:Vector<int> = Vector<int>;
|
stories.deleteStories#b5d501d7 id:Vector<int> = Vector<int>;
|
||||||
stories.togglePinned#51602944 id:Vector<int> pinned:Bool = Vector<int>;
|
stories.togglePinned#51602944 id:Vector<int> pinned:Bool = Vector<int>;
|
||||||
stories.getAllStories#eeb0d625 flags:# next:flags.1?true state:flags.0?string = stories.AllStories;
|
stories.getAllStories#eeb0d625 flags:# next:flags.1?true include_hidden:flags.2?true state:flags.0?string = stories.AllStories;
|
||||||
stories.getUserStories#96d528e0 user_id:InputUser = stories.UserStories;
|
stories.getUserStories#96d528e0 user_id:InputUser = stories.UserStories;
|
||||||
stories.getPinnedStories#b471137 user_id:InputUser offset_id:int limit:int = stories.Stories;
|
stories.getPinnedStories#b471137 user_id:InputUser offset_id:int limit:int = stories.Stories;
|
||||||
stories.getExpiredStories#8f792f2 offset_id:int limit:int = stories.Stories;
|
stories.getExpiredStories#8f792f2 offset_id:int limit:int = stories.Stories;
|
||||||
|
@ -2124,5 +2095,3 @@ stories.readStories#edc5105b user_id:InputUser max_id:int = Vector<int>;
|
||||||
stories.incrementStoryViews#22126127 user_id:InputUser id:Vector<int> = Bool;
|
stories.incrementStoryViews#22126127 user_id:InputUser id:Vector<int> = Bool;
|
||||||
stories.getStoryViewsList#4b3b5e97 id:int offset_date:int offset_id:long limit:int = stories.StoryViewsList;
|
stories.getStoryViewsList#4b3b5e97 id:int offset_date:int offset_id:long limit:int = stories.StoryViewsList;
|
||||||
stories.getStoriesViews#9a75d6a6 id:Vector<int> = stories.StoryViews;
|
stories.getStoriesViews#9a75d6a6 id:Vector<int> = stories.StoryViews;
|
||||||
|
|
||||||
// LAYER 160
|
|
1
Telegram/SourceFiles/mtproto/scheme/layer.tl
Normal file
1
Telegram/SourceFiles/mtproto/scheme/layer.tl
Normal file
|
@ -0,0 +1 @@
|
||||||
|
// LAYER 160
|
|
@ -11,16 +11,18 @@ add_library(tdesktop::td_scheme ALIAS td_scheme)
|
||||||
include(cmake/generate_scheme.cmake)
|
include(cmake/generate_scheme.cmake)
|
||||||
|
|
||||||
set(scheme_files
|
set(scheme_files
|
||||||
${res_loc}/tl/mtproto.tl
|
${src_loc}/mtproto/scheme/api.tl
|
||||||
${res_loc}/tl/api.tl
|
${src_loc}/mtproto/scheme/layer.tl
|
||||||
|
${src_loc}/mtproto/scheme/mtproto.tl
|
||||||
)
|
)
|
||||||
|
|
||||||
generate_scheme(td_scheme ${src_loc}/codegen/scheme/codegen_scheme.py "${scheme_files}")
|
generate_scheme(td_scheme ${src_loc}/codegen/scheme/codegen_scheme.py "${scheme_files}")
|
||||||
|
|
||||||
nice_target_sources(td_scheme ${res_loc}
|
nice_target_sources(td_scheme ${src_loc}/mtproto/scheme
|
||||||
PRIVATE
|
PRIVATE
|
||||||
tl/mtproto.tl
|
api.tl
|
||||||
tl/api.tl
|
layer.tl
|
||||||
|
mtproto.tl
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(td_scheme
|
target_include_directories(td_scheme
|
||||||
|
|
Loading…
Add table
Reference in a new issue