Update API scheme. TODO public forwards stats.

This commit is contained in:
John Preston 2023-12-14 11:10:03 +00:00
parent 4337f0b509
commit f7e2c7977b
4 changed files with 49 additions and 8 deletions
Telegram/SourceFiles

View file

@ -383,11 +383,12 @@ void PublicForwards::requestMessage(
_requestId = makeRequest(MTPstats_GetMessagePublicForwards(
channel()->inputChannel,
MTP_int(_fullId.messageId.msg),
MTP_int(token.rate),
tlOffsetPeer,
MTP_int(token.fullId.msg),
//MTP_int(token.rate),
//tlOffsetPeer,
//MTP_int(token.fullId.msg),
MTP_string(), // offset
kLimit
)).done([=, channel = channel()](const MTPmessages_Messages &result) {
)).done([=, channel = channel()](const MTPstats_PublicForwards &result) {
using Messages = QVector<Data::RecentPostId>;
_requestId = 0;
@ -414,6 +415,8 @@ void PublicForwards::requestMessage(
auto allLoaded = false;
auto fullCount = 0;
auto messages = Messages();
#if 0 // todo
auto messages = result.match([&](const MTPDmessages_messages &data) {
channel->owner().processUsers(data.vusers());
channel->owner().processChats(data.vchats());
@ -447,7 +450,7 @@ void PublicForwards::requestMessage(
allLoaded = true;
return Messages();
});
#endif
_lastTotal = std::max(_lastTotal, fullCount);
done({
.list = std::move(messages),

View file

@ -81,8 +81,11 @@ using UpdateFlag = StoryUpdate::Flag;
}, [](const MTPDgeoPointEmpty &) {
});
}, [&](const MTPDmediaAreaSuggestedReaction &data) {
}, [&](const MTPDmediaAreaChannelPost &data) {
}, [&](const MTPDinputMediaAreaChannelPost &data) {
LOG(("API Error: Unexpected inputMediaAreaChannelPost from API."));
}, [&](const MTPDinputMediaAreaVenue &data) {
LOG(("API Error: Unexpected inputMediaAreaVenue in API data."));
LOG(("API Error: Unexpected inputMediaAreaVenue from API."));
});
return result;
}
@ -99,8 +102,32 @@ using UpdateFlag = StoryUpdate::Flag;
.flipped = data.is_flipped(),
.dark = data.is_dark(),
});
}, [&](const MTPDmediaAreaChannelPost &data) {
}, [&](const MTPDinputMediaAreaChannelPost &data) {
LOG(("API Error: Unexpected inputMediaAreaChannelPost from API."));
}, [&](const MTPDinputMediaAreaVenue &data) {
LOG(("API Error: Unexpected inputMediaAreaVenue in API data."));
LOG(("API Error: Unexpected inputMediaAreaVenue from API."));
});
return result;
}
[[nodiscard]] auto ParseChannelPost(const MTPMediaArea &area)
-> std::optional<ChannelPost> {
auto result = std::optional<ChannelPost>();
area.match([&](const MTPDmediaAreaVenue &data) {
}, [&](const MTPDmediaAreaGeoPoint &data) {
}, [&](const MTPDmediaAreaSuggestedReaction &data) {
}, [&](const MTPDmediaAreaChannelPost &data) {
result.emplace(ChannelPost{
.area = ParseArea(data.vcoordinates()),
.itemId = FullMsgId(
peerFromChannel(data.vchannel_id()),
data.vmsg_id().v),
});
}, [&](const MTPDinputMediaAreaChannelPost &data) {
LOG(("API Error: Unexpected inputMediaAreaChannelPost from API."));
}, [&](const MTPDinputMediaAreaVenue &data) {
LOG(("API Error: Unexpected inputMediaAreaVenue from API."));
});
return result;
}

View file

@ -109,6 +109,15 @@ struct SuggestedReaction {
const SuggestedReaction &) = default;
};
struct ChannelPost {
StoryArea area;
FullMsgId itemId;
friend inline bool operator==(
const ChannelPost &,
const ChannelPost &) = default;
};
class Story final {
public:
Story(

View file

@ -1575,6 +1575,8 @@ mediaAreaVenue#be82db9c coordinates:MediaAreaCoordinates geo:GeoPoint title:stri
inputMediaAreaVenue#b282217f coordinates:MediaAreaCoordinates query_id:long result_id:string = MediaArea;
mediaAreaGeoPoint#df8b3b22 coordinates:MediaAreaCoordinates geo:GeoPoint = MediaArea;
mediaAreaSuggestedReaction#14455871 flags:# dark:flags.0?true flipped:flags.1?true coordinates:MediaAreaCoordinates reaction:Reaction = MediaArea;
mediaAreaChannelPost#770416af coordinates:MediaAreaCoordinates channel_id:long msg_id:int = MediaArea;
inputMediaAreaChannelPost#2271f2bf coordinates:MediaAreaCoordinates channel:InputChannel msg_id:int = MediaArea;
peerStories#9a35e999 flags:# peer:Peer max_read_id:flags.0?int stories:Vector<StoryItem> = PeerStories;
@ -2164,7 +2166,7 @@ folders.editPeerFolders#6847d0ab folder_peers:Vector<InputFolderPeer> = Updates;
stats.getBroadcastStats#ab42441a flags:# dark:flags.0?true channel:InputChannel = stats.BroadcastStats;
stats.loadAsyncGraph#621d5fa0 flags:# token:string x:flags.0?long = StatsGraph;
stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel = stats.MegagroupStats;
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
stats.getMessagePublicForwards#5f150144 channel:InputChannel msg_id:int offset:string limit:int = stats.PublicForwards;
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
stats.getStoryStats#374fef40 flags:# dark:flags.0?true peer:InputPeer id:int = stats.StoryStats;
stats.getStoryPublicForwards#a6437ef6 peer:InputPeer id:int offset:string limit:int = stats.PublicForwards;