Disallow messageInvoice copying.
This commit is contained in:
parent
a78fe2dfe5
commit
6b0637f402
@ -1867,7 +1867,7 @@ messageSchedulingStateSendWhenOnline = MessageSchedulingState;
|
|||||||
//@scheduling_state Message scheduling state. Messages sent to a secret chat, live location messages and self-destructing messages can't be scheduled
|
//@scheduling_state Message scheduling state. Messages sent to a secret chat, live location messages and self-destructing messages can't be scheduled
|
||||||
messageSendOptions disable_notification:Bool from_background:Bool scheduling_state:MessageSchedulingState = MessageSendOptions;
|
messageSendOptions disable_notification:Bool from_background:Bool scheduling_state:MessageSchedulingState = MessageSendOptions;
|
||||||
|
|
||||||
//@description Options to be used when a message content is copied without a link to the original message
|
//@description Options to be used when a message content is copied without a link to the original message. Service messages and messageInvoice can't be copied
|
||||||
//@send_copy True, if content of the message needs to be copied without a link to the original message. Always true if the message is forwarded to a secret chat
|
//@send_copy True, if content of the message needs to be copied without a link to the original message. Always true if the message is forwarded to a secret chat
|
||||||
//@replace_caption True, if media caption of the message copy needs to be replaced. Ignored if send_copy is false
|
//@replace_caption True, if media caption of the message copy needs to be replaced. Ignored if send_copy is false
|
||||||
//@new_caption New message caption. Ignored if replace_caption is false
|
//@new_caption New message caption. Ignored if replace_caption is false
|
||||||
|
@ -4235,6 +4235,9 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
|
|||||||
case MessageContentType::Game:
|
case MessageContentType::Game:
|
||||||
return make_unique<MessageGame>(*static_cast<const MessageGame *>(content));
|
return make_unique<MessageGame>(*static_cast<const MessageGame *>(content));
|
||||||
case MessageContentType::Invoice:
|
case MessageContentType::Invoice:
|
||||||
|
if (type == MessageContentDupType::Copy) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return make_unique<MessageInvoice>(*static_cast<const MessageInvoice *>(content));
|
return make_unique<MessageInvoice>(*static_cast<const MessageInvoice *>(content));
|
||||||
case MessageContentType::LiveLocation:
|
case MessageContentType::LiveLocation:
|
||||||
if (!to_secret && (type == MessageContentDupType::Send || type == MessageContentDupType::SendViaBot)) {
|
if (!to_secret && (type == MessageContentDupType::Send || type == MessageContentDupType::SendViaBot)) {
|
||||||
|
@ -25946,6 +25946,7 @@ void MessagesManager::do_forward_messages(DialogId to_dialog_id, DialogId from_d
|
|||||||
Result<MessageId> MessagesManager::forward_message(DialogId to_dialog_id, DialogId from_dialog_id, MessageId message_id,
|
Result<MessageId> MessagesManager::forward_message(DialogId to_dialog_id, DialogId from_dialog_id, MessageId message_id,
|
||||||
tl_object_ptr<td_api::messageSendOptions> &&options,
|
tl_object_ptr<td_api::messageSendOptions> &&options,
|
||||||
bool in_game_share, MessageCopyOptions &©_options) {
|
bool in_game_share, MessageCopyOptions &©_options) {
|
||||||
|
bool need_copy = copy_options.send_copy;
|
||||||
vector<MessageCopyOptions> all_copy_options;
|
vector<MessageCopyOptions> all_copy_options;
|
||||||
all_copy_options.push_back(std::move(copy_options));
|
all_copy_options.push_back(std::move(copy_options));
|
||||||
TRY_RESULT(result, forward_messages(to_dialog_id, from_dialog_id, {message_id}, std::move(options), in_game_share,
|
TRY_RESULT(result, forward_messages(to_dialog_id, from_dialog_id, {message_id}, std::move(options), in_game_share,
|
||||||
@ -25953,7 +25954,8 @@ Result<MessageId> MessagesManager::forward_message(DialogId to_dialog_id, Dialog
|
|||||||
CHECK(result.size() == 1);
|
CHECK(result.size() == 1);
|
||||||
auto sent_message_id = result[0];
|
auto sent_message_id = result[0];
|
||||||
if (sent_message_id == MessageId()) {
|
if (sent_message_id == MessageId()) {
|
||||||
return Status::Error(11, "Message can't be forwarded");
|
return Status::Error(400,
|
||||||
|
need_copy ? Slice("The message can't be copied") : Slice("The message can't be forwarded"));
|
||||||
}
|
}
|
||||||
return sent_message_id;
|
return sent_message_id;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user