Add td_api::editBusinessMessageMedia.
This commit is contained in:
parent
96c1b0081f
commit
9e466e2b9b
@ -8448,7 +8448,7 @@ sendBusinessMessageAlbum business_connection_id:string chat_id:int53 reply_to:In
|
||||
//@input_message_content New text content of the message. Must be of type inputMessageText
|
||||
editBusinessMessageText business_connection_id:string chat_id:int53 message_id:int53 reply_markup:ReplyMarkup input_message_content:InputMessageContent = BusinessMessage;
|
||||
|
||||
//@description Edits the content of a live location in a message message sent on behalf of a business account; for bots only
|
||||
//@description Edits the content of a live location in a message sent on behalf of a business account; for bots only
|
||||
//@business_connection_id Unique identifier of business connection on behalf of which the message was sent
|
||||
//@chat_id The chat the message belongs to
|
||||
//@message_id Identifier of the message
|
||||
@ -8460,6 +8460,13 @@ editBusinessMessageText business_connection_id:string chat_id:int53 message_id:i
|
||||
//@proximity_alert_radius The new maximum distance for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled
|
||||
editBusinessMessageLiveLocation business_connection_id:string chat_id:int53 message_id:int53 reply_markup:ReplyMarkup location:location live_period:int32 heading:int32 proximity_alert_radius:int32 = BusinessMessage;
|
||||
|
||||
//@description Edits the content of a message with an animation, an audio, a document, a photo or a video in a message sent on behalf of a business account; for bots only
|
||||
//@business_connection_id Unique identifier of business connection on behalf of which the message was sent
|
||||
//@chat_id The chat the message belongs to
|
||||
//@message_id Identifier of the message
|
||||
//@reply_markup The new message reply markup; pass null if none; for bots only
|
||||
//@input_message_content New content of the message. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, inputMessagePhoto or inputMessageVideo
|
||||
editBusinessMessageMedia business_connection_id:string chat_id:int53 message_id:int53 reply_markup:ReplyMarkup input_message_content:InputMessageContent = BusinessMessage;
|
||||
|
||||
//@description Checks validness of a name for a quick reply shortcut. Can be called synchronously @name The name of the shortcut; 1-32 characters
|
||||
checkQuickReplyShortcutName name:string = Ok;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "td/telegram/MessageQuote.h"
|
||||
#include "td/telegram/MessageSelfDestructType.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/ReplyMarkup.h"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/Td.h"
|
||||
@ -106,6 +107,7 @@ struct BusinessConnectionManager::BusinessConnection {
|
||||
struct BusinessConnectionManager::PendingMessage {
|
||||
BusinessConnectionId business_connection_id_;
|
||||
DialogId dialog_id_;
|
||||
MessageId message_id_;
|
||||
MessageInputReplyTo input_reply_to_;
|
||||
string send_emoji_;
|
||||
MessageSelfDestructType ttl_;
|
||||
@ -1221,6 +1223,80 @@ void BusinessConnectionManager::edit_business_message_live_location(
|
||||
std::move(input_reply_markup));
|
||||
}
|
||||
|
||||
void BusinessConnectionManager::edit_business_message_media(
|
||||
BusinessConnectionId business_connection_id, DialogId dialog_id, MessageId message_id,
|
||||
td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content,
|
||||
Promise<td_api::object_ptr<td_api::businessMessage>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, check_business_connection(business_connection_id, dialog_id));
|
||||
TRY_STATUS_PROMISE(promise, check_business_message_id(message_id));
|
||||
|
||||
if (input_message_content == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "Can't edit message without new content"));
|
||||
}
|
||||
int32 new_message_content_type = input_message_content->get_id();
|
||||
if (new_message_content_type != td_api::inputMessageAnimation::ID &&
|
||||
new_message_content_type != td_api::inputMessageAudio::ID &&
|
||||
new_message_content_type != td_api::inputMessageDocument::ID &&
|
||||
new_message_content_type != td_api::inputMessagePhoto::ID &&
|
||||
new_message_content_type != td_api::inputMessageVideo::ID) {
|
||||
return promise.set_error(Status::Error(400, "Unsupported input message content type"));
|
||||
}
|
||||
|
||||
bool is_premium = td_->option_manager_->get_option_boolean("is_premium");
|
||||
TRY_RESULT_PROMISE(promise, content,
|
||||
get_input_message_content(DialogId(), std::move(input_message_content), td_, is_premium));
|
||||
if (!content.ttl.is_empty()) {
|
||||
return promise.set_error(Status::Error(400, "Can't enable self-destruction for media"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, new_reply_markup,
|
||||
get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false, true));
|
||||
|
||||
auto input_media = get_input_media(content.content.get(), td_, MessageSelfDestructType(), string(), true);
|
||||
if (input_media != nullptr) {
|
||||
auto file_id = get_message_content_any_file_id(content.content.get());
|
||||
CHECK(file_id.is_valid());
|
||||
FileView file_view = td_->file_manager_->get_file_view(file_id);
|
||||
if (file_view.has_remote_location()) {
|
||||
const FormattedText *caption = get_message_content_caption(content.content.get());
|
||||
td_->create_handler<EditBusinessMessageQuery>(std::move(promise))
|
||||
->send(1 << 11, business_connection_id, dialog_id, message_id, caption == nullptr ? "" : caption->text,
|
||||
get_input_message_entities(td_->user_manager_.get(), caption, "edit_business_message_media"),
|
||||
std::move(input_media), content.invert_media,
|
||||
get_input_reply_markup(td_->user_manager_.get(), new_reply_markup));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto message = create_business_message_to_send(business_connection_id, dialog_id, MessageInputReplyTo(), false, false,
|
||||
MessageEffectId(), std::move(new_reply_markup), std::move(content));
|
||||
message->message_id_ = message_id;
|
||||
|
||||
upload_media(std::move(message), PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](
|
||||
Result<UploadMediaResult> &&result) mutable {
|
||||
send_closure(actor_id, &BusinessConnectionManager::do_edit_business_message_media, std::move(result),
|
||||
std::move(promise));
|
||||
}));
|
||||
}
|
||||
|
||||
void BusinessConnectionManager::do_edit_business_message_media(
|
||||
Result<UploadMediaResult> &&result, Promise<td_api::object_ptr<td_api::businessMessage>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
TRY_RESULT_PROMISE(promise, upload_result, std::move(result));
|
||||
CHECK(upload_result.input_media_ != nullptr);
|
||||
|
||||
auto message = std::move(upload_result.message_);
|
||||
CHECK(message != nullptr);
|
||||
const FormattedText *caption = get_message_content_caption(message->content_.get());
|
||||
td_->create_handler<EditBusinessMessageQuery>(std::move(promise))
|
||||
->send(1 << 11, message->business_connection_id_, message->dialog_id_, message->message_id_,
|
||||
caption == nullptr ? "" : caption->text,
|
||||
get_input_message_entities(td_->user_manager_.get(), caption, "do_edit_business_message_media"),
|
||||
std::move(upload_result.input_media_), message->invert_media_,
|
||||
get_input_reply_markup(td_->user_manager_.get(), message->reply_markup_));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::updateBusinessConnection> BusinessConnectionManager::get_update_business_connection(
|
||||
const BusinessConnection *connection) const {
|
||||
return td_api::make_object<td_api::updateBusinessConnection>(connection->get_business_connection_object(td_));
|
||||
|
@ -85,6 +85,11 @@ class BusinessConnectionManager final : public Actor {
|
||||
int32 heading, int32 proximity_alert_radius,
|
||||
Promise<td_api::object_ptr<td_api::businessMessage>> &&promise);
|
||||
|
||||
void edit_business_message_media(BusinessConnectionId business_connection_id, DialogId dialog_id,
|
||||
MessageId message_id, td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content,
|
||||
Promise<td_api::object_ptr<td_api::businessMessage>> &&promise);
|
||||
|
||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||
|
||||
private:
|
||||
@ -173,6 +178,9 @@ class BusinessConnectionManager final : public Actor {
|
||||
void process_sent_business_message_album(telegram_api::object_ptr<telegram_api::Updates> &&updates_ptr,
|
||||
Promise<td_api::object_ptr<td_api::businessMessages>> &&promise);
|
||||
|
||||
void do_edit_business_message_media(Result<UploadMediaResult> &&result,
|
||||
Promise<td_api::object_ptr<td_api::businessMessage>> &&promise);
|
||||
|
||||
td_api::object_ptr<td_api::updateBusinessConnection> get_update_business_connection(
|
||||
const BusinessConnection *connection) const;
|
||||
|
||||
|
@ -5823,6 +5823,15 @@ void Td::on_request(uint64 id, td_api::editBusinessMessageLiveLocation &request)
|
||||
request.live_period_, request.heading_, request.proximity_alert_radius_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::editBusinessMessageMedia &request) {
|
||||
CHECK_IS_BOT();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
business_connection_manager_->edit_business_message_media(
|
||||
BusinessConnectionId(std::move(request.business_connection_id_)), DialogId(request.chat_id_),
|
||||
MessageId(request.message_id_), std::move(request.reply_markup_), std::move(request.input_message_content_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::loadQuickReplyShortcuts &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
|
@ -920,6 +920,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::editBusinessMessageLiveLocation &request);
|
||||
|
||||
void on_request(uint64 id, td_api::editBusinessMessageMedia &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::loadQuickReplyShortcuts &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setQuickReplyShortcutName &request);
|
||||
|
@ -5074,9 +5074,15 @@ class CliClient final : public Actor {
|
||||
MessageId message_id;
|
||||
string document;
|
||||
get_args(args, chat_id, message_id, document);
|
||||
send_request(td_api::make_object<td_api::editMessageMedia>(
|
||||
chat_id, message_id, nullptr,
|
||||
td_api::make_object<td_api::inputMessageDocument>(as_input_file(document), nullptr, false, as_caption(""))));
|
||||
auto input_document =
|
||||
td_api::make_object<td_api::inputMessageDocument>(as_input_file(document), nullptr, false, as_caption(""));
|
||||
if (!business_connection_id_.empty()) {
|
||||
send_request(td_api::make_object<td_api::editBusinessMessageMedia>(business_connection_id_, chat_id, message_id,
|
||||
nullptr, std::move(input_document)));
|
||||
} else {
|
||||
send_request(
|
||||
td_api::make_object<td_api::editMessageMedia>(chat_id, message_id, nullptr, std::move(input_document)));
|
||||
}
|
||||
} else if (op == "eqrmd") {
|
||||
ShortcutId shortcut_id;
|
||||
MessageId message_id;
|
||||
@ -5090,11 +5096,16 @@ class CliClient final : public Actor {
|
||||
MessageId message_id;
|
||||
string photo;
|
||||
get_args(args, chat_id, message_id, photo);
|
||||
send_request(td_api::make_object<td_api::editMessageMedia>(
|
||||
chat_id, message_id, nullptr,
|
||||
td_api::make_object<td_api::inputMessagePhoto>(as_input_file(photo), as_input_thumbnail(photo), Auto(), 0, 0,
|
||||
as_caption(""), show_caption_above_media_,
|
||||
get_message_self_destruct_type(), has_spoiler_)));
|
||||
auto input_photo = td_api::make_object<td_api::inputMessagePhoto>(
|
||||
as_input_file(photo), as_input_thumbnail(photo), Auto(), 0, 0, as_caption(""), show_caption_above_media_,
|
||||
get_message_self_destruct_type(), has_spoiler_);
|
||||
if (!business_connection_id_.empty()) {
|
||||
send_request(td_api::make_object<td_api::editBusinessMessageMedia>(business_connection_id_, chat_id, message_id,
|
||||
nullptr, std::move(input_photo)));
|
||||
} else {
|
||||
send_request(
|
||||
td_api::make_object<td_api::editMessageMedia>(chat_id, message_id, nullptr, std::move(input_photo)));
|
||||
}
|
||||
} else if (op == "eqrmp") {
|
||||
ShortcutId shortcut_id;
|
||||
MessageId message_id;
|
||||
@ -5111,11 +5122,16 @@ class CliClient final : public Actor {
|
||||
string video;
|
||||
string thumbnail;
|
||||
get_args(args, chat_id, message_id, video, thumbnail);
|
||||
send_request(td_api::make_object<td_api::editMessageMedia>(
|
||||
chat_id, message_id, nullptr,
|
||||
td_api::make_object<td_api::inputMessageVideo>(as_input_file(video), as_input_thumbnail(thumbnail), Auto(), 1,
|
||||
2, 3, true, as_caption(""), show_caption_above_media_,
|
||||
get_message_self_destruct_type(), has_spoiler_)));
|
||||
auto input_video = td_api::make_object<td_api::inputMessageVideo>(
|
||||
as_input_file(video), as_input_thumbnail(thumbnail), Auto(), 1, 2, 3, true, as_caption(""),
|
||||
show_caption_above_media_, get_message_self_destruct_type(), has_spoiler_);
|
||||
if (!business_connection_id_.empty()) {
|
||||
send_request(td_api::make_object<td_api::editBusinessMessageMedia>(business_connection_id_, chat_id, message_id,
|
||||
nullptr, std::move(input_video)));
|
||||
} else {
|
||||
send_request(
|
||||
td_api::make_object<td_api::editMessageMedia>(chat_id, message_id, nullptr, std::move(input_video)));
|
||||
}
|
||||
} else if (op == "emll") {
|
||||
ChatId chat_id;
|
||||
MessageId message_id;
|
||||
|
Loading…
Reference in New Issue
Block a user