Support pinned messages in private and basic group chats.

GitOrigin-RevId: b08ba37a6b27f871e394b5e4ac1864766f046134
This commit is contained in:
levlam 2019-02-01 15:19:32 +03:00
parent 563a88fde4
commit 591576e6a4
12 changed files with 272 additions and 273 deletions

View File

@ -314,7 +314,7 @@ chatMemberStatusCreator is_member:Bool = ChatMemberStatus;
//@can_delete_messages True, if the administrator can delete messages of other users
//@can_invite_users True, if the administrator can invite new users to the chat
//@can_restrict_members True, if the administrator can restrict, ban, or unban chat members
//@can_pin_messages True, if the administrator can pin messages; applicable to supergroups only
//@can_pin_messages True, if the administrator can pin messages; applicable to groups only
//@can_promote_members True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that were directly or indirectly promoted by him
chatMemberStatusAdministrator can_be_edited:Bool can_change_info:Bool can_post_messages:Bool can_edit_messages:Bool can_delete_messages:Bool can_invite_users:Bool can_restrict_members:Bool can_pin_messages:Bool can_promote_members:Bool = ChatMemberStatus;
@ -424,10 +424,9 @@ supergroup id:int32 username:string date:int32 status:ChatMemberStatus member_co
//@is_all_history_available True, if new chat members will have access to old messages. In public supergroups and both public and private channels, old messages are always available, so this option affects only private supergroups. The value of this field is only available for chat administrators
//@sticker_set_id Identifier of the supergroup sticker set; 0 if none
//@invite_link Invite link for this chat
//@pinned_message_id Identifier of the pinned message in the chat; 0 if none
//@upgraded_from_basic_group_id Identifier of the basic group from which supergroup was upgraded; 0 if none
//@upgraded_from_max_message_id Identifier of the last message in the basic group from which supergroup was upgraded; 0 if none
supergroupFullInfo description:string member_count:int32 administrator_count:int32 restricted_count:int32 banned_count:int32 can_get_members:Bool can_set_username:Bool can_set_sticker_set:Bool is_all_history_available:Bool sticker_set_id:int64 invite_link:string pinned_message_id:int53 upgraded_from_basic_group_id:int32 upgraded_from_max_message_id:int53 = SupergroupFullInfo;
supergroupFullInfo description:string member_count:int32 administrator_count:int32 restricted_count:int32 banned_count:int32 can_get_members:Bool can_set_username:Bool can_set_sticker_set:Bool is_all_history_available:Bool sticker_set_id:int64 invite_link:string upgraded_from_basic_group_id:int32 upgraded_from_max_message_id:int53 = SupergroupFullInfo;
//@class SecretChatState @description Describes the current secret chat state
@ -575,10 +574,11 @@ chatTypeSecret secret_chat_id:int32 user_id:int32 = ChatType;
//@last_read_outbox_message_id Identifier of the last read outgoing message
//@unread_mention_count Number of unread messages with a mention/reply in the chat
//@notification_settings Notification settings for this chat
//@pinned_message_id Identifier of the pinned message in the chat; 0 if none
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
//@draft_message A draft of a message in the chat; may be null
//@client_data Contains client-specific data associated with the chat. (For example, the chat position or local chat notification settings can be stored here.) Persistent if a message database is used
chat id:int53 type:ChatType title:string photo:chatPhoto last_message:message order:int64 is_pinned:Bool is_marked_as_unread:Bool is_sponsored:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:chatNotificationSettings reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
chat id:int53 type:ChatType title:string photo:chatPhoto last_message:message order:int64 is_pinned:Bool is_marked_as_unread:Bool is_sponsored:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:chatNotificationSettings pinned_message_id:int53 reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
//@description Represents a list of chats @chat_ids List of chat identifiers
chats chat_ids:vector<int53> = Chats;
@ -1175,7 +1175,7 @@ messageChatUpgradeTo supergroup_id:int32 = MessageContent;
//@description A supergroup has been created from a basic group @title Title of the newly created supergroup @basic_group_id The identifier of the original basic group
messageChatUpgradeFrom title:string basic_group_id:int32 = MessageContent;
//@description A message has been pinned @message_id Identifier of the pinned message, can be an identifier of a deleted message
//@description A message has been pinned @message_id Identifier of the pinned message, can be an identifier of a deleted message or 0
messagePinMessage message_id:int53 = MessageContent;
//@description A screenshot of a message in the chat has been taken
@ -2266,6 +2266,9 @@ updateChatNotificationSettings chat_id:int53 notification_settings:chatNotificat
//@description Notification settings for some type of chats were updated @scope Types of chats for which notification settings were updated @notification_settings The new notification settings
updateScopeNotificationSettings scope:NotificationSettingsScope notification_settings:scopeNotificationSettings = Update;
//@description The chat pinned message was changed @chat_id Chat identifier @pinned_message_id The new identifier of the pinned message; 0 if there is no pinned message in the chat
updateChatPinnedMessage chat_id:int53 pinned_message_id:int53 = Update;
//@description The default chat reply markup was changed. Can occur because new messages with reply markup were received or because an old reply markup was hidden by the user
//@chat_id Chat identifier @reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
updateChatReplyMarkup chat_id:int53 reply_markup_message_id:int53 = Update;
@ -2911,6 +2914,12 @@ toggleChatDefaultDisableNotification chat_id:int53 default_disable_notification:
//@description Changes client data associated with a chat @chat_id Chat identifier @client_data New value of client_data
setChatClientData chat_id:int53 client_data:string = Ok;
//@description Pins a message in a chat; requires appropriate administrator rights in the group or channel @chat_id Identifier of the chat @message_id Identifier of the new pinned message @disable_notification True, if there should be no notification about the pinned message
pinChatMessage chat_id:int53 message_id:int53 disable_notification:Bool = Ok;
//@description Removes the pinned message from a chat; requires appropriate administrator rights in the group or channel @chat_id Identifier of the chat
unpinChatMessage chat_id:int53 = Ok;
//@description Adds current user as a new member to a chat. Private and secret chats can't be joined using this method @chat_id Chat identifier
joinChat chat_id:int53 = Ok;
@ -3219,12 +3228,6 @@ toggleSupergroupIsAllHistoryAvailable supergroup_id:int32 is_all_history_availab
//@description Changes information about a supergroup or channel; requires appropriate administrator rights @supergroup_id Identifier of the supergroup or channel @param_description New supergroup or channel description; 0-255 characters
setSupergroupDescription supergroup_id:int32 description:string = Ok;
//@description Pins a message in a supergroup or channel; requires appropriate administrator rights in the supergroup or channel @supergroup_id Identifier of the supergroup or channel @message_id Identifier of the new pinned message @disable_notification True, if there should be no notification about the pinned message
pinSupergroupMessage supergroup_id:int32 message_id:int53 disable_notification:Bool = Ok;
//@description Removes the pinned message from a supergroup or channel; requires appropriate administrator rights in the supergroup or channel @supergroup_id Identifier of the supergroup or channel
unpinSupergroupMessage supergroup_id:int32 = Ok;
//@description Reports some messages from a user in a supergroup as spam; requires administrator rights in the supergroup @supergroup_id Supergroup identifier @user_id User identifier @message_ids Identifiers of messages sent in the supergroup by the user. This list must be non-empty
reportSupergroupSpam supergroup_id:int32 user_id:int32 message_ids:vector<int53> = Ok;

