Add getChatAvailableMessageSenders.
This commit is contained in:
parent
fe8e521a41
commit
108fca1e6e
@ -4372,6 +4372,9 @@ getMessageEmbeddingCode chat_id:int53 message_id:int53 for_album:Bool = Text;
|
||||
getMessageLinkInfo url:string = MessageLinkInfo;
|
||||
|
||||
|
||||
//@description Returns list of message sender identifiers, which can be used to send messages in a chat @chat_id Chat identifier
|
||||
getChatAvailableMessageSenders chat_id:int53 = MessageSenders;
|
||||
|
||||
//@description Sends a message. Returns the sent message
|
||||
//@chat_id Target chat
|
||||
//@message_thread_id If not 0, a message thread identifier in which the message will be sent
|
||||
|
@ -2904,6 +2904,47 @@ class ReadMentionsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetSendAsQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::messageSenders>> promise_;
|
||||
DialogId dialog_id_;
|
||||
|
||||
public:
|
||||
explicit GetSendAsQuery(Promise<td_api::object_ptr<td_api::messageSenders>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id) {
|
||||
dialog_id_ = dialog_id;
|
||||
|
||||
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
|
||||
if (input_peer == nullptr) {
|
||||
return promise_.set_error(Status::Error(400, "Chat is not accessible"));
|
||||
}
|
||||
|
||||
send_query(G()->net_query_creator().create(telegram_api::channels_getSendAs(std::move(input_peer))));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::channels_getSendAs>(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 GetSendAsQuery: " << to_string(ptr);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetSendAsQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetSendAsQuery");
|
||||
|
||||
promise_.set_value(convert_message_senders_object(td_, ptr->peers_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadMentionsQuery");
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class SendSecretMessageActor final : public NetActor {
|
||||
int64 random_id_;
|
||||
|
||||
@ -23853,6 +23894,23 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, const
|
||||
add_reply_markup_dependencies(dependencies, m->reply_markup.get());
|
||||
}
|
||||
|
||||
void MessagesManager::get_dialog_send_message_as(DialogId dialog_id,
|
||||
Promise<td_api::object_ptr<td_api::messageSenders>> &&promise) {
|
||||
const Dialog *d = get_dialog_force(dialog_id, "get_group_call_join_as");
|
||||
if (d == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access chat"));
|
||||
}
|
||||
if (!d->default_send_message_as_dialog_id.is_valid()) {
|
||||
return promise.set_value(td_api::make_object<td_api::messageSenders>());
|
||||
}
|
||||
CHECK(d->dialog_id.get_type() == DialogType::Channel);
|
||||
|
||||
td_->create_handler<GetSendAsQuery>(std::move(promise))->send(dialog_id);
|
||||
}
|
||||
|
||||
class MessagesManager::SendMessageLogEvent {
|
||||
public:
|
||||
DialogId dialog_id;
|
||||
|
@ -389,6 +389,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void reload_voice_chat_on_search(const string &username);
|
||||
|
||||
void get_dialog_send_message_as(DialogId dialog_id, Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
|
||||
|
||||
Result<td_api::object_ptr<td_api::message>> send_message(
|
||||
DialogId dialog_id, MessageId top_thread_message_id, MessageId reply_to_message_id,
|
||||
tl_object_ptr<td_api::messageSendOptions> &&options, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
|
@ -5458,6 +5458,12 @@ void Td::on_request(uint64 id, const td_api::readAllChatMentions &request) {
|
||||
messages_manager_->read_all_dialog_mentions(DialogId(request.chat_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getChatAvailableMessageSenders &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
messages_manager_->get_dialog_send_message_as(DialogId(request.chat_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::sendMessage &request) {
|
||||
auto r_sent_message = messages_manager_->send_message(
|
||||
DialogId(request.chat_id_), MessageId(request.message_thread_id_), MessageId(request.reply_to_message_id_),
|
||||
|
@ -654,6 +654,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::readAllChatMentions &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getChatAvailableMessageSenders &request);
|
||||
|
||||
void on_request(uint64 id, td_api::sendMessage &request);
|
||||
|
||||
void on_request(uint64 id, td_api::sendMessageAlbum &request);
|
||||
|
@ -3229,6 +3229,8 @@ class CliClient final : public Actor {
|
||||
schedule_date_ = std::move(args);
|
||||
} else if (op == "smti") {
|
||||
message_thread_id_ = std::move(args);
|
||||
} else if (op == "gcams") {
|
||||
send_request(td_api::make_object<td_api::getChatAvailableMessageSenders>(as_chat_id(args)));
|
||||
} else if (op == "sm" || op == "sms" || op == "smr" || op == "smf") {
|
||||
string chat_id;
|
||||
string reply_to_message_id;
|
||||
|
Loading…
Reference in New Issue
Block a user