mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-27 07:52:57 +02:00
Update API scheme to layer 205.
This commit is contained in:
parent
9832af7cce
commit
06db13a0ab
12 changed files with 349 additions and 75 deletions
|
@ -54,6 +54,7 @@ constexpr auto kRequestTimeLimit = 60 * crl::time(1000);
|
|||
data.vid(),
|
||||
data.vfrom_id() ? *data.vfrom_id() : MTPPeer(),
|
||||
data.vpeer_id(),
|
||||
data.vsaved_peer_id() ? *data.vsaved_peer_id() : MTPPeer(),
|
||||
data.vreply_to() ? *data.vreply_to() : MTPMessageReplyHeader(),
|
||||
data.vdate(),
|
||||
data.vaction(),
|
||||
|
|
|
@ -59,6 +59,7 @@ constexpr auto kRequestTimeLimit = 60 * crl::time(1000);
|
|||
data.vid(),
|
||||
data.vfrom_id() ? *data.vfrom_id() : MTPPeer(),
|
||||
data.vpeer_id(),
|
||||
data.vsaved_peer_id() ? *data.vsaved_peer_id() : MTPPeer(),
|
||||
data.vreply_to() ? *data.vreply_to() : MTPMessageReplyHeader(),
|
||||
data.vdate(),
|
||||
data.vaction(),
|
||||
|
|
|
@ -263,7 +263,10 @@ void SponsoredMessages::request(not_null<History*> history, Fn<void()> done) {
|
|||
}
|
||||
}
|
||||
request.requestId = _session->api().request(
|
||||
MTPmessages_GetSponsoredMessages(history->peer->input)
|
||||
MTPmessages_GetSponsoredMessages(
|
||||
MTP_flags(0),
|
||||
history->peer->input,
|
||||
MTPint()) // msg_id
|
||||
).done([=](const MTPmessages_sponsoredMessages &result) {
|
||||
parse(history, result);
|
||||
if (done) {
|
||||
|
|
|
@ -335,6 +335,10 @@ Utf8String Reaction::TypeToString(const Reaction &reaction) {
|
|||
Unexpected("Type in Reaction::Type.");
|
||||
}
|
||||
|
||||
std::vector<TextPart> ParseText(const MTPTextWithEntities &text) {
|
||||
return ParseText(text.data().vtext(), text.data().ventities().v);
|
||||
}
|
||||
|
||||
Utf8String Reaction::Id(const Reaction &reaction) {
|
||||
auto id = Utf8String();
|
||||
switch (reaction.type) {
|
||||
|
@ -777,17 +781,16 @@ Poll ParsePoll(const MTPDmessageMediaPoll &data) {
|
|||
auto result = Poll();
|
||||
data.vpoll().match([&](const MTPDpoll &poll) {
|
||||
result.id = poll.vid().v;
|
||||
result.question = ParseString(poll.vquestion().data().vtext());
|
||||
result.question = ParseText(poll.vquestion());
|
||||
result.closed = poll.is_closed();
|
||||
result.answers = ranges::views::all(
|
||||
poll.vanswers().v
|
||||
) | ranges::views::transform([](const MTPPollAnswer &answer) {
|
||||
return answer.match([](const MTPDpollAnswer &answer) {
|
||||
auto result = Poll::Answer();
|
||||
result.text = ParseString(answer.vtext().data().vtext());
|
||||
result.option = answer.voption().v;
|
||||
return result;
|
||||
});
|
||||
const auto &data = answer.data();
|
||||
auto result = Poll::Answer();
|
||||
result.text = ParseText(data.vtext());
|
||||
result.option = data.voption().v;
|
||||
return result;
|
||||
}) | ranges::to_vector;
|
||||
});
|
||||
data.vresults().match([&](const MTPDpollResults &results) {
|
||||
|
@ -796,25 +799,47 @@ Poll ParsePoll(const MTPDmessageMediaPoll &data) {
|
|||
}
|
||||
if (const auto resultsList = results.vresults()) {
|
||||
for (const auto &single : resultsList->v) {
|
||||
single.match([&](const MTPDpollAnswerVoters &voters) {
|
||||
const auto i = ranges::find(
|
||||
result.answers,
|
||||
voters.voption().v,
|
||||
&Poll::Answer::option);
|
||||
if (i == end(result.answers)) {
|
||||
return;
|
||||
}
|
||||
i->votes = voters.vvoters().v;
|
||||
if (voters.is_chosen()) {
|
||||
i->my = true;
|
||||
}
|
||||
});
|
||||
const auto &voters = single.data();
|
||||
const auto i = ranges::find(
|
||||
result.answers,
|
||||
voters.voption().v,
|
||||
&Poll::Answer::option);
|
||||
if (i == end(result.answers)) {
|
||||
continue;
|
||||
}
|
||||
i->votes = voters.vvoters().v;
|
||||
if (voters.is_chosen()) {
|
||||
i->my = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
TodoListItem ParseTodoListItem(const MTPTodoItem &item) {
|
||||
const auto &data = item.data();
|
||||
auto result = TodoListItem();
|
||||
result.text = ParseText(data.vtitle());
|
||||
result.id = data.vid().v;
|
||||
return result;
|
||||
}
|
||||
|
||||
TodoList ParseTodoList(const MTPDmessageMediaToDo &data) {
|
||||
auto result = TodoList();
|
||||
data.vtodo().match([&](const MTPDtodoList &data) {
|
||||
result.title = ParseText(data.vtitle());
|
||||
result.othersCanAppend = data.is_others_can_append();
|
||||
result.othersCanComplete = data.is_others_can_complete();
|
||||
result.items = ranges::views::all(
|
||||
data.vlist().v
|
||||
) | ranges::views::transform(
|
||||
ParseTodoListItem
|
||||
) | ranges::to_vector;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
GiveawayStart ParseGiveaway(const MTPDmessageMediaGiveaway &data) {
|
||||
auto result = GiveawayStart{
|
||||
.untilDate = data.vuntil_date().v,
|
||||
|
@ -1367,6 +1392,8 @@ Media ParseMedia(
|
|||
result.ttl = data.vperiod().v;
|
||||
}, [&](const MTPDmessageMediaPoll &data) {
|
||||
result.content = ParsePoll(data);
|
||||
}, [&](const MTPDmessageMediaToDo &data) {
|
||||
result.content = ParseTodoList(data);
|
||||
}, [](const MTPDmessageMediaDice &data) {
|
||||
// #TODO dice
|
||||
}, [](const MTPDmessageMediaStory &data) {
|
||||
|
@ -1714,6 +1741,22 @@ ServiceAction ParseServiceAction(
|
|||
.stars = int(data.vstars().v),
|
||||
.broadcastAllowed = data.is_broadcast_messages_allowed(),
|
||||
};
|
||||
}, [&](const MTPDmessageActionTodoCompletions &data) {
|
||||
const auto take = [](const MTPVector<MTPint> &list) {
|
||||
return list.v
|
||||
| ranges::views::transform(&MTPint::v)
|
||||
| ranges::to_vector;
|
||||
};
|
||||
result.content = ActionTodoCompletions{
|
||||
.completed = take(data.vcompleted()),
|
||||
.incompleted = take(data.vincompleted()),
|
||||
};
|
||||
}, [&](const MTPDmessageActionTodoAppendTasks &data) {
|
||||
result.content = ActionTodoAppendTasks{
|
||||
.items = data.vlist().v
|
||||
| ranges::views::transform(ParseTodoListItem)
|
||||
| ranges::to_vector,
|
||||
};
|
||||
}, [&](const MTPDmessageActionConferenceCall &data) {
|
||||
auto content = ActionPhoneCall();
|
||||
using State = ActionPhoneCall::State;
|
||||
|
|
|
@ -44,6 +44,39 @@ inline auto NumberToString(Type value, int length = 0, char filler = '0')
|
|||
filler).replace(',', '.');
|
||||
}
|
||||
|
||||
struct TextPart {
|
||||
enum class Type {
|
||||
Text,
|
||||
Unknown,
|
||||
Mention,
|
||||
Hashtag,
|
||||
BotCommand,
|
||||
Url,
|
||||
Email,
|
||||
Bold,
|
||||
Italic,
|
||||
Code,
|
||||
Pre,
|
||||
TextUrl,
|
||||
MentionName,
|
||||
Phone,
|
||||
Cashtag,
|
||||
Underline,
|
||||
Strike,
|
||||
Blockquote,
|
||||
BankCard,
|
||||
Spoiler,
|
||||
CustomEmoji,
|
||||
};
|
||||
Type type = Type::Text;
|
||||
Utf8String text;
|
||||
Utf8String additional;
|
||||
|
||||
[[nodiscard]] static Utf8String UnavailableEmoji() {
|
||||
return "(unavailable)";
|
||||
}
|
||||
};
|
||||
|
||||
struct UserpicsInfo {
|
||||
int count = 0;
|
||||
};
|
||||
|
@ -198,19 +231,31 @@ struct PaidMedia {
|
|||
|
||||
struct Poll {
|
||||
struct Answer {
|
||||
Utf8String text;
|
||||
std::vector<TextPart> text;
|
||||
QByteArray option;
|
||||
int votes = 0;
|
||||
bool my = false;
|
||||
};
|
||||
|
||||
uint64 id = 0;
|
||||
Utf8String question;
|
||||
std::vector<TextPart> question;
|
||||
std::vector<Answer> answers;
|
||||
int totalVotes = 0;
|
||||
bool closed = false;
|
||||
};
|
||||
|
||||
struct TodoListItem {
|
||||
std::vector<TextPart> text;
|
||||
int id = 0;
|
||||
};
|
||||
|
||||
struct TodoList {
|
||||
bool othersCanAppend = false;
|
||||
bool othersCanComplete = false;
|
||||
std::vector<TextPart> title;
|
||||
std::vector<TodoListItem> items;
|
||||
};
|
||||
|
||||
struct GiveawayStart {
|
||||
std::vector<QString> countries;
|
||||
std::vector<ChannelId> channels;
|
||||
|
@ -370,6 +415,7 @@ struct Media {
|
|||
Game,
|
||||
Invoice,
|
||||
Poll,
|
||||
TodoList,
|
||||
GiveawayStart,
|
||||
GiveawayResults,
|
||||
PaidMedia,
|
||||
|
@ -404,39 +450,6 @@ Media ParseMedia(
|
|||
const QString &folder,
|
||||
TimeId date);
|
||||
|
||||
struct TextPart {
|
||||
enum class Type {
|
||||
Text,
|
||||
Unknown,
|
||||
Mention,
|
||||
Hashtag,
|
||||
BotCommand,
|
||||
Url,
|
||||
Email,
|
||||
Bold,
|
||||
Italic,
|
||||
Code,
|
||||
Pre,
|
||||
TextUrl,
|
||||
MentionName,
|
||||
Phone,
|
||||
Cashtag,
|
||||
Underline,
|
||||
Strike,
|
||||
Blockquote,
|
||||
BankCard,
|
||||
Spoiler,
|
||||
CustomEmoji,
|
||||
};
|
||||
Type type = Type::Text;
|
||||
Utf8String text;
|
||||
Utf8String additional;
|
||||
|
||||
[[nodiscard]] static Utf8String UnavailableEmoji() {
|
||||
return "(unavailable)";
|
||||
}
|
||||
};
|
||||
|
||||
struct ActionChatCreate {
|
||||
Utf8String title;
|
||||
std::vector<UserId> userIds;
|
||||
|
@ -676,6 +689,15 @@ struct ActionPaidMessagesPrice {
|
|||
bool broadcastAllowed = false;
|
||||
};
|
||||
|
||||
struct ActionTodoCompletions {
|
||||
std::vector<int> completed;
|
||||
std::vector<int> incompleted;
|
||||
};
|
||||
|
||||
struct ActionTodoAppendTasks {
|
||||
std::vector<TodoListItem> items;
|
||||
};
|
||||
|
||||
struct ServiceAction {
|
||||
std::variant<
|
||||
v::null_t,
|
||||
|
@ -723,7 +745,9 @@ struct ServiceAction {
|
|||
ActionPrizeStars,
|
||||
ActionStarGift,
|
||||
ActionPaidMessagesRefunded,
|
||||
ActionPaidMessagesPrice> content;
|
||||
ActionPaidMessagesPrice,
|
||||
ActionTodoCompletions,
|
||||
ActionTodoAppendTasks> content;
|
||||
};
|
||||
|
||||
ServiceAction ParseServiceAction(
|
||||
|
|
|
@ -621,7 +621,14 @@ private:
|
|||
[[nodiscard]] QByteArray pushPhotoMedia(
|
||||
const Data::Photo &data,
|
||||
const QString &basePath);
|
||||
[[nodiscard]] QByteArray pushPoll(const Data::Poll &data);
|
||||
[[nodiscard]] QByteArray pushPoll(
|
||||
const Data::Poll &data,
|
||||
const QString &internalLinksDomain,
|
||||
const QString &relativeLinkBase);
|
||||
[[nodiscard]] QByteArray pushTodoList(
|
||||
const Data::TodoList &data,
|
||||
const QString &internalLinksDomain,
|
||||
const QString &relativeLinkBase);
|
||||
[[nodiscard]] QByteArray pushGiveaway(
|
||||
const PeersMap &peers,
|
||||
const Data::GiveawayStart &data);
|
||||
|
@ -1395,6 +1402,50 @@ auto HtmlWriter::Wrap::pushMessage(
|
|||
+ QString::number(data.stars).toUtf8()
|
||||
+ " Telegram Stars.";
|
||||
return result;
|
||||
}, [&](const ActionTodoCompletions &data) {
|
||||
auto completed = QByteArrayList();
|
||||
for (const auto index : data.completed) {
|
||||
completed.push_back(QByteArray::number(index));
|
||||
}
|
||||
auto incompleted = QByteArrayList();
|
||||
for (const auto index : data.incompleted) {
|
||||
incompleted.push_back(QByteArray::number(index));
|
||||
}
|
||||
const auto list = [](const QByteArrayList &v) {
|
||||
return v.isEmpty()
|
||||
? QByteArray()
|
||||
: (v.size() > 1)
|
||||
? (v.mid(0, v.size() - 1).join(", ") + " and " + v.back())
|
||||
: v.front();
|
||||
};
|
||||
if (completed.isEmpty() && !incompleted.isEmpty()) {
|
||||
return serviceFrom
|
||||
+ " marked "
|
||||
+ list(incompleted)
|
||||
+ " as not done yet in "
|
||||
+ wrapReplyToLink("this todo list") + ".";
|
||||
} else if (!completed.isEmpty() && incompleted.isEmpty()) {
|
||||
return serviceFrom
|
||||
+ " marked "
|
||||
+ list(completed)
|
||||
+ " as done in "
|
||||
+ wrapReplyToLink("this todo list") + ".";
|
||||
}
|
||||
return serviceFrom
|
||||
+ " marked "
|
||||
+ list(completed)
|
||||
+ " as done and "
|
||||
+ list(incompleted)
|
||||
+ " as not done yet in "
|
||||
+ wrapReplyToLink("this todo list") + ".";
|
||||
}, [&](const ActionTodoAppendTasks &data) {
|
||||
auto tasks = QByteArrayList();
|
||||
for (const auto &task : data.items) {
|
||||
tasks.push_back("""
|
||||
+ FormatText(task.text, internalLinksDomain, _base)
|
||||
+ """);
|
||||
}
|
||||
return serviceFrom + " added tasks: " + tasks.join(", ");
|
||||
}, [](v::null_t) { return QByteArray(); });
|
||||
|
||||
if (!serviceText.isEmpty()) {
|
||||
|
@ -1721,7 +1772,9 @@ QByteArray HtmlWriter::Wrap::pushMedia(
|
|||
Assert(!message.media.ttl);
|
||||
return pushPhotoMedia(*photo, basePath);
|
||||
} else if (const auto poll = std::get_if<Poll>(&content)) {
|
||||
return pushPoll(*poll);
|
||||
return pushPoll(*poll, internalLinksDomain, _base);
|
||||
} else if (const auto todo = std::get_if<TodoList>(&content)) {
|
||||
return pushTodoList(*todo, internalLinksDomain, _base);
|
||||
} else if (const auto giveaway = std::get_if<GiveawayStart>(&content)) {
|
||||
return pushGiveaway(peers, *giveaway);
|
||||
} else if (const auto giveaway = std::get_if<GiveawayResults>(&content)) {
|
||||
|
@ -1999,13 +2052,19 @@ QByteArray HtmlWriter::Wrap::pushPhotoMedia(
|
|||
return result;
|
||||
}
|
||||
|
||||
QByteArray HtmlWriter::Wrap::pushPoll(const Data::Poll &data) {
|
||||
QByteArray HtmlWriter::Wrap::pushPoll(
|
||||
const Data::Poll &data,
|
||||
const QString &internalLinksDomain,
|
||||
const QString &relativeLinkBase) {
|
||||
using namespace Data;
|
||||
|
||||
auto result = pushDiv("media_wrap clearfix");
|
||||
result.append(pushDiv("media_poll"));
|
||||
result.append(pushDiv("question bold"));
|
||||
result.append(SerializeString(data.question));
|
||||
result.append(FormatText(
|
||||
data.question,
|
||||
internalLinksDomain,
|
||||
relativeLinkBase));
|
||||
result.append(popTag());
|
||||
result.append(pushDiv("details"));
|
||||
if (data.closed) {
|
||||
|
@ -2036,7 +2095,9 @@ QByteArray HtmlWriter::Wrap::pushPoll(const Data::Poll &data) {
|
|||
};
|
||||
for (const auto &answer : data.answers) {
|
||||
result.append(pushDiv("answer"));
|
||||
result.append("- " + SerializeString(answer.text) + details(answer));
|
||||
result.append("- "
|
||||
+ FormatText(answer.text, internalLinksDomain, relativeLinkBase)
|
||||
+ details(answer));
|
||||
result.append(popTag());
|
||||
}
|
||||
result.append(pushDiv("total details "));
|
||||
|
@ -2047,6 +2108,38 @@ QByteArray HtmlWriter::Wrap::pushPoll(const Data::Poll &data) {
|
|||
return result;
|
||||
}
|
||||
|
||||
QByteArray HtmlWriter::Wrap::pushTodoList(
|
||||
const Data::TodoList &data,
|
||||
const QString &internalLinksDomain,
|
||||
const QString &relativeLinkBase) {
|
||||
using namespace Data;
|
||||
|
||||
auto result = pushDiv("media_wrap clearfix");
|
||||
result.append(pushDiv("media_poll"));
|
||||
result.append(pushDiv("question bold"));
|
||||
result.append(FormatText(
|
||||
data.title,
|
||||
internalLinksDomain,
|
||||
relativeLinkBase));
|
||||
result.append(popTag());
|
||||
result.append(pushDiv("details"));
|
||||
result.append(SerializeString("To-do List"));
|
||||
result.append(popTag());
|
||||
const auto details = [&](const TodoListItem &item) {
|
||||
return QByteArray(""); // #TODO todo
|
||||
};
|
||||
for (const auto &item : data.items) {
|
||||
result.append(pushDiv("answer"));
|
||||
result.append("- "
|
||||
+ FormatText(item.text, internalLinksDomain, relativeLinkBase)
|
||||
+ details(item));
|
||||
result.append(popTag());
|
||||
}
|
||||
result.append(popTag());
|
||||
result.append(popTag());
|
||||
return result;
|
||||
}
|
||||
|
||||
QByteArray HtmlWriter::Wrap::pushGiveaway(
|
||||
const PeersMap &peers,
|
||||
const Data::GiveawayStart &data) {
|
||||
|
@ -2436,6 +2529,7 @@ MediaData HtmlWriter::Wrap::prepareMediaData(
|
|||
result.description = data.description;
|
||||
result.status = Data::FormatMoneyAmount(data.amount, data.currency);
|
||||
}, [](const Poll &data) {
|
||||
}, [](const TodoList &data) {
|
||||
}, [](const GiveawayStart &data) {
|
||||
}, [](const GiveawayResults &data) {
|
||||
}, [&](const PaidMedia &data) {
|
||||
|
|
|
@ -680,6 +680,34 @@ QByteArray SerializeMessage(
|
|||
pushAction("paid_messages_price_change");
|
||||
push("price_stars", data.stars);
|
||||
push("is_broadcast_messages_allowed", data.broadcastAllowed);
|
||||
}, [&](const ActionTodoCompletions &data) {
|
||||
pushActor();
|
||||
pushAction("todo_completions");
|
||||
auto completed = QByteArrayList();
|
||||
for (const auto index : data.completed) {
|
||||
completed.push_back(QByteArray::number(index));
|
||||
}
|
||||
auto incompleted = QByteArrayList();
|
||||
for (const auto index : data.incompleted) {
|
||||
incompleted.push_back(QByteArray::number(index));
|
||||
}
|
||||
pushBare("completed", '[' + completed.join(',') + ']');
|
||||
pushBare("incompleted", '[' + incompleted.join(',') + ']');
|
||||
}, [&](const ActionTodoAppendTasks &data) {
|
||||
pushActor();
|
||||
pushAction("todo_append_tasks");
|
||||
const auto items = ranges::views::all(
|
||||
data.items
|
||||
) | ranges::views::transform([&](const TodoListItem &item) {
|
||||
context.nesting.push_back(Context::kArray);
|
||||
auto result = SerializeObject(context, {
|
||||
{ "text", SerializeText(context, item.text) },
|
||||
{ "id", NumberToString(item.id) },
|
||||
});
|
||||
context.nesting.pop_back();
|
||||
return result;
|
||||
}) | ranges::to_vector;
|
||||
pushBare("items", SerializeArray(context, items));
|
||||
}, [](v::null_t) {});
|
||||
|
||||
if (v::is_null(message.action.content)) {
|
||||
|
@ -807,7 +835,7 @@ QByteArray SerializeMessage(
|
|||
) | ranges::views::transform([&](const Poll::Answer &answer) {
|
||||
context.nesting.push_back(Context::kArray);
|
||||
auto result = SerializeObject(context, {
|
||||
{ "text", SerializeString(answer.text) },
|
||||
{ "text", SerializeText(context, answer.text) },
|
||||
{ "voters", NumberToString(answer.votes) },
|
||||
{ "chosen", answer.my ? "true" : "false" },
|
||||
});
|
||||
|
@ -818,11 +846,36 @@ QByteArray SerializeMessage(
|
|||
context.nesting.pop_back();
|
||||
|
||||
pushBare("poll", SerializeObject(context, {
|
||||
{ "question", SerializeString(data.question) },
|
||||
{ "question", SerializeText(context, data.question) },
|
||||
{ "closed", data.closed ? "true" : "false" },
|
||||
{ "total_voters", NumberToString(data.totalVotes) },
|
||||
{ "answers", serialized }
|
||||
}));
|
||||
}, [&](const TodoList &data) {
|
||||
context.nesting.push_back(Context::kObject);
|
||||
const auto items = ranges::views::all(
|
||||
data.items
|
||||
) | ranges::views::transform([&](const TodoListItem &item) {
|
||||
context.nesting.push_back(Context::kArray);
|
||||
auto result = SerializeObject(context, {
|
||||
{ "text", SerializeText(context, item.text) },
|
||||
{ "id", NumberToString(item.id) },
|
||||
});
|
||||
context.nesting.pop_back();
|
||||
return result;
|
||||
}) | ranges::to_vector;
|
||||
const auto serialized = SerializeArray(context, items);
|
||||
context.nesting.pop_back();
|
||||
|
||||
pushBare("todo_list", SerializeObject(context, {
|
||||
{ "title", SerializeText(context, data.title) },
|
||||
{ "others_can_append", data.othersCanAppend ? "true" : "false" },
|
||||
{
|
||||
"others_can_complete",
|
||||
data.othersCanComplete ? "true" : "false",
|
||||
},
|
||||
{ "answers", serialized }
|
||||
}));
|
||||
}, [&](const GiveawayStart &data) {
|
||||
context.nesting.push_back(Context::kArray);
|
||||
const auto channels = ranges::views::all(
|
||||
|
|
|
@ -131,6 +131,7 @@ MTPMessage PrepareLogMessage(const MTPMessage &message, TimeId newDate) {
|
|||
const auto reply = PrepareLogReply(data.vreply_to());
|
||||
const auto removeFlags = Flag::f_out
|
||||
| Flag::f_post
|
||||
| Flag::f_saved_peer_id
|
||||
| Flag::f_reactions_are_possible
|
||||
| Flag::f_reactions
|
||||
| Flag::f_ttl_period
|
||||
|
@ -140,6 +141,7 @@ MTPMessage PrepareLogMessage(const MTPMessage &message, TimeId newDate) {
|
|||
data.vid(),
|
||||
data.vfrom_id() ? *data.vfrom_id() : MTPPeer(),
|
||||
data.vpeer_id(),
|
||||
MTPPeer(), // saved_peer_id
|
||||
reply.value_or(MTPMessageReplyHeader()),
|
||||
MTP_int(newDate),
|
||||
data.vaction(),
|
||||
|
@ -150,6 +152,7 @@ MTPMessage PrepareLogMessage(const MTPMessage &message, TimeId newDate) {
|
|||
const auto reply = PrepareLogReply(data.vreply_to());
|
||||
const auto removeFlags = Flag::f_out
|
||||
| Flag::f_post
|
||||
| Flag::f_saved_peer_id
|
||||
| (reply ? Flag() : Flag::f_reply_to)
|
||||
| Flag::f_replies
|
||||
| Flag::f_edit_date
|
||||
|
|
|
@ -357,6 +357,8 @@ std::unique_ptr<Data::Media> HistoryItem::CreateMedia(
|
|||
return std::make_unique<Data::MediaPoll>(
|
||||
item,
|
||||
item->history()->owner().processPoll(media));
|
||||
}, [&](const MTPDmessageMediaToDo &media) -> Result {
|
||||
return nullptr; // #TODO todo
|
||||
}, [&](const MTPDmessageMediaDice &media) -> Result {
|
||||
return std::make_unique<Data::MediaDice>(
|
||||
item,
|
||||
|
@ -2102,6 +2104,7 @@ void HistoryItem::applyEditionToHistoryCleared() {
|
|||
MTP_int(id),
|
||||
peerToMTP(PeerId(0)), // from_id
|
||||
peerToMTP(_history->peer->id),
|
||||
MTPPeer(), // saved_peer_id
|
||||
MTPMessageReplyHeader(),
|
||||
MTP_int(date()),
|
||||
MTP_messageActionHistoryClear(),
|
||||
|
@ -4553,6 +4556,24 @@ void HistoryItem::createServiceFromMtp(const MTPDmessageService &message) {
|
|||
}, [](const MTPDmessageReplyStoryHeader &data) {
|
||||
});
|
||||
}
|
||||
|
||||
const auto savedSublistPeer = message.vsaved_peer_id()
|
||||
? peerFromMTP(*message.vsaved_peer_id())
|
||||
: PeerId();
|
||||
const auto requiresMonoforumPeer = _history->peer->amMonoforumAdmin();
|
||||
if (savedSublistPeer || requiresMonoforumPeer) {
|
||||
UpdateComponents(HistoryMessageSaved::Bit());
|
||||
const auto saved = Get<HistoryMessageSaved>();
|
||||
saved->sublistPeerId = savedSublistPeer
|
||||
? savedSublistPeer
|
||||
: _from->id;
|
||||
if (_history->peer->isSelf()) {
|
||||
saved->savedMessagesSublist
|
||||
= _history->owner().savedMessages().sublist(
|
||||
_history->owner().peer(saved->sublistPeerId));
|
||||
}
|
||||
}
|
||||
|
||||
setServiceMessageByAction(action);
|
||||
}
|
||||
|
||||
|
@ -5853,6 +5874,16 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
|||
return result;
|
||||
};
|
||||
|
||||
auto prepareTodoCompletions = [&](const MTPDmessageActionTodoCompletions &action) {
|
||||
auto result = PreparedServiceText(); // #TODO todo
|
||||
return result;
|
||||
};
|
||||
|
||||
auto prepareTodoAppendTasks = [&](const MTPDmessageActionTodoAppendTasks &action) {
|
||||
auto result = PreparedServiceText(); // #TODO todo
|
||||
return result;
|
||||
};
|
||||
|
||||
auto prepareConferenceCall = [&](const MTPDmessageActionConferenceCall &) -> PreparedServiceText {
|
||||
Unexpected("PhoneCall type in setServiceMessageFromMtp.");
|
||||
};
|
||||
|
@ -5907,6 +5938,8 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
|||
preparePaidMessagesRefunded,
|
||||
preparePaidMessagesPrice,
|
||||
prepareConferenceCall,
|
||||
prepareTodoCompletions,
|
||||
prepareTodoAppendTasks,
|
||||
PrepareEmptyText<MTPDmessageActionRequestedPeerSentMe>,
|
||||
PrepareErrorText<MTPDmessageActionEmpty>));
|
||||
|
||||
|
|
|
@ -897,6 +897,8 @@ MediaCheckResult CheckMessageMedia(const MTPMessageMedia &media) {
|
|||
return Result::Good;
|
||||
}, [](const MTPDmessageMediaPoll &) {
|
||||
return Result::Good;
|
||||
}, [](const MTPDmessageMediaToDo &) {
|
||||
return Result::Good;
|
||||
}, [](const MTPDmessageMediaDice &) {
|
||||
return Result::Good;
|
||||
}, [](const MTPDmessageMediaStory &data) {
|
||||
|
|
|
@ -1222,10 +1222,13 @@ void PaysStatus::setupHandlers() {
|
|||
) | rpl::start_with_next([=] {
|
||||
const auto user = _user;
|
||||
const auto exception = [=](bool refund) {
|
||||
using Flag = MTPaccount_AddNoPaidMessagesException::Flag;
|
||||
using Flag = MTPaccount_ToggleNoPaidMessagesException::Flag;
|
||||
const auto api = &user->session().api();
|
||||
api->request(MTPaccount_AddNoPaidMessagesException(
|
||||
MTP_flags(refund ? Flag::f_refund_charged : Flag()),
|
||||
const auto require = false;
|
||||
api->request(MTPaccount_ToggleNoPaidMessagesException(
|
||||
MTP_flags((refund ? Flag::f_refund_charged : Flag())
|
||||
| (require ? Flag::f_require_payment : Flag())),
|
||||
MTPInputPeer(), // parent_peer // #TODO monoforum
|
||||
user->inputUser
|
||||
)).done([=] {
|
||||
user->clearPaysPerMessage();
|
||||
|
@ -1268,6 +1271,8 @@ void PaysStatus::setupHandlers() {
|
|||
}, box->lifetime());
|
||||
|
||||
user->session().api().request(MTPaccount_GetPaidMessagesRevenue(
|
||||
MTP_flags(0),
|
||||
MTPInputPeer(), // parent_peer // #TODO monoforum
|
||||
user->inputUser
|
||||
)).done(crl::guard(_inner, [=](
|
||||
const MTPaccount_PaidMessagesRevenue &result) {
|
||||
|
|
|
@ -46,6 +46,7 @@ inputMediaDice#e66fbf7b emoticon:string = InputMedia;
|
|||
inputMediaStory#89fdd778 peer:InputPeer id:int = InputMedia;
|
||||
inputMediaWebPage#c21b8849 flags:# force_large_media:flags.0?true force_small_media:flags.1?true optional:flags.2?true url:string = InputMedia;
|
||||
inputMediaPaidMedia#c4103386 flags:# stars_amount:long extended_media:Vector<InputMedia> payload:flags.0?string = InputMedia;
|
||||
inputMediaTodo#9fc55fde todo:TodoList = InputMedia;
|
||||
|
||||
inputChatPhotoEmpty#1ca48f57 = InputChatPhoto;
|
||||
inputChatUploadedPhoto#bdcdaec0 flags:# file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double video_emoji_markup:flags.3?VideoSize = InputChatPhoto;
|
||||
|
@ -117,7 +118,7 @@ chatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:f
|
|||
|
||||
messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message;
|
||||
message#eabcdd4d flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true flags2:# offline:flags2.1?true video_processing_pending:flags2.4?true id:int from_id:flags.8?Peer from_boosts_applied:flags.29?int peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long via_business_bot_id:flags2.0?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector<MessageEntity> views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector<RestrictionReason> ttl_period:flags.25?int quick_reply_shortcut_id:flags.30?int effect:flags2.2?long factcheck:flags2.3?FactCheck report_delivery_until_date:flags2.5?int paid_message_stars:flags2.6?long = Message;
|
||||
messageService#d3d28540 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true reactions_are_possible:flags.9?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction reactions:flags.20?MessageReactions ttl_period:flags.25?int = Message;
|
||||
messageService#7a800e0a flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true reactions_are_possible:flags.9?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer saved_peer_id:flags.28?Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction reactions:flags.20?MessageReactions ttl_period:flags.25?int = Message;
|
||||
|
||||
messageMediaEmpty#3ded6320 = MessageMedia;
|
||||
messageMediaPhoto#695150d7 flags:# spoiler:flags.3?true photo:flags.0?Photo ttl_seconds:flags.2?int = MessageMedia;
|
||||
|
@ -136,6 +137,7 @@ messageMediaStory#68cb6283 flags:# via_mention:flags.1?true peer:Peer id:int sto
|
|||
messageMediaGiveaway#aa073beb flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.2?true channels:Vector<long> countries_iso2:flags.1?Vector<string> prize_description:flags.3?string quantity:int months:flags.4?int stars:flags.5?long until_date:int = MessageMedia;
|
||||
messageMediaGiveawayResults#ceaa3ea1 flags:# only_new_subscribers:flags.0?true refunded:flags.2?true channel_id:long additional_peers_count:flags.3?int launch_msg_id:int winners_count:int unclaimed_count:int winners:Vector<long> months:flags.4?int stars:flags.5?long prize_description:flags.1?string until_date:int = MessageMedia;
|
||||
messageMediaPaidMedia#a8852491 stars_amount:long extended_media:Vector<MessageExtendedMedia> = MessageMedia;
|
||||
messageMediaToDo#8a53b014 flags:# todo:TodoList completions:flags.0?Vector<TodoCompletion> = MessageMedia;
|
||||
|
||||
messageActionEmpty#b6aef7b0 = MessageAction;
|
||||
messageActionChatCreate#bd47cbad title:string users:Vector<long> = MessageAction;
|
||||
|
@ -188,6 +190,8 @@ messageActionStarGiftUnique#2e3ae60e flags:# upgrade:flags.0?true transferred:fl
|
|||
messageActionPaidMessagesRefunded#ac1f1fcd count:int stars:long = MessageAction;
|
||||
messageActionPaidMessagesPrice#84b88578 flags:# broadcast_messages_allowed:flags.0?true stars:long = MessageAction;
|
||||
messageActionConferenceCall#2ffe2f7a flags:# missed:flags.0?true active:flags.1?true video:flags.4?true call_id:long duration:flags.2?int other_participants:flags.3?Vector<Peer> = MessageAction;
|
||||
messageActionTodoCompletions#cc7c5c89 completed:Vector<int> incompleted:Vector<int> = MessageAction;
|
||||
messageActionTodoAppendTasks#c7edbc83 list:Vector<TodoItem> = MessageAction;
|
||||
|
||||
dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog;
|
||||
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
|
||||
|
@ -1407,9 +1411,9 @@ account.resetPasswordFailedWait#e3779861 retry_date:int = account.ResetPasswordR
|
|||
account.resetPasswordRequestedWait#e9effc7d until_date:int = account.ResetPasswordResult;
|
||||
account.resetPasswordOk#e926d63e = account.ResetPasswordResult;
|
||||
|
||||
sponsoredMessage#4d93a990 flags:# recommended:flags.5?true can_report:flags.12?true random_id:bytes url:string title:string message:string entities:flags.1?Vector<MessageEntity> photo:flags.6?Photo media:flags.14?MessageMedia color:flags.13?PeerColor button_text:string sponsor_info:flags.7?string additional_info:flags.8?string = SponsoredMessage;
|
||||
sponsoredMessage#7dbf8673 flags:# recommended:flags.5?true can_report:flags.12?true random_id:bytes url:string title:string message:string entities:flags.1?Vector<MessageEntity> photo:flags.6?Photo media:flags.14?MessageMedia color:flags.13?PeerColor button_text:string sponsor_info:flags.7?string additional_info:flags.8?string min_display_duration:flags.15?int max_display_duration:flags.15?int = SponsoredMessage;
|
||||
|
||||
messages.sponsoredMessages#c9ee1d87 flags:# posts_between:flags.0?int messages:Vector<SponsoredMessage> chats:Vector<Chat> users:Vector<User> = messages.SponsoredMessages;
|
||||
messages.sponsoredMessages#ffda656d flags:# posts_between:flags.0?int start_delay:flags.1?int between_delay:flags.2?int messages:Vector<SponsoredMessage> chats:Vector<Chat> users:Vector<User> = messages.SponsoredMessages;
|
||||
messages.sponsoredMessagesEmpty#1839490f = messages.SponsoredMessages;
|
||||
|
||||
searchResultsCalendarPeriod#c9b0539f date:int min_msg_id:int max_msg_id:int count:int = SearchResultsCalendarPeriod;
|
||||
|
@ -1715,7 +1719,7 @@ storyReactionPublicRepost#cfcd0f13 peer_id:Peer story:StoryItem = StoryReaction;
|
|||
stories.storyReactionsList#aa5f789c flags:# count:int reactions:Vector<StoryReaction> chats:Vector<Chat> users:Vector<User> next_offset:flags.0?string = stories.StoryReactionsList;
|
||||
|
||||
savedDialog#bd87cb6c flags:# pinned:flags.2?true peer:Peer top_message:int = SavedDialog;
|
||||
monoForumDialog#64407ea7 flags:# unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_reactions_count:int draft:flags.1?DraftMessage = SavedDialog;
|
||||
monoForumDialog#64407ea7 flags:# unread_mark:flags.3?true nopaid_messages_exception:flags.4?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_reactions_count:int draft:flags.1?DraftMessage = SavedDialog;
|
||||
|
||||
messages.savedDialogs#f83ae221 dialogs:Vector<SavedDialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.SavedDialogs;
|
||||
messages.savedDialogsSlice#44ba9dd9 count:int dialogs:Vector<SavedDialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.SavedDialogs;
|
||||
|
@ -1983,6 +1987,12 @@ stories.canSendStoryCount#c387c04e count_remains:int = stories.CanSendStoryCount
|
|||
|
||||
pendingSuggestion#e7e82e12 suggestion:string title:TextWithEntities description:TextWithEntities url:string = PendingSuggestion;
|
||||
|
||||
todoItem#cba9a52f id:int title:TextWithEntities = TodoItem;
|
||||
|
||||
todoList#49b92a26 flags:# others_can_append:flags.0?true others_can_complete:flags.1?true title:TextWithEntities list:Vector<TodoItem> = TodoList;
|
||||
|
||||
todoCompletion#4cc120b7 id:int completed_by:long date:int = TodoCompletion;
|
||||
|
||||
---functions---
|
||||
|
||||
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
||||
|
@ -2134,8 +2144,8 @@ account.toggleSponsoredMessages#b9d9a38d enabled:Bool = Bool;
|
|||
account.getReactionsNotifySettings#6dd654c = ReactionsNotifySettings;
|
||||
account.setReactionsNotifySettings#316ce548 settings:ReactionsNotifySettings = ReactionsNotifySettings;
|
||||
account.getCollectibleEmojiStatuses#2e7b4543 hash:long = account.EmojiStatuses;
|
||||
account.addNoPaidMessagesException#6f688aa7 flags:# refund_charged:flags.0?true user_id:InputUser = Bool;
|
||||
account.getPaidMessagesRevenue#f1266f38 user_id:InputUser = account.PaidMessagesRevenue;
|
||||
account.getPaidMessagesRevenue#19ba4a67 flags:# parent_peer:flags.0?InputPeer user_id:InputUser = account.PaidMessagesRevenue;
|
||||
account.toggleNoPaidMessagesException#fe2eda76 flags:# refund_charged:flags.0?true require_payment:flags.2?true parent_peer:flags.1?InputPeer user_id:InputUser = Bool;
|
||||
|
||||
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
|
||||
users.getFullUser#b60f5918 id:InputUser = users.UserFull;
|
||||
|
@ -2390,13 +2400,15 @@ messages.getPaidReactionPrivacy#472455aa = Updates;
|
|||
messages.viewSponsoredMessage#269e3643 random_id:bytes = Bool;
|
||||
messages.clickSponsoredMessage#8235057e flags:# media:flags.0?true fullscreen:flags.1?true random_id:bytes = Bool;
|
||||
messages.reportSponsoredMessage#12cbf0c4 random_id:bytes option:bytes = channels.SponsoredMessageReportResult;
|
||||
messages.getSponsoredMessages#9bd2f439 peer:InputPeer = messages.SponsoredMessages;
|
||||
messages.getSponsoredMessages#3d6ce850 flags:# peer:InputPeer msg_id:flags.0?int = messages.SponsoredMessages;
|
||||
messages.savePreparedInlineMessage#f21f7f2f flags:# result:InputBotInlineResult user_id:InputUser peer_types:flags.0?Vector<InlineQueryPeerType> = messages.BotPreparedInlineMessage;
|
||||
messages.getPreparedInlineMessage#857ebdb8 bot:InputUser id:string = messages.PreparedInlineMessage;
|
||||
messages.searchStickers#29b1c66a flags:# emojis:flags.0?true q:string emoticon:string lang_code:Vector<string> offset:int limit:int hash:long = messages.FoundStickers;
|
||||
messages.reportMessagesDelivery#5a6d7395 flags:# push:flags.0?true peer:InputPeer id:Vector<int> = Bool;
|
||||
messages.getSavedDialogsByID#6f6f9c96 flags:# parent_peer:flags.1?InputPeer ids:Vector<InputPeer> = messages.SavedDialogs;
|
||||
messages.readSavedHistory#ba4a3b5b parent_peer:InputPeer peer:InputPeer max_id:int = Bool;
|
||||
messages.toggleTodoCompleted#d3e03124 peer:InputPeer msg_id:int completed:Vector<int> incompleted:Vector<int> = Updates;
|
||||
messages.appendTodoList#21a61057 peer:InputPeer msg_id:int list:Vector<TodoItem> = Updates;
|
||||
|
||||
updates.getState#edd4882a = updates.State;
|
||||
updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference;
|
||||
|
@ -2714,4 +2726,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool;
|
|||
|
||||
fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo;
|
||||
|
||||
// LAYER 204
|
||||
// LAYER 205
|
||||
|
|
Loading…
Add table
Reference in a new issue