mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Update API scheme to layer 206.
This commit is contained in:
@@ -14,6 +14,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace Api {
|
||||
|
||||
MTPSuggestedPost SuggestToMTP(const std::optional<SuggestOptions> &suggest) {
|
||||
using Flag = MTPDsuggestedPost::Flag;
|
||||
return suggest
|
||||
? MTP_suggestedPost(
|
||||
MTP_flags(suggest->date ? Flag::f_schedule_date : Flag()),
|
||||
MTP_long(suggest->stars),
|
||||
MTP_int(suggest->date))
|
||||
: MTPSuggestedPost();
|
||||
}
|
||||
|
||||
SendAction::SendAction(
|
||||
not_null<Data::Thread*> thread,
|
||||
SendOptions options)
|
||||
|
@@ -19,6 +19,18 @@ namespace Api {
|
||||
|
||||
inline constexpr auto kScheduledUntilOnlineTimestamp = TimeId(0x7FFFFFFE);
|
||||
|
||||
struct SuggestOptions {
|
||||
int stars = 0;
|
||||
TimeId date = 0;
|
||||
|
||||
friend inline bool operator==(
|
||||
const SuggestOptions &,
|
||||
const SuggestOptions &) = default;
|
||||
};
|
||||
|
||||
[[nodiscard]] MTPSuggestedPost SuggestToMTP(
|
||||
const std::optional<SuggestOptions> &suggest);
|
||||
|
||||
struct SendOptions {
|
||||
uint64 price = 0;
|
||||
PeerData *sendAs = nullptr;
|
||||
@@ -31,6 +43,7 @@ struct SendOptions {
|
||||
bool invertCaption = false;
|
||||
bool hideViaBot = false;
|
||||
crl::time ttlSeconds = 0;
|
||||
std::optional<SuggestOptions> suggest;
|
||||
|
||||
friend inline bool operator==(
|
||||
const SendOptions &,
|
||||
|
@@ -75,6 +75,9 @@ void Polls::create(
|
||||
if (action.options.effectId) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_effect;
|
||||
}
|
||||
if (action.options.suggest) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_suggested_post;
|
||||
}
|
||||
if (starsPaid) {
|
||||
action.options.starsApproved -= starsPaid;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_allow_paid_stars;
|
||||
@@ -102,7 +105,8 @@ void Polls::create(
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(_session, action.options.shortcutId),
|
||||
MTP_long(action.options.effectId),
|
||||
MTP_long(starsPaid)
|
||||
MTP_long(starsPaid),
|
||||
SuggestToMTP(action.options.suggest)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
if (clearCloudDraft) {
|
||||
history->finishSavingCloudDraft(
|
||||
|
@@ -109,6 +109,9 @@ void SendSimpleMedia(SendAction action, MTPInputMedia inputMedia) {
|
||||
if (action.options.effectId) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_effect;
|
||||
}
|
||||
if (action.options.suggest) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_suggested_post;
|
||||
}
|
||||
if (action.options.invertCaption) {
|
||||
flags |= MessageFlag::InvertMedia;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_invert_media;
|
||||
@@ -136,7 +139,8 @@ void SendSimpleMedia(SendAction action, MTPInputMedia inputMedia) {
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(session, action.options.shortcutId),
|
||||
MTP_long(action.options.effectId),
|
||||
MTP_long(starsPaid)
|
||||
MTP_long(starsPaid),
|
||||
SuggestToMTP(action.options.suggest)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
}, [=](const MTP::Error &error, const MTP::Response &response) {
|
||||
api->sendMessageFail(error, peer, randomId);
|
||||
@@ -211,6 +215,9 @@ void SendExistingMedia(
|
||||
if (action.options.effectId) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_effect;
|
||||
}
|
||||
if (action.options.suggest) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_suggested_post;
|
||||
}
|
||||
if (action.options.invertCaption) {
|
||||
flags |= MessageFlag::InvertMedia;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_invert_media;
|
||||
@@ -255,7 +262,8 @@ void SendExistingMedia(
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(session, action.options.shortcutId),
|
||||
MTP_long(action.options.effectId),
|
||||
MTP_long(starsPaid)
|
||||
MTP_long(starsPaid),
|
||||
SuggestToMTP(action.options.suggest)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
}, [=](const MTP::Error &error, const MTP::Response &response) {
|
||||
if (error.code() == 400
|
||||
@@ -391,6 +399,9 @@ bool SendDice(MessageToSend &message) {
|
||||
if (action.options.effectId) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_effect;
|
||||
}
|
||||
if (action.options.suggest) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_suggested_post;
|
||||
}
|
||||
if (action.options.invertCaption) {
|
||||
flags |= MessageFlag::InvertMedia;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_invert_media;
|
||||
@@ -435,7 +446,8 @@ bool SendDice(MessageToSend &message) {
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(session, action.options.shortcutId),
|
||||
MTP_long(action.options.effectId),
|
||||
MTP_long(starsPaid)
|
||||
MTP_long(starsPaid),
|
||||
SuggestToMTP(action.options.suggest)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
}, [=](const MTP::Error &error, const MTP::Response &response) {
|
||||
api->sendMessageFail(error, peer, randomId, newId);
|
||||
|
@@ -77,6 +77,9 @@ void TodoLists::create(
|
||||
if (action.options.effectId) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_effect;
|
||||
}
|
||||
if (action.options.suggest) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_suggested_post;
|
||||
}
|
||||
if (starsPaid) {
|
||||
action.options.starsApproved -= starsPaid;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_allow_paid_stars;
|
||||
@@ -104,7 +107,8 @@ void TodoLists::create(
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(_session, action.options.shortcutId),
|
||||
MTP_long(action.options.effectId),
|
||||
MTP_long(starsPaid)
|
||||
MTP_long(starsPaid),
|
||||
SuggestToMTP(action.options.suggest)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
if (clearCloudDraft) {
|
||||
history->finishSavingCloudDraft(
|
||||
|
@@ -1228,7 +1228,8 @@ void Updates::applyUpdatesNoPtsCheck(const MTPUpdates &updates) {
|
||||
MTPlong(), // effect
|
||||
MTPFactCheck(),
|
||||
MTPint(), // report_delivery_until_date
|
||||
MTPlong()), // paid_message_stars
|
||||
MTPlong(), // paid_message_stars
|
||||
MTPSuggestedPost()),
|
||||
MessageFlags(),
|
||||
NewMessageType::Unread);
|
||||
} break;
|
||||
@@ -1267,7 +1268,8 @@ void Updates::applyUpdatesNoPtsCheck(const MTPUpdates &updates) {
|
||||
MTPlong(), // effect
|
||||
MTPFactCheck(),
|
||||
MTPint(), // report_delivery_until_date
|
||||
MTPlong()), // paid_message_stars
|
||||
MTPlong(), // paid_message_stars
|
||||
MTPSuggestedPost()),
|
||||
MessageFlags(),
|
||||
NewMessageType::Unread);
|
||||
} break;
|
||||
|
Reference in New Issue
Block a user