Binary file not shown.

View File

@ -1229,57 +1229,6 @@ class EditChannelAboutQuery : public Td::ResultHandler {
}
};
class UpdateChannelPinnedMessageQuery : public Td::ResultHandler {
Promise<Unit> promise_;
ChannelId channel_id_;
MessageId message_id_;
public:
explicit UpdateChannelPinnedMessageQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(ChannelId channel_id, MessageId message_id, bool disable_notification) {
channel_id_ = channel_id;
message_id_ = message_id;
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
int32 flags = 0;
if (disable_notification) {
flags |= telegram_api::channels_updatePinnedMessage::SILENT_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_updatePinnedMessage(
flags, false /*ignored*/, std::move(input_channel), message_id.get_server_message_id().get()))));
}
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::channels_updatePinnedMessage>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for updateChannelPinnedMessage: " << to_string(ptr);
td->updates_manager_->on_get_updates(std::move(ptr));
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) override {
if (status.message() == "CHAT_NOT_MODIFIED") {
td->contacts_manager_->on_update_channel_pinned_message(channel_id_, message_id_);
if (!td->auth_manager_->is_bot()) {
promise_.set_value(Unit());
return;
}
} else {
td->contacts_manager_->on_get_channel_error(channel_id_, status, "UpdateChannelPinnedMessageQuery");
}
promise_.set_error(std::move(status));
}
};
class ReportChannelSpamQuery : public Td::ResultHandler {
Promise<Unit> promise_;
ChannelId channel_id_;
@ -4159,44 +4108,6 @@ void ContactsManager::set_channel_description(ChannelId channel_id, const string
td_->create_handler<EditChannelAboutQuery>(std::move(promise))->send(channel_id, new_description);
}
void ContactsManager::pin_channel_message(ChannelId channel_id, MessageId message_id, bool disable_notification,
Promise<Unit> &&promise) {
auto c = get_channel(channel_id);
if (c == nullptr) {
return promise.set_error(Status::Error(6, "Supergroup not found"));
}
auto channel_status = get_channel_status(c);
bool can_pin = c->is_megagroup ? channel_status.can_pin_messages() : channel_status.can_edit_messages();
if (!can_pin) {
return promise.set_error(Status::Error(6, "Not enough rights to pin a message"));
}
if (!td_->messages_manager_->have_message({DialogId(channel_id), message_id})) {
return promise.set_error(Status::Error(6, "Message not found"));
}
if (!message_id.is_server()) {
return promise.set_error(Status::Error(6, "Message can't be pinned"));
}
td_->create_handler<UpdateChannelPinnedMessageQuery>(std::move(promise))
->send(channel_id, message_id, disable_notification);
}
void ContactsManager::unpin_channel_message(ChannelId channel_id, Promise<Unit> &&promise) {
auto c = get_channel(channel_id);
if (c == nullptr) {
return promise.set_error(Status::Error(6, "Supergroup not found"));
}
auto channel_status = get_channel_status(c);
bool can_unpin = c->is_megagroup ? channel_status.can_pin_messages() : channel_status.can_edit_messages();
if (!can_unpin) {
return promise.set_error(Status::Error(6, "Not enough rights to unpin a message"));
}
td_->create_handler<UpdateChannelPinnedMessageQuery>(std::move(promise))->send(channel_id, MessageId(), false);
}
void ContactsManager::report_channel_spam(ChannelId channel_id, UserId user_id, const vector<MessageId> &message_ids,
Promise<Unit> &&promise) {
auto c = get_channel(channel_id);
@ -4591,15 +4502,6 @@ string ContactsManager::get_channel_invite_link(
return channel_full->invite_link;
}
MessageId ContactsManager::get_channel_pinned_message_id(
ChannelId channel_id) { // should be non-const to update ChannelFull cache
auto channel_full = get_channel_full(channel_id);
if (channel_full == nullptr) {
return MessageId();
}
return channel_full->pinned_message_id;
}
void ContactsManager::delete_chat_participant(ChatId chat_id, UserId user_id, Promise<Unit> &&promise) {
const Chat *c = get_chat(chat_id);
if (c == nullptr) {
@ -6489,6 +6391,12 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
on_update_user_links(user_id, std::move(user_full->link_->my_link_), std::move(user_full->link_->foreign_link_));
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(user_id), std::move(user_full->notify_settings_));
MessageId pinned_message_id;
if ((user_full->flags_ & USER_FULL_FLAG_HAS_PINNED_MESSAGE) != 0) {
pinned_message_id = MessageId(ServerMessageId(user_full->pinned_msg_id_));
}
td_->messages_manager_->on_update_dialog_pinned_message_id(DialogId(user_id), pinned_message_id);
UserFull *user = &users_full_[user_id];
user->expires_at = Time::now() + USER_FULL_EXPIRE_TIME;
user->is_inited = true;
@ -6677,6 +6585,12 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
return;
}
MessageId pinned_message_id;
if ((chat_full->flags_ & CHAT_FULL_FLAG_HAS_PINNED_MESSAGE) != 0) {
pinned_message_id = MessageId(ServerMessageId(chat_full->pinned_msg_id_));
}
td_->messages_manager_->on_update_dialog_pinned_message_id(DialogId(chat_id), pinned_message_id);
ChatFull *chat = &chats_full_[chat_id];
on_update_chat_full_invite_link(chat, std::move(chat_full->exported_invite_));
@ -6768,9 +6682,11 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
on_update_channel_full_invite_link(channel, std::move(channel_full->exported_invite_));
MessageId pinned_message_id;
if ((channel_full->flags_ & CHANNEL_FULL_FLAG_HAS_PINNED_MESSAGE) != 0) {
on_update_channel_full_pinned_message(channel, MessageId(ServerMessageId(channel_full->pinned_msg_id_)));
pinned_message_id = MessageId(ServerMessageId(channel_full->pinned_msg_id_));
}
td_->messages_manager_->on_update_dialog_pinned_message_id(DialogId(channel_id), pinned_message_id);
for (auto &bot_info : channel_full->bot_info_) {
on_update_bot_info(std::move(bot_info));
@ -6779,7 +6695,7 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
ChatId migrated_from_chat_id;
MessageId migrated_from_max_message_id;
if (channel_full->flags_ & CHANNEL_FULL_FLAG_MIGRATED_FROM) {
if ((channel_full->flags_ & CHANNEL_FULL_FLAG_MIGRATED_FROM) != 0) {
migrated_from_chat_id = ChatId(channel_full->migrated_from_chat_id_);
migrated_from_max_message_id = MessageId(ServerMessageId(channel_full->migrated_from_max_id_));
}
@ -8164,19 +8080,6 @@ void ContactsManager::on_update_channel_username(Channel *c, ChannelId channel_i
}
}
void ContactsManager::on_update_channel_full_pinned_message(ChannelFull *channel_full, MessageId message_id) {
if (!message_id.is_valid() && message_id != MessageId()) {
LOG(ERROR) << "Receive " << message_id << " as pinned message";
return;
}
CHECK(channel_full != nullptr);
if (channel_full->pinned_message_id != message_id) {
channel_full->pinned_message_id = message_id;
channel_full->is_changed = true;
}
}
void ContactsManager::on_update_channel_description(ChannelId channel_id, string &&description) {
if (!channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id;
@ -8211,20 +8114,6 @@ void ContactsManager::on_update_channel_sticker_set(ChannelId channel_id, int64
}
}
void ContactsManager::on_update_channel_pinned_message(ChannelId channel_id, MessageId message_id) {
if (!channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id;
return;
}
auto channel_full = get_channel_full(channel_id);
if (channel_full == nullptr) {
return;
}
on_update_channel_full_pinned_message(channel_full, message_id);
update_channel_full(channel_full, channel_id);
}
void ContactsManager::on_update_channel_is_all_history_available(ChannelId channel_id, bool is_all_history_available) {
if (!channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id;
@ -10038,7 +9927,7 @@ tl_object_ptr<td_api::supergroupFullInfo> ContactsManager::get_supergroup_full_i
channel_full->description, channel_full->participant_count, channel_full->administrator_count,
channel_full->restricted_count, channel_full->banned_count, channel_full->can_get_participants,
channel_full->can_set_username, channel_full->can_set_sticker_set, channel_full->is_all_history_available,
channel_full->sticker_set_id, channel_full->invite_link, channel_full->pinned_message_id.get(),
channel_full->sticker_set_id, channel_full->invite_link,
get_basic_group_id_object(channel_full->migrated_from_chat_id, "get_supergroup_full_info_object"),
channel_full->migrated_from_max_message_id.get());
}

View File

@ -167,7 +167,6 @@ class ContactsManager : public Actor {
void on_update_channel_username(ChannelId channel_id, string &&username);
void on_update_channel_description(ChannelId channel_id, string &&description);
void on_update_channel_sticker_set(ChannelId channel_id, int64 sticker_set_id);
void on_update_channel_pinned_message(ChannelId channel_id, MessageId message_id);
void on_update_channel_is_all_history_available(ChannelId channel_id, bool is_all_history_available);
void on_update_dialog_administrators(DialogId dialog_id, vector<UserId> administrator_user_ids, bool have_access);
@ -307,11 +306,6 @@ class ContactsManager : public Actor {
void set_channel_description(ChannelId channel_id, const string &description, Promise<Unit> &&promise);
void pin_channel_message(ChannelId channel_id, MessageId message_id, bool disable_notification,
Promise<Unit> &&promise);
void unpin_channel_message(ChannelId channel_id, Promise<Unit> &&promise);
void report_channel_spam(ChannelId channel_id, UserId user_id, const vector<MessageId> &message_ids,
Promise<Unit> &&promise);
@ -342,8 +336,6 @@ class ContactsManager : public Actor {
string get_channel_invite_link(ChannelId channel_id);
MessageId get_channel_pinned_message_id(ChannelId channel_id);
ChannelId migrate_chat_to_megagroup(ChatId chat_id, Promise<Unit> &promise);
vector<DialogId> get_created_public_dialogs(Promise<Unit> &&promise);
@ -650,7 +642,6 @@ class ContactsManager : public Actor {
int32 restricted_count = 0;
int32 banned_count = 0;
string invite_link;
MessageId pinned_message_id;
int64 sticker_set_id = 0; // do not forget to store along with access hash
@ -744,6 +735,8 @@ class ContactsManager : public Actor {
static constexpr int32 USER_FULL_FLAG_HAS_ABOUT = 1 << 1;
static constexpr int32 USER_FULL_FLAG_HAS_PHOTO = 1 << 2;
static constexpr int32 USER_FULL_FLAG_HAS_BOT_INFO = 1 << 3;
static constexpr int32 USER_FULL_FLAG_HAS_PINNED_MESSAGE = 1 << 6;
static constexpr int32 USER_FULL_FLAG_CAN_PIN_MESSAGE = 1 << 7;
static constexpr int32 CHAT_FLAG_USER_IS_CREATOR = 1 << 0;
static constexpr int32 CHAT_FLAG_USER_WAS_KICKED = 1 << 1;
@ -753,6 +746,8 @@ class ContactsManager : public Actor {
static constexpr int32 CHAT_FLAG_IS_DEACTIVATED = 1 << 5;
static constexpr int32 CHAT_FLAG_WAS_MIGRATED = 1 << 6;
static constexpr int32 CHAT_FULL_FLAG_HAS_PINNED_MESSAGE = 1 << 6;
static constexpr int32 CHANNEL_FLAG_USER_IS_CREATOR = 1 << 0;
static constexpr int32 CHANNEL_FLAG_USER_HAS_LEFT = 1 << 2;
static constexpr int32 CHANNEL_FLAG_IS_BROADCAST = 1 << 5;
@ -898,7 +893,6 @@ class ContactsManager : public Actor {
void on_update_channel_full_invite_link(ChannelFull *channel_full,
tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link_ptr);
void on_update_channel_full_pinned_message(ChannelFull *channel_full, MessageId message_id);
void speculative_add_channel_user(ChannelId channel_id, UserId user_id, DialogParticipantStatus status,
DialogParticipantStatus old_status);

View File

@ -81,7 +81,7 @@ DialogParticipantStatus DialogParticipantStatus::Banned(int32 banned_until_date)
}
DialogParticipantStatus DialogParticipantStatus::GroupAdministrator(bool is_creator) {
return DialogParticipantStatus::Administrator(is_creator, true, false, false, true, true, false, true, false, false);
return DialogParticipantStatus::Administrator(is_creator, true, false, false, true, true, false, true, true, false);
}
DialogParticipantStatus DialogParticipantStatus::ChannelAdministrator(bool is_creator, bool is_megagroup) {

View File

@ -260,54 +260,56 @@ class GetChannelMessagesQuery : public Td::ResultHandler {
}
};
class GetChannelPinnedMessageQuery : public Td::ResultHandler {
Promise<MessageId> promise_;
ChannelId channel_id_;
class UpdateDialogPinnedMessageQuery : public Td::ResultHandler {
Promise<Unit> promise_;
DialogId dialog_id_;
MessageId message_id_;
public:
explicit GetChannelPinnedMessageQuery(Promise<MessageId> &&promise) : promise_(std::move(promise)) {
explicit UpdateDialogPinnedMessageQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(ChannelId channel_id) {
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
if (input_channel == nullptr) {
return promise_.set_error(Status::Error(6, "Can't access the chat"));
void send(DialogId dialog_id, MessageId message_id, bool disable_notification) {
dialog_id_ = dialog_id;
message_id_ = message_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
LOG(INFO) << "Can't update pinned message because have no write access to " << dialog_id;
return on_error(0, Status::Error(500, "Can't update pinned message"));
}
channel_id_ = channel_id;
vector<tl_object_ptr<telegram_api::InputMessage>> input_messages;
input_messages.push_back(make_tl_object<telegram_api::inputMessagePinned>());
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_getMessages(std::move(input_channel), std::move(input_messages)))));
int32 flags = 0;
if (disable_notification) {
flags |= telegram_api::messages_updatePinnedMessage::SILENT_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_updatePinnedMessage(
flags, false /*ignored*/, std::move(input_peer), message_id.get_server_message_id().get()))));
}
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::channels_getMessages>(packet);
auto result_ptr = fetch_result<telegram_api::messages_updatePinnedMessage>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
}
auto info = td->messages_manager_->on_get_messages(result_ptr.move_as_ok(), "GetChannelPinnedMessageQuery");
if (info.messages.empty()) {
return promise_.set_value(MessageId());
}
if (info.messages.size() >= 2) {
return promise_.set_error(Status::Error(500, "More than 1 pinned message received"));
}
auto full_message_id = td->messages_manager_->on_get_message(
std::move(info.messages[0]), false, info.is_channel_messages, false, false, "GetChannelPinnedMessageQuery");
if (full_message_id.get_dialog_id().is_valid() && full_message_id.get_dialog_id() != DialogId(channel_id_)) {
return promise_.set_error(Status::Error(500, "Receive pinned message in a wrong chat"));
}
promise_.set_value(full_message_id.get_message_id());
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for UpdateDialogPinnedMessageQuery: " << to_string(ptr);
td->updates_manager_->on_get_updates(std::move(ptr));
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) override {
if (status.message() == "MESSAGE_IDS_EMPTY") {
promise_.set_value(MessageId());
return;
if (status.message() == "CHAT_NOT_MODIFIED") {
td->messages_manager_->on_update_dialog_pinned_message_id(dialog_id_, message_id_);
if (!td->auth_manager_->is_bot()) {
promise_.set_value(Unit());
return;
}
} else {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "UpdateDialogPinnedMessageQuery");
}
td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelPinnedMessageQuery");
promise_.set_error(std::move(status));
}
};
@ -339,7 +341,7 @@ class ExportChannelMessageLinkQuery : public Td::ResultHandler {
}
auto ptr = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for ExportChannelMessageLinkQuery " << to_string(ptr);
LOG(DEBUG) << "Receive result for ExportChannelMessageLinkQuery: " << to_string(ptr);
td->messages_manager_->on_get_public_message_link({DialogId(channel_id_), message_id_}, for_group_,
std::move(ptr->link_), std::move(ptr->html_));
@ -380,7 +382,7 @@ class GetDialogListQuery : public NetActorOnce {
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetDialogListQuery " << to_string(ptr);
LOG(INFO) << "Receive result for GetDialogListQuery: " << to_string(ptr);
switch (ptr->get_id()) {
case telegram_api::messages_dialogs::ID: {
auto dialogs = move_tl_object_as<telegram_api::messages_dialogs>(ptr);
@ -429,7 +431,7 @@ class SearchPublicDialogsQuery : public Td::ResultHandler {
}
auto dialogs = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for SearchPublicDialogsQuery " << to_string(dialogs);
LOG(INFO) << "Receive result for SearchPublicDialogsQuery: " << to_string(dialogs);
td->contacts_manager_->on_get_users(std::move(dialogs->users_), "SearchPublicDialogsQuery");
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "SearchPublicDialogsQuery");
td->messages_manager_->on_get_public_dialogs_search_result(query_, std::move(dialogs->my_results_),
@ -468,7 +470,7 @@ class GetCommonDialogsQuery : public Td::ResultHandler {
}
auto chats_ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetCommonDialogsQuery " << to_string(chats_ptr);
LOG(INFO) << "Receive result for GetCommonDialogsQuery: " << to_string(chats_ptr);
int32 constructor_id = chats_ptr->get_id();
switch (constructor_id) {
case telegram_api::messages_chats::ID: {
@ -964,7 +966,7 @@ class GetMessagesViewsQuery : public Td::ResultHandler {
}
vector<int32> views = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetMessagesViewsQuery " << format::as_array(views);
LOG(INFO) << "Receive result for GetMessagesViewsQuery: " << format::as_array(views);
if (message_ids_.size() != views.size()) {
return on_error(id, Status::Error(500, "Wrong number of message views returned"));
}
@ -3640,6 +3642,7 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
mention_notification_group.group_id.is_valid() && !mention_notification_group.try_reuse;
bool has_new_secret_chat_notification_id = new_secret_chat_notification_id.is_valid();
bool has_pinned_message_notification = pinned_message_notification_message_id.is_valid();
bool has_pinned_message_id = pinned_message_id.is_valid();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_draft_message);
STORE_FLAG(has_last_database_message);
@ -3667,9 +3670,9 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
STORE_FLAG(has_message_notification_group);
STORE_FLAG(has_mention_notification_group);
STORE_FLAG(has_new_secret_chat_notification_id);
STORE_FLAG(has_pinned_message_notification); // 26
//
//
STORE_FLAG(has_pinned_message_notification);
STORE_FLAG(has_pinned_message_id);
STORE_FLAG(is_pinned_message_id_inited); // 28
//STORE_FLAG(has_flags2);
END_STORE_FLAGS();
@ -3741,6 +3744,9 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
if (has_pinned_message_notification) {
store(pinned_message_notification_message_id, storer);
}
if (has_pinned_message_id) {
store(pinned_message_id, storer);
}
}
// do not forget to resolve dialog dependencies including dependencies of last_message
@ -3764,6 +3770,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
bool has_mention_notification_group;
bool has_new_secret_chat_notification_id;
bool has_pinned_message_notification;
bool has_pinned_message_id;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_draft_message);
PARSE_FLAG(has_last_database_message);
@ -3792,6 +3799,8 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
PARSE_FLAG(has_mention_notification_group);
PARSE_FLAG(has_new_secret_chat_notification_id);
PARSE_FLAG(has_pinned_message_notification);
PARSE_FLAG(has_pinned_message_id);
PARSE_FLAG(is_pinned_message_id_inited);
END_PARSE_FLAGS();
parse(dialog_id, parser); // must be stored at offset 4
@ -3886,6 +3895,9 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
if (has_pinned_message_notification) {
parse(pinned_message_notification_message_id, parser);
}
if (has_pinned_message_id) {
parse(pinned_message_id, parser);
}
}
template <class StorerT>
@ -10237,6 +10249,11 @@ void MessagesManager::on_get_dialogs(vector<tl_object_ptr<telegram_api::dialog>>
<< dialog_id;
dialog->unread_mentions_count_ = 0;
}
if (!d->is_pinned_message_id_inited) {
// asynchronously get dialog pinned message from the server
// TODO add pinned_message_id to telegram_api::dialog
get_dialog_pinned_message(dialog_id, Auto());
}
need_update_dialog_pos |= update_dialog_draft_message(
d, get_draft_message(td_->contacts_manager_.get(), std::move(dialog->draft_)), true, false);
@ -11569,23 +11586,46 @@ MessageId MessagesManager::get_replied_message(DialogId dialog_id, MessageId mes
return replied_message_id;
}
void MessagesManager::get_dialog_pinned_message(DialogId dialog_id, Promise<MessageId> &&promise) {
MessageId MessagesManager::get_dialog_pinned_message(DialogId dialog_id, Promise<Unit> &&promise) {
Dialog *d = get_dialog_force(dialog_id);
if (d == nullptr) {
return promise.set_error(Status::Error(6, "Chat not found"));
promise.set_error(Status::Error(6, "Chat not found"));
return MessageId();
}
if (dialog_id.get_type() != DialogType::Channel) {
return promise.set_value(MessageId());
Promise<Unit> empty_promise;
auto &get_pinned_message_id_promise = d->is_pinned_message_id_inited ? empty_promise : promise;
switch (dialog_id.get_type()) {
case DialogType::User:
td_->contacts_manager_->get_user_full(dialog_id.get_user_id(), std::move(get_pinned_message_id_promise));
break;
case DialogType::Chat:
td_->contacts_manager_->get_chat_full(dialog_id.get_chat_id(), std::move(get_pinned_message_id_promise));
break;
case DialogType::Channel: {
td_->contacts_manager_->get_channel_full(dialog_id.get_channel_id(), std::move(get_pinned_message_id_promise));
break;
}
case DialogType::SecretChat:
get_pinned_message_id_promise.set_value(Unit());
return MessageId();
case DialogType::None:
default:
UNREACHABLE();
get_pinned_message_id_promise.set_error(Status::Error(500, "Wrong chat type"));
}
if (!d->is_pinned_message_id_inited) {
// promise was already consumed
return MessageId();
}
auto channel_id = dialog_id.get_channel_id();
auto message_id = td_->contacts_manager_->get_channel_pinned_message_id(channel_id);
if (get_message_force(d, message_id) == nullptr) {
return td_->create_handler<GetChannelPinnedMessageQuery>(std::move(promise))->send(channel_id);
tl_object_ptr<telegram_api::InputMessage> input_message;
if (dialog_id.get_type() == DialogType::Channel) {
input_message = make_tl_object<telegram_api::inputMessagePinned>();
}
get_message_force_from_server(d, d->pinned_message_id, std::move(promise), std::move(input_message));
promise.set_value(std::move(message_id));
return d->pinned_message_id;
}
bool MessagesManager::get_messages(DialogId dialog_id, const vector<MessageId> &message_ids, Promise<Unit> &&promise) {
@ -12665,14 +12705,13 @@ void MessagesManager::open_dialog(Dialog *d) {
remove_new_secret_chat_notification(d, true);
}
get_dialog_pinned_message(d->dialog_id, Auto());
switch (d->dialog_id.get_type()) {
case DialogType::User:
break;
case DialogType::Chat: {
auto chat_id = d->dialog_id.get_chat_id();
td_->contacts_manager_->get_chat_full(chat_id, Promise<Unit>());
case DialogType::Chat:
break;
}
case DialogType::Channel:
get_channel_difference(d->dialog_id, d->pts, true, "open_dialog");
break;
@ -12773,8 +12812,8 @@ tl_object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *d) co
d->is_marked_as_unread, d->order == SPONSORED_DIALOG_ORDER, can_report_dialog(d->dialog_id),
d->notification_settings.silent_send_message, d->server_unread_count + d->local_unread_count,
d->last_read_inbox_message_id.get(), d->last_read_outbox_message_id.get(), d->unread_mention_count,
get_chat_notification_settings_object(&d->notification_settings), d->reply_markup_message_id.get(),
get_draft_message_object(d->draft_message), d->client_data);
get_chat_notification_settings_object(&d->notification_settings), d->pinned_message_id.get(),
d->reply_markup_message_id.get(), get_draft_message_object(d->draft_message), d->client_data);
}
tl_object_ptr<td_api::chat> MessagesManager::get_chat_object(DialogId dialog_id) const {
@ -19414,6 +19453,38 @@ void MessagesManager::set_dialog_is_marked_as_unread(Dialog *d, bool is_marked_a
}
}
void MessagesManager::on_update_dialog_pinned_message_id(DialogId dialog_id, MessageId pinned_message_id) {
if (!dialog_id.is_valid()) {
LOG(ERROR) << "Receive pinned message in invalid " << dialog_id;
return;
}
auto d = get_dialog_force(dialog_id);
if (d == nullptr) {
// nothing to do
return;
}
if (d->pinned_message_id == pinned_message_id) {
return;
}
set_dialog_pinned_message_id(d, pinned_message_id);
}
void MessagesManager::set_dialog_pinned_message_id(Dialog *d, MessageId pinned_message_id) {
CHECK(d != nullptr);
CHECK(d->pinned_message_id != pinned_message_id);
d->pinned_message_id = pinned_message_id;
d->is_pinned_message_id_inited = true;
on_dialog_updated(d->dialog_id, "set_dialog_pinned_message_id");
LOG(INFO) << "Set " << d->dialog_id << " pinned message to " << pinned_message_id;
CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_pinned_message_id";
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateChatPinnedMessage>(d->dialog_id.get(), pinned_message_id.get()));
}
void MessagesManager::on_create_new_dialog_success(int64 random_id, tl_object_ptr<telegram_api::Updates> &&updates,
DialogType expected_type, Promise<Unit> &&promise) {
auto sent_messages = td_->updates_manager_->get_new_messages(updates.get());
@ -20259,6 +20330,60 @@ void MessagesManager::set_dialog_title(DialogId dialog_id, const string &title,
td_->create_handler<EditDialogTitleQuery>(std::move(promise))->send(dialog_id, new_title);
}
void MessagesManager::pin_dialog_message(DialogId dialog_id, MessageId message_id, bool disable_notification,
bool is_unpin, Promise<Unit> &&promise) {
auto d = get_dialog_force(dialog_id);
if (d == nullptr) {
return promise.set_error(Status::Error(6, "Chat not found"));
}
Slice action = is_unpin ? Slice("unpin") : Slice("pin");
switch (dialog_id.get_type()) {
case DialogType::User:
if (dialog_id != get_my_dialog_id()) { // TODO
return promise.set_error(Status::Error(3, PSLICE() << "Can't " << action << " message in the private chat"));
}
break;
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_status(chat_id);
if (!status.can_pin_messages() ||
(td_->auth_manager_->is_bot() && !td_->contacts_manager_->is_appointed_chat_administrator(chat_id))) {
return promise.set_error(Status::Error(3, PSLICE() << "Not enough rights to " << action << " a message"));
}
break;
}
case DialogType::Channel: {
auto status = td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id());
bool can_pin = is_broadcast_channel(dialog_id) ? status.can_edit_messages() : status.can_pin_messages();
if (!can_pin) {
return promise.set_error(Status::Error(6, PSLICE() << "Not enough rights to " << action << " a message"));
}
break;
}
case DialogType::SecretChat:
return promise.set_error(Status::Error(3, PSLICE() << "Can't " << action << " message in a secret chat"));
case DialogType::None:
default:
UNREACHABLE();
}
if (is_unpin) {
CHECK(message_id == MessageId());
} else {
if (!have_message({dialog_id, message_id})) {
return promise.set_error(Status::Error(6, "Message not found"));
}
if (!message_id.is_server()) {
return promise.set_error(Status::Error(6, "Message can't be pinned"));
}
}
// TODO log event
td_->create_handler<UpdateDialogPinnedMessageQuery>(std::move(promise))
->send(dialog_id, message_id, disable_notification);
}
void MessagesManager::add_dialog_participant(DialogId dialog_id, UserId user_id, int32 forward_limit,
Promise<Unit> &&promise) {
LOG(INFO) << "Receive AddChatParticipant request to add " << user_id << " to " << dialog_id;
@ -21568,22 +21693,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
}
if (from_update && message_id.is_server()) {
auto pinned_message_id = get_message_content_pinned_message_id(m->content.get());
if (pinned_message_id.is_valid()) {
switch (dialog_id.get_type()) {
case DialogType::User:
case DialogType::Chat:
// nothing to do yet
break;
case DialogType::SecretChat:
break;
case DialogType::Channel:
td_->contacts_manager_->on_update_channel_pinned_message(dialog_id.get_channel_id(), pinned_message_id);
break;
case DialogType::None:
default:
UNREACHABLE();
}
}
on_update_dialog_pinned_message_id(dialog_id, pinned_message_id);
}
if (!td_->auth_manager_->is_bot() && from_update && m->forward_info == nullptr &&
(m->is_outgoing || dialog_id == my_dialog_id)) {
@ -22540,6 +22650,11 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
send_get_dialog_query(dialog_id, Auto());
}
if (being_added_dialog_id_ != dialog_id && !d->is_pinned_message_id_inited) {
// asynchronously get dialog pinned message from the server
get_dialog_pinned_message(dialog_id, Auto());
}
if (d->notification_settings.is_synchronized && !d->notification_settings.is_use_default_fixed &&
have_input_peer(dialog_id, AccessRights::Read)) {
LOG(INFO) << "Reget notification settings of " << dialog_id;

View File

@ -276,6 +276,8 @@ class MessagesManager : public Actor {
void on_update_dialog_is_marked_as_unread(DialogId dialog_id, bool is_marked_as_unread);
void on_update_dialog_pinned_message_id(DialogId dialog_id, MessageId pinned_message_id);
void on_update_service_notification(tl_object_ptr<telegram_api::updateServiceNotification> &&update);
void on_update_contact_registered(tl_object_ptr<telegram_api::updateContactRegistered> &&update);
@ -408,6 +410,9 @@ class MessagesManager : public Actor {
void set_dialog_title(DialogId dialog_id, const string &title, Promise<Unit> &&promise);
void pin_dialog_message(DialogId dialog_id, MessageId message_id, bool disable_notification, bool is_unpin,
Promise<Unit> &&promise);
void add_dialog_participant(DialogId dialog_id, UserId user_id, int32 forward_limit, Promise<Unit> &&promise);
void add_dialog_participants(DialogId dialog_id, const vector<UserId> &user_ids, Promise<Unit> &&promise);
@ -462,7 +467,7 @@ class MessagesManager : public Actor {
MessageId get_replied_message(DialogId dialog_id, MessageId message_id, bool force, Promise<Unit> &&promise);
void get_dialog_pinned_message(DialogId dialog_id, Promise<MessageId> &&promise);
MessageId get_dialog_pinned_message(DialogId dialog_id, Promise<Unit> &&promise);
bool get_messages(DialogId dialog_id, const vector<MessageId> &message_ids, Promise<Unit> &&promise);
@ -893,6 +898,7 @@ class MessagesManager : public Actor {
MessageId last_read_inbox_message_id;
int32 last_read_inbox_message_date = 0; // secret chats only
MessageId last_read_outbox_message_id;
MessageId pinned_message_id;
MessageId reply_markup_message_id;
DialogNotificationSettings notification_settings;
unique_ptr<DraftMessage> draft_message;
@ -941,6 +947,7 @@ class MessagesManager : public Actor {
bool is_last_read_inbox_message_id_inited = false;
bool is_last_read_outbox_message_id_inited = false;
bool is_pinned_message_id_inited = false;
bool need_repair_server_unread_count = false;
bool is_marked_as_unread = false;
@ -1657,6 +1664,8 @@ class MessagesManager : public Actor {
void set_dialog_is_marked_as_unread(Dialog *d, bool is_marked_as_unread);
void set_dialog_pinned_message_id(Dialog *d, MessageId pinned_message_id);
void toggle_dialog_is_pinned_on_server(DialogId dialog_id, bool is_pinned, uint64 logevent_id);
void toggle_dialog_is_marked_as_unread_on_server(DialogId dialog_id, bool is_marked_as_unread, uint64 logevent_id);

View File

@ -975,26 +975,17 @@ class GetRepliedMessageRequest : public RequestOnceActor {
public:
GetRepliedMessageRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id)
: RequestOnceActor(std::move(td), request_id), dialog_id_(dialog_id), message_id_(message_id) {
set_tries(3);
set_tries(3); // 1 to get initial message, 1 to get the reply and 1 for result
}
};
class GetChatPinnedMessageRequest : public RequestActor<MessageId> {
class GetChatPinnedMessageRequest : public RequestOnceActor {
DialogId dialog_id_;
MessageId pinned_message_id_;
void do_run(Promise<MessageId> &&promise) override {
if (get_tries() < 2) {
promise.set_value(std::move(pinned_message_id_));
return;
}
td->messages_manager_->get_dialog_pinned_message(dialog_id_, std::move(promise));
}
void do_set_result(MessageId &&result) override {
pinned_message_id_ = result;
void do_run(Promise<Unit> &&promise) override {
pinned_message_id_ = td->messages_manager_->get_dialog_pinned_message(dialog_id_, std::move(promise));
}
void do_send_result() override {
@ -1003,7 +994,8 @@ class GetChatPinnedMessageRequest : public RequestActor<MessageId> {
public:
GetChatPinnedMessageRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id)
: RequestActor(std::move(td), request_id), dialog_id_(dialog_id) {
: RequestOnceActor(std::move(td), request_id), dialog_id_(dialog_id) {
set_tries(3); // 1 to get pinned_message_id, 1 to get the message and 1 for result
}
};
@ -5916,15 +5908,15 @@ void Td::on_request(uint64 id, td_api::setSupergroupDescription &request) {
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::pinSupergroupMessage &request) {
void Td::on_request(uint64 id, const td_api::pinChatMessage &request) {
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->pin_channel_message(ChannelId(request.supergroup_id_), MessageId(request.message_id_),
request.disable_notification_, std::move(promise));
messages_manager_->pin_dialog_message(DialogId(request.chat_id_), MessageId(request.message_id_),
request.disable_notification_, false, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::unpinSupergroupMessage &request) {
void Td::on_request(uint64 id, const td_api::unpinChatMessage &request) {
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->unpin_channel_message(ChannelId(request.supergroup_id_), std::move(promise));
messages_manager_->pin_dialog_message(DialogId(request.chat_id_), MessageId(), false, true, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::reportSupergroupSpam &request) {

View File

@ -627,6 +627,10 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::setChatClientData &request);
void on_request(uint64 id, const td_api::pinChatMessage &request);
void on_request(uint64 id, const td_api::unpinChatMessage &request);
void on_request(uint64 id, const td_api::joinChat &request);
void on_request(uint64 id, const td_api::leaveChat &request);
@ -715,10 +719,6 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::setSupergroupDescription &request);
void on_request(uint64 id, const td_api::pinSupergroupMessage &request);
void on_request(uint64 id, const td_api::unpinSupergroupMessage &request);
void on_request(uint64 id, const td_api::reportSupergroupSpam &request);
void on_request(uint64 id, td_api::getSupergroupMembers &request);

View File

@ -1492,17 +1492,27 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannelMessageV
td_->messages_manager_->on_update_message_views({dialog_id, MessageId(ServerMessageId(update->id_))}, update->views_);
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannelPinnedMessage> update, bool /*force_apply*/) {
td_->contacts_manager_->on_update_channel_pinned_message(ChannelId(update->channel_id_),
MessageId(ServerMessageId(update->id_)));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannelAvailableMessages> update,
bool /*force_apply*/) {
td_->messages_manager_->on_update_channel_max_unavailable_message_id(
ChannelId(update->channel_id_), MessageId(ServerMessageId(update->available_min_id_)));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserPinnedMessage> update, bool /*force_apply*/) {
td_->messages_manager_->on_update_dialog_pinned_message_id(DialogId(UserId(update->user_id_)),
MessageId(ServerMessageId(update->id_)));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatPinnedMessage> update, bool /*force_apply*/) {
td_->messages_manager_->on_update_dialog_pinned_message_id(DialogId(ChatId(update->chat_id_)),
MessageId(ServerMessageId(update->id_)));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannelPinnedMessage> update, bool /*force_apply*/) {
td_->messages_manager_->on_update_dialog_pinned_message_id(DialogId(ChannelId(update->channel_id_)),
MessageId(ServerMessageId(update->id_)));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNotifySettings> update, bool /*force_apply*/) {
CHECK(update != nullptr);
switch (update->peer_->get_id()) {
@ -1857,10 +1867,4 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateLangPack> updat
// unsupported updates
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserPinnedMessage> update, bool /*force_apply*/) {
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatPinnedMessage> update, bool /*force_apply*/) {
}
} // namespace td

View File

@ -225,9 +225,12 @@ class UpdatesManager : public Actor {
void on_update(tl_object_ptr<telegram_api::updateEditChannelMessage> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateDeleteChannelMessages> update, bool force_apply);
void on_update(tl_object_ptr<telegram_api::updateChannelMessageViews> update, bool force_apply);
void on_update(tl_object_ptr<telegram_api::updateChannelPinnedMessage> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateChannelAvailableMessages> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateUserPinnedMessage> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateChatPinnedMessage> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateChannelPinnedMessage> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateDraftMessage> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateDialogPinned> update, bool /*force_apply*/);
@ -274,9 +277,6 @@ class UpdatesManager : public Actor {
void on_update(tl_object_ptr<telegram_api::updateLangPack> update, bool /*force_apply*/);
// unsupported updates
void on_update(tl_object_ptr<telegram_api::updateUserPinnedMessage> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateChatPinnedMessage> update, bool /*force_apply*/);
};
} // namespace td

View File

@ -3301,22 +3301,15 @@ class CliClient final : public Actor {
std::tie(supergroup_id, description) = split(args);
send_request(make_tl_object<td_api::setSupergroupDescription>(as_supergroup_id(supergroup_id), description));
} else if (op == "psgm" || op == "pchm") {
string supergroup_id;
} else if (op == "pcm" || op == "pcms") {
string chat_id;
string message_id;
std::tie(supergroup_id, message_id) = split(args);
send_request(make_tl_object<td_api::pinSupergroupMessage>(as_supergroup_id(supergroup_id),
as_message_id(message_id), false));
} else if (op == "psgms" || op == "pchms") {
string supergroup_id;
string message_id;
std::tie(supergroup_id, message_id) = split(args);
send_request(make_tl_object<td_api::pinSupergroupMessage>(as_supergroup_id(supergroup_id),
as_message_id(message_id), true));
} else if (op == "upsgm" || op == "upchm") {
send_request(make_tl_object<td_api::unpinSupergroupMessage>(as_supergroup_id(args)));
std::tie(chat_id, message_id) = split(args);
send_request(
make_tl_object<td_api::pinChatMessage>(as_chat_id(chat_id), as_message_id(message_id), op == "pcms"));
} else if (op == "upcm") {
send_request(make_tl_object<td_api::unpinChatMessage>(as_chat_id(args)));
} else if (op == "grib") {
send_request(make_tl_object<td_api::getRecentInlineBots>());
} else if (op == "spc" || op == "su" || op == "sch") {