diff --git a/td/telegram/ChatManager.cpp b/td/telegram/ChatManager.cpp index f652a142b..0700a91ae 100644 --- a/td/telegram/ChatManager.cpp +++ b/td/telegram/ChatManager.cpp @@ -7850,6 +7850,18 @@ bool ChatManager::get_channel_sign_messages(const Channel *c) { return c->sign_messages; } +bool ChatManager::get_channel_show_message_sender(ChannelId channel_id) const { + auto c = get_channel(channel_id); + if (c == nullptr) { + return false; + } + return get_channel_show_message_sender(c); +} + +bool ChatManager::get_channel_show_message_sender(const Channel *c) { + return c->show_message_sender; +} + bool ChatManager::get_channel_has_linked_channel(ChannelId channel_id) const { auto c = get_channel(channel_id); if (c == nullptr) { diff --git a/td/telegram/ChatManager.h b/td/telegram/ChatManager.h index 04d4c6057..911e6be8d 100644 --- a/td/telegram/ChatManager.h +++ b/td/telegram/ChatManager.h @@ -351,6 +351,7 @@ class ChatManager final : public Actor { bool get_channel_is_fake(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_show_message_sender(ChannelId channel_id) const; bool get_channel_has_linked_channel(ChannelId channel_id) const; bool get_channel_join_request(ChannelId channel_id) const; bool get_channel_can_be_deleted(ChannelId channel_id) const; @@ -703,6 +704,7 @@ class ChatManager final : public Actor { static DialogParticipantStatus get_channel_status(const Channel *c); DialogParticipantStatus get_channel_permissions(ChannelId channel_id, const Channel *c) const; static bool get_channel_sign_messages(const Channel *c); + static bool get_channel_show_message_sender(const Channel *c); static bool get_channel_has_linked_channel(const Channel *c); static bool get_channel_can_be_deleted(const Channel *c); static bool get_channel_join_to_send(const Channel *c); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 48a8db4d0..9c139b3d1 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -23288,10 +23288,14 @@ unique_ptr MessagesManager::create_message_to_send( bool is_channel_post = td_->dialog_manager_->is_broadcast_channel(dialog_id); if (is_channel_post) { // sender of the post can be hidden - if (!is_scheduled && td_->chat_manager_->get_channel_sign_messages(dialog_id.get_channel_id())) { - m->author_signature = td_->user_manager_->get_user_title(my_id); + if (td_->chat_manager_->get_channel_show_message_sender(dialog_id.get_channel_id())) { + m->sender_user_id = my_id; + } else { + if (!is_scheduled && td_->chat_manager_->get_channel_sign_messages(dialog_id.get_channel_id())) { + m->author_signature = td_->user_manager_->get_user_title(my_id); + } + m->sender_dialog_id = dialog_id; } - m->sender_dialog_id = dialog_id; } else { if (send_as_dialog_id.is_valid()) { if (send_as_dialog_id.get_type() == DialogType::User) { @@ -27408,7 +27412,7 @@ Result MessagesManager::add_local_message( auto message = make_unique(); auto *m = message.get(); m->message_id = message_id; - if (is_channel_post) { + if (is_channel_post && !td_->chat_manager_->get_channel_show_message_sender(dialog_id.get_channel_id())) { // sender of the post can be hidden if (td_->chat_manager_->get_channel_sign_messages(dialog_id.get_channel_id())) { m->author_signature = td_->user_manager_->get_user_title(sender_user_id);