Update response of getChatAvailableMessageSenders.

This commit is contained in:
levlam 2022-10-04 17:53:56 +03:00
parent bbd97ec59e
commit 8d1ee490ad
5 changed files with 33 additions and 12 deletions

View File

@ -795,6 +795,13 @@ messageSenderChat chat_id:int53 = MessageSender;
messageSenders total_count:int32 senders:vector<MessageSender> = MessageSenders;
//@description Represents a message sender, which can be used to send messages in a chat @sender Available message senders @needs_premium True, if Telegram Premium is needed to use the message sender
chatMessageSender sender:MessageSender needs_premium:Bool = ChatMessageSender;
//@description Represents a list of message senders, which can be used to send messages in a chat @senders List of available message senders
chatMessageSenders senders:vector<chatMessageSender> = ChatMessageSenders;
//@class MessageForwardOrigin @description Contains information about the origin of a forwarded message
//@description The message was originally sent by a known user @sender_user_id Identifier of the user that originally sent the message
@ -5056,7 +5063,7 @@ rateSpeechRecognition chat_id:int53 message_id:int53 is_good:Bool = Ok;
//@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;
getChatAvailableMessageSenders chat_id:int53 = ChatMessageSenders;
//@description Selects a message sender to send messages in a chat @chat_id Chat identifier @message_sender_id New message sender for the chat
setChatMessageSender chat_id:int53 message_sender_id:MessageSender = Ok;

View File

@ -15263,6 +15263,14 @@ int32 ContactsManager::get_channel_participant_count(ChannelId channel_id) const
return c->participant_count;
}
bool ContactsManager::get_channel_is_verified(ChannelId channel_id) const {
auto c = get_channel(channel_id);
if (c == nullptr) {
return false;
}
return c->is_verified;
}
bool ContactsManager::get_channel_sign_messages(ChannelId channel_id) const {
auto c = get_channel(channel_id);
if (c == nullptr) {

View File

@ -547,6 +547,7 @@ class ContactsManager final : public Actor {
int32 get_channel_date(ChannelId channel_id) const;
DialogParticipantStatus get_channel_status(ChannelId channel_id) const;
DialogParticipantStatus get_channel_permissions(ChannelId channel_id) const;
bool get_channel_is_verified(ChannelId channel_id) const;
int32 get_channel_participant_count(ChannelId channel_id) const;
bool get_channel_sign_messages(ChannelId channel_id) const;
bool get_channel_has_linked_channel(ChannelId channel_id) const;

View File

@ -25738,7 +25738,7 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, const
}
void MessagesManager::get_dialog_send_message_as_dialog_ids(
DialogId dialog_id, Promise<td_api::object_ptr<td_api::messageSenders>> &&promise, bool is_recursive) {
DialogId dialog_id, Promise<td_api::object_ptr<td_api::chatMessageSenders>> &&promise, bool is_recursive) {
TRY_STATUS_PROMISE(promise, G()->close_status());
const Dialog *d = get_dialog_force(dialog_id, "get_group_call_join_as");
@ -25749,21 +25749,21 @@ void MessagesManager::get_dialog_send_message_as_dialog_ids(
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>());
return promise.set_value(td_api::make_object<td_api::chatMessageSenders>());
}
CHECK(dialog_id.get_type() == DialogType::Channel);
if (created_public_broadcasts_inited_) {
auto senders = td_api::make_object<td_api::messageSenders>();
auto senders = td_api::make_object<td_api::chatMessageSenders>();
if (!created_public_broadcasts_.empty()) {
auto add_sender = [&senders, td = td_](DialogId dialog_id) {
senders->total_count_++;
senders->senders_.push_back(get_message_sender_object_const(td, dialog_id, "add_sender"));
auto add_sender = [&senders, td = td_](DialogId dialog_id, bool needs_premium) {
auto sender = get_message_sender_object_const(td, dialog_id, "add_sender");
senders->senders_.push_back(td_api::make_object<td_api::chatMessageSender>(std::move(sender), needs_premium));
};
if (is_anonymous_administrator(dialog_id, nullptr)) {
add_sender(dialog_id);
add_sender(dialog_id, false);
} else {
add_sender(get_my_dialog_id());
add_sender(get_my_dialog_id(), false);
}
auto sorted_channel_ids = transform(created_public_broadcasts_, [&](ChannelId channel_id) {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(channel_id);
@ -25771,8 +25771,13 @@ void MessagesManager::get_dialog_send_message_as_dialog_ids(
});
std::sort(sorted_channel_ids.begin(), sorted_channel_ids.end());
for (auto channel_id : sorted_channel_ids) {
add_sender(DialogId(ChannelId(channel_id.second)));
bool is_premium = td_->option_manager_->get_option_boolean("is_premium");
auto linked_channel_id = td_->contacts_manager_->get_channel_linked_channel_id(dialog_id.get_channel_id());
for (auto sorted_channel_id : sorted_channel_ids) {
ChannelId channel_id(sorted_channel_id.second);
bool needs_premium = !is_premium && channel_id != linked_channel_id &&
!td_->contacts_manager_->get_channel_is_verified(channel_id);
add_sender(DialogId(channel_id), needs_premium);
}
}
return promise.set_value(std::move(senders));

View File

@ -428,7 +428,7 @@ class MessagesManager final : public Actor {
void reload_voice_chat_on_search(const string &username);
void get_dialog_send_message_as_dialog_ids(DialogId dialog_id,
Promise<td_api::object_ptr<td_api::messageSenders>> &&promise,
Promise<td_api::object_ptr<td_api::chatMessageSenders>> &&promise,
bool is_recursive = false);
void set_dialog_default_send_message_as_dialog_id(DialogId dialog_id, DialogId message_sender_dialog_id,