Add td_api::setMessageFactCheck.
This commit is contained in:
parent
7709da3f44
commit
5e12908520
@ -1524,9 +1524,9 @@ inputMessageReplyToMessage chat_id:int53 message_id:int53 quote:inputTextQuote =
|
||||
inputMessageReplyToStory story_sender_chat_id:int53 story_id:int32 = InputMessageReplyTo;
|
||||
|
||||
|
||||
//@description Describes a fact check added to the message by an independent checker
|
||||
//@text Text of the fact check
|
||||
//@country_code A two-letter ISO 3166-1 alpha-2 country code of the country for which the fact check is shown
|
||||
//@description Describes a fact-check added to the message by an independent checker
|
||||
//@text Text of the fact-check
|
||||
//@country_code A two-letter ISO 3166-1 alpha-2 country code of the country for which the fact-check is shown
|
||||
factCheck text:formattedText country_code:string = FactCheck;
|
||||
|
||||
|
||||
@ -1562,7 +1562,7 @@ factCheck text:formattedText country_code:string = FactCheck;
|
||||
//@import_info Information about the initial message for messages created with importMessages; may be null if the message isn't imported
|
||||
//@interaction_info Information about interactions with the message; may be null if none
|
||||
//@unread_reactions Information about unread reactions added to the message
|
||||
//@fact_check Information about fact check added to the message; may be null if none
|
||||
//@fact_check Information about fact-check added to the message; may be null if none
|
||||
//@reply_to Information about the message or the story this message is replying to; may be null if none
|
||||
//@message_thread_id If non-zero, the identifier of the message thread the message belongs to; unique within the chat to which the message belongs
|
||||
//@saved_messages_topic_id Identifier of the Saved Messages topic for the message; 0 for messages not from Saved Messages
|
||||
@ -6231,7 +6231,7 @@ internalLinkTypeProxy server:string port:int32 type:ProxyType = InternalLinkType
|
||||
|
||||
//@description The link is a link to a chat by its username. Call searchPublicChat with the given chat username to process the link
|
||||
//-If the chat is found, open its profile information screen or the chat itself.
|
||||
//-If draft text isn't empty and the chat is a private chat, then put the draft text in the input field
|
||||
//-If draft text isn't empty and the chat is a private chat with a regular user, then put the draft text in the input field
|
||||
//@chat_username Username of the chat
|
||||
//@draft_text Draft text for message to send in the chat
|
||||
internalLinkTypePublicChat chat_username:string draft_text:string = InternalLinkType;
|
||||
@ -6965,10 +6965,10 @@ updateMessageMentionRead chat_id:int53 message_id:int53 unread_mention_count:int
|
||||
//@unread_reaction_count The new number of messages with unread reactions left in the chat
|
||||
updateMessageUnreadReactions chat_id:int53 message_id:int53 unread_reactions:vector<unreadReaction> unread_reaction_count:int32 = Update;
|
||||
|
||||
//@description A fact check added to a message was changed
|
||||
//@description A fact-check added to a message was changed
|
||||
//@chat_id Chat identifier
|
||||
//@message_id Message identifier
|
||||
//@fact_check The new fact check
|
||||
//@fact_check The new fact-check
|
||||
updateMessageFactCheck chat_id:int53 message_id:int53 fact_check:factCheck = Update;
|
||||
|
||||
//@description A message with a live location was viewed. When the update is received, the application is supposed to update the live location
|
||||
@ -8337,6 +8337,12 @@ editInlineMessageReplyMarkup inline_message_id:string reply_markup:ReplyMarkup =
|
||||
//@scheduling_state The new message scheduling state; pass null to send the message immediately
|
||||
editMessageSchedulingState chat_id:int53 message_id:int53 scheduling_state:MessageSchedulingState = Ok;
|
||||
|
||||
//@description Changes the fact-check of a message. Can be only used if getOption("can_edit_fact_check") == true
|
||||
//@chat_id The channel chat the message belongs to
|
||||
//@message_id Identifier of the message
|
||||
//@text New text of the fact-check; 0-1024 characters; pass null to remove it. Only Bold, Italic, and TextUrl entities are supported
|
||||
setMessageFactCheck chat_id:int53 message_id:int53 text:formattedText = Ok;
|
||||
|
||||
|
||||
//@description Sends a message on behalf of a business account; for bots only. Returns the message after it was sent
|
||||
//@business_connection_id Unique identifier of business connection on behalf of which to send the request
|
||||
|
@ -1322,6 +1322,49 @@ class GetFactCheckQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class EditMessageFactCheckQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
DialogId dialog_id_;
|
||||
|
||||
public:
|
||||
explicit EditMessageFactCheckQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id, MessageId message_id, const FormattedText &text) {
|
||||
dialog_id_ = dialog_id;
|
||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
||||
CHECK(input_peer != nullptr);
|
||||
auto server_message_id = message_id.get_server_message_id().get();
|
||||
if (text.text.empty()) {
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::messages_deleteFactCheck(std::move(input_peer), server_message_id)));
|
||||
} else {
|
||||
send_query(G()->net_query_creator().create(telegram_api::messages_editFactCheck(
|
||||
std::move(input_peer), server_message_id,
|
||||
get_input_text_with_entities(td_->user_manager_.get(), text, "messages_editFactCheck"))));
|
||||
}
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
static_assert(std::is_same<telegram_api::messages_deleteFactCheck::ReturnType,
|
||||
telegram_api::messages_editFactCheck::ReturnType>::value,
|
||||
"");
|
||||
auto result_ptr = fetch_result<telegram_api::messages_editFactCheck>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for EditMessageFactCheckQuery: " << to_string(ptr);
|
||||
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "EditMessageFactCheckQuery");
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class ReadMessagesContentsQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
@ -25674,6 +25717,27 @@ void MessagesManager::edit_message_scheduling_state(
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::set_message_fact_check(MessageFullId message_full_id,
|
||||
td_api::object_ptr<td_api::formattedText> &&text,
|
||||
Promise<Unit> &&promise) {
|
||||
auto dialog_id = message_full_id.get_dialog_id();
|
||||
TRY_RESULT_PROMISE(promise, d, check_dialog_access(dialog_id, false, AccessRights::Read, "set_message_fact_check"));
|
||||
|
||||
const Message *m = get_message_force(d, message_full_id.get_message_id(), "set_message_fact_check");
|
||||
if (m == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "Message not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->is_broadcast_channel(dialog_id) || !m->message_id.is_valid() ||
|
||||
!m->message_id.is_server()) {
|
||||
return promise.set_error(Status::Error(400, "Message fact-check can't be changed for the message"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, fact_check_text,
|
||||
get_formatted_text(td_, dialog_id, std::move(text), false, true, true, false));
|
||||
|
||||
td_->create_handler<EditMessageFactCheckQuery>(std::move(promise))->send(dialog_id, m->message_id, fact_check_text);
|
||||
}
|
||||
|
||||
bool MessagesManager::is_discussion_message(DialogId dialog_id, const Message *m) const {
|
||||
if (m == nullptr || m->forward_info == nullptr) {
|
||||
return false;
|
||||
|
@ -507,6 +507,9 @@ class MessagesManager final : public Actor {
|
||||
td_api::object_ptr<td_api::MessageSchedulingState> &&scheduling_state,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void set_message_fact_check(MessageFullId message_full_id, td_api::object_ptr<td_api::formattedText> &&text,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void get_dialog_filter_dialog_count(td_api::object_ptr<td_api::chatFolder> filter, Promise<int32> &&promise);
|
||||
|
||||
void add_dialog_list_for_dialog_filter(DialogFilterId dialog_filter_id);
|
||||
|
@ -5764,6 +5764,13 @@ void Td::on_request(uint64 id, td_api::editMessageSchedulingState &request) {
|
||||
std::move(request.scheduling_state_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setMessageFactCheck &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
messages_manager_->set_message_fact_check({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
||||
std::move(request.text_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::sendBusinessMessage &request) {
|
||||
CHECK_IS_BOT();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -893,6 +893,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::editMessageSchedulingState &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setMessageFactCheck &request);
|
||||
|
||||
void on_request(uint64 id, td_api::sendBusinessMessage &request);
|
||||
|
||||
void on_request(uint64 id, td_api::sendBusinessMessageAlbum &request);
|
||||
|
@ -5082,6 +5082,12 @@ class CliClient final : public Actor {
|
||||
get_args(args, chat_id, message_id, date);
|
||||
send_request(td_api::make_object<td_api::editMessageSchedulingState>(chat_id, message_id,
|
||||
as_message_scheduling_state(date)));
|
||||
} else if (op == "smfc") {
|
||||
ChatId chat_id;
|
||||
MessageId message_id;
|
||||
string message;
|
||||
get_args(args, chat_id, message_id, message);
|
||||
send_request(td_api::make_object<td_api::setMessageFactCheck>(chat_id, message_id, as_formatted_text(message)));
|
||||
} else {
|
||||
op_not_found_count++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user