mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/telegramdesktop/tdesktop
synced 2026-09-21 00:23:56 +08:00
Update API scheme. Show interactions in channel stories.
This commit is contained in:
@@ -1353,6 +1353,96 @@ void Stories::loadViewsSlice(
|
||||
}
|
||||
}
|
||||
|
||||
void Stories::loadReactionsSlice(
|
||||
not_null<PeerData*> peer,
|
||||
StoryId id,
|
||||
QString offset,
|
||||
Fn<void(StoryViews)> done) {
|
||||
Expects(peer->isChannel());
|
||||
|
||||
if (_reactionsStoryPeer == peer
|
||||
&& _reactionsStoryId == id
|
||||
&& _reactionsOffset == offset) {
|
||||
if (_reactionsRequestId) {
|
||||
_reactionsDone = std::move(done);
|
||||
}
|
||||
return;
|
||||
}
|
||||
_reactionsStoryPeer = peer;
|
||||
_reactionsStoryId = id;
|
||||
_reactionsOffset = offset;
|
||||
_reactionsDone = std::move(done);
|
||||
|
||||
using Flag = MTPstories_GetStoryReactionsList::Flag;
|
||||
const auto api = &_owner->session().api();
|
||||
_owner->session().api().request(_reactionsRequestId).cancel();
|
||||
_reactionsRequestId = api->request(MTPstories_GetStoryReactionsList(
|
||||
MTP_flags(offset.isEmpty() ? Flag() : Flag::f_offset),
|
||||
_reactionsStoryPeer->input,
|
||||
MTP_int(_reactionsStoryId),
|
||||
MTPReaction(),
|
||||
MTP_string(_reactionsOffset),
|
||||
MTP_int(kViewsPerPage)
|
||||
)).done([=](const MTPstories_StoryReactionsList &result) {
|
||||
_reactionsRequestId = 0;
|
||||
|
||||
const auto &data = result.data();
|
||||
auto slice = StoryViews{
|
||||
.nextOffset = data.vnext_offset().value_or_empty(),
|
||||
.reactions = data.vcount().v,
|
||||
.total = data.vcount().v,
|
||||
};
|
||||
_owner->processUsers(data.vusers());
|
||||
_owner->processChats(data.vchats());
|
||||
slice.list.reserve(data.vreactions().v.size());
|
||||
for (const auto &reaction : data.vreactions().v) {
|
||||
reaction.match([&](const MTPDstoryReaction &data) {
|
||||
slice.list.push_back({
|
||||
.peer = _owner->peer(peerFromMTP(data.vpeer_id())),
|
||||
.reaction = ReactionFromMTP(data.vreaction()),
|
||||
.date = data.vdate().v,
|
||||
});
|
||||
}, [&](const MTPDstoryReactionPublicRepost &data) {
|
||||
const auto story = applySingle(
|
||||
peerFromMTP(data.vpeer_id()),
|
||||
data.vstory());
|
||||
if (story) {
|
||||
slice.list.push_back({
|
||||
.peer = story->peer(),
|
||||
.repostId = story->id(),
|
||||
});
|
||||
}
|
||||
}, [&](const MTPDstoryReactionPublicForward &data) {
|
||||
const auto item = _owner->addNewMessage(
|
||||
data.vmessage(),
|
||||
{},
|
||||
NewMessageType::Existing);
|
||||
if (item) {
|
||||
slice.list.push_back({
|
||||
.peer = item->history()->peer,
|
||||
.forwardId = item->id,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
const auto fullId = FullStoryId{
|
||||
.peer = _reactionsStoryPeer->id,
|
||||
.story = _reactionsStoryId,
|
||||
};
|
||||
if (const auto story = lookup(fullId)) {
|
||||
(*story)->applyChannelReactionsSlice(_reactionsOffset, slice);
|
||||
}
|
||||
if (const auto done = base::take(_reactionsDone)) {
|
||||
done(std::move(slice));
|
||||
}
|
||||
}).fail([=] {
|
||||
_reactionsRequestId = 0;
|
||||
if (const auto done = base::take(_reactionsDone)) {
|
||||
done({});
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
|
||||
void Stories::sendViewsSliceRequest() {
|
||||
Expects(_viewsStoryPeer != nullptr);
|
||||
Expects(_viewsStoryPeer->isSelf());
|
||||
@@ -1379,6 +1469,7 @@ void Stories::sendViewsSliceRequest() {
|
||||
.total = data.vcount().v,
|
||||
};
|
||||
_owner->processUsers(data.vusers());
|
||||
_owner->processChats(data.vchats());
|
||||
slice.list.reserve(data.vviews().v.size());
|
||||
for (const auto &view : data.vviews().v) {
|
||||
view.match([&](const MTPDstoryView &data) {
|
||||
|
||||
Reference in New Issue
Block a user