Improve Saved Messages topic API and naming.

This commit is contained in:
levlam 2024-02-07 14:01:29 +03:00
parent aae57bf18a
commit f28d40605a
9 changed files with 139 additions and 136 deletions

View File

@ -1355,7 +1355,7 @@ inputMessageReplyToStory story_sender_chat_id:int53 story_id:int32 = InputMessag
//@unread_reactions Information about unread reactions added to the message //@unread_reactions Information about unread reactions added to the message
//@reply_to Information about the message or the story this message is replying to; 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 //@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 Information about topic of the message in the Saved Messages chat; may be null for messages not from Saved Messages //@saved_messages_topic_id Identifier of the Saved Messages topic for the message; 0 for messages not from Saved Messages
//@self_destruct_type The message's self-destruct type; may be null if none //@self_destruct_type The message's self-destruct type; may be null if none
//@self_destruct_in Time left before the message self-destruct timer expires, in seconds; 0 if self-destruction isn't scheduled yet //@self_destruct_in Time left before the message self-destruct timer expires, in seconds; 0 if self-destruction isn't scheduled yet
//@auto_delete_in Time left before the message will be automatically deleted by message_auto_delete_time setting of the chat, in seconds; 0 if never //@auto_delete_in Time left before the message will be automatically deleted by message_auto_delete_time setting of the chat, in seconds; 0 if never
@ -1365,7 +1365,7 @@ inputMessageReplyToStory story_sender_chat_id:int53 story_id:int32 = InputMessag
//@restriction_reason If non-empty, contains a human-readable description of the reason why access to this message must be restricted //@restriction_reason If non-empty, contains a human-readable description of the reason why access to this message must be restricted
//@content Content of the message //@content Content of the message
//@reply_markup Reply markup for the message; may be null if none //@reply_markup Reply markup for the message; may be null if none
message id:int53 sender_id:MessageSender chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool is_pinned:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_replied_in_another_chat:Bool can_be_saved:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_added_reactions:Bool can_get_statistics:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_viewers:Bool can_get_media_timestamp_links:Bool can_report_reactions:Bool has_timestamped_media:Bool is_channel_post:Bool is_topic_message:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo import_info:messageImportInfo interaction_info:messageInteractionInfo unread_reactions:vector<unreadReaction> reply_to:MessageReplyTo message_thread_id:int53 saved_messages_topic:SavedMessagesTopic self_destruct_type:MessageSelfDestructType self_destruct_in:double auto_delete_in:double via_bot_user_id:int53 author_signature:string media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message; message id:int53 sender_id:MessageSender chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool is_pinned:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_replied_in_another_chat:Bool can_be_saved:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_added_reactions:Bool can_get_statistics:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_viewers:Bool can_get_media_timestamp_links:Bool can_report_reactions:Bool has_timestamped_media:Bool is_channel_post:Bool is_topic_message:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo import_info:messageImportInfo interaction_info:messageInteractionInfo unread_reactions:vector<unreadReaction> reply_to:MessageReplyTo message_thread_id:int53 saved_messages_topic_id:int53 self_destruct_type:MessageSelfDestructType self_destruct_in:double auto_delete_in:double via_bot_user_id:int53 author_signature:string media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message;
//@description Contains a list of messages @total_count Approximate total number of messages found @messages List of messages; messages may be null //@description Contains a list of messages @total_count Approximate total number of messages found @messages List of messages; messages may be null
messages total_count:int32 messages:vector<message> = Messages; messages total_count:int32 messages:vector<message> = Messages;
@ -1890,24 +1890,25 @@ webAppInfo launch_id:int64 url:string = WebAppInfo;
messageThreadInfo chat_id:int53 message_thread_id:int53 reply_info:messageReplyInfo unread_message_count:int32 messages:vector<message> draft_message:draftMessage = MessageThreadInfo; messageThreadInfo chat_id:int53 message_thread_id:int53 reply_info:messageReplyInfo unread_message_count:int32 messages:vector<message> draft_message:draftMessage = MessageThreadInfo;
//@class SavedMessagesTopic @description Contains information about a Saved Messages topic //@class SavedMessagesTopicType @description Describes type of a Saved Messages topic
//@description Topic containing messages sent by the current user of forwarded from an unknown chat //@description Topic containing messages sent by the current user of forwarded from an unknown chat
savedMessagesTopicMyNotes = SavedMessagesTopic; savedMessagesTopicTypeMyNotes = SavedMessagesTopicType;
//@description Topic containing messages forwarded from a user with hidden privacy //@description Topic containing messages forwarded from a user with hidden privacy
savedMessagesTopicAuthorHidden = SavedMessagesTopic; savedMessagesTopicTypeAuthorHidden = SavedMessagesTopicType;
//@description Topic containing messages forwarded from a specific chat @chat_id Identifier of the chat //@description Topic containing messages forwarded from a specific chat @chat_id Identifier of the chat
savedMessagesTopicSavedFromChat chat_id:int53 = SavedMessagesTopic; savedMessagesTopicTypeSavedFromChat chat_id:int53 = SavedMessagesTopicType;
//@description Contains information about a found Saved Messages topic //@description Contains information about a Saved Messages topic
//@topic The topic //@id Unique topic identifier
//@type Type of the topic
//@is_pinned True, if the topic is pinned //@is_pinned True, if the topic is pinned
//@order A parameter used to determine order of the topic in the topic list. Topics must be sorted by the order in descending order //@order A parameter used to determine order of the topic in the topic list. Topics must be sorted by the order in descending order
//@last_message Last message in the topic; may be null if none or unknown //@last_message Last message in the topic; may be null if none or unknown
foundSavedMessagesTopic topic:SavedMessagesTopic is_pinned:Bool order:int64 last_message:message = FoundSavedMessagesTopic; savedMessagesTopic id:int53 type:SavedMessagesTopicType is_pinned:Bool order:int64 last_message:message = SavedMessagesTopic;
//@description Describes a forum topic icon @color Color of the topic icon in RGB format @custom_emoji_id Unique identifier of the custom emoji shown on the topic icon; 0 if none //@description Describes a forum topic icon @color Color of the topic icon in RGB format @custom_emoji_id Unique identifier of the custom emoji shown on the topic icon; 0 if none
@ -6504,8 +6505,9 @@ updateChatFolders chat_folders:vector<chatFolderInfo> main_chat_list_position:in
//@online_member_count New number of online members in the chat, or 0 if unknown //@online_member_count New number of online members in the chat, or 0 if unknown
updateChatOnlineMemberCount chat_id:int53 online_member_count:int32 = Update; updateChatOnlineMemberCount chat_id:int53 online_member_count:int32 = Update;
//@description Basic information about a Saved Messages topic has changed @topic New information about the topic //@description Basic information about a Saved Messages topic has changed. This update is guaranteed to come before the topic identifier is returned to the application
updateSavedMessagesTopic topic:foundSavedMessagesTopic = Update; //@topic New data about the topic
updateSavedMessagesTopic topic:savedMessagesTopic = Update;
//@description Basic information about a topic in a forum chat was changed @chat_id Chat identifier @info New information about the topic //@description Basic information about a topic in a forum chat was changed @chat_id Chat identifier @info New information about the topic
updateForumTopicInfo chat_id:int53 info:forumTopicInfo = Update; updateForumTopicInfo chat_id:int53 info:forumTopicInfo = Update;
@ -6738,9 +6740,9 @@ updateActiveEmojiReactions emojis:vector<string> = Update;
updateDefaultReactionType reaction_type:ReactionType = Update; updateDefaultReactionType reaction_type:ReactionType = Update;
//@description Tags used in Saved Messages or a Saved Messages topic have changed //@description Tags used in Saved Messages or a Saved Messages topic have changed
//@saved_messages_topic Saved Messages topic which tags were changed; may be null if tags for the whole chat has changed //@saved_messages_topic_id Identifier of Saved Messages topic which tags were changed; 0 if tags for the whole chat has changed
//@tags The new tags //@tags The new tags
updateSavedMessagesTags saved_messages_topic:SavedMessagesTopic tags:savedMessagesTags = Update; updateSavedMessagesTags saved_messages_topic_id:int53 tags:savedMessagesTags = Update;
//@description The parameters of speech recognition without Telegram Premium subscription has changed //@description The parameters of speech recognition without Telegram Premium subscription has changed
//@max_media_duration The maximum allowed duration of media for speech recognition without Telegram Premium subscription //@max_media_duration The maximum allowed duration of media for speech recognition without Telegram Premium subscription
@ -7247,34 +7249,34 @@ getInactiveSupergroupChats = Chats;
loadSavedMessagesTopics limit:int32 = Ok; loadSavedMessagesTopics limit:int32 = Ok;
//@description Returns messages in a Saved Messages topic. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id) //@description Returns messages in a Saved Messages topic. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id)
//@saved_messages_topic Saved Messages topic which messages will be fetched //@saved_messages_topic_id Identifier of Saved Messages topic which messages will be fetched
//@from_message_id Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message //@from_message_id Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message
//@offset Specify 0 to get results from exactly the message from_message_id or a negative offset up to 99 to get additionally some newer messages //@offset Specify 0 to get results from exactly the message from_message_id or a negative offset up to 99 to get additionally some newer messages
//@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset. //@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset.
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
getSavedMessagesTopicHistory saved_messages_topic:SavedMessagesTopic from_message_id:int53 offset:int32 limit:int32 = Messages; getSavedMessagesTopicHistory saved_messages_topic_id:int53 from_message_id:int53 offset:int32 limit:int32 = Messages;
//@description Returns the last message sent in a Saved Messages topic no later than the specified date //@description Returns the last message sent in a Saved Messages topic no later than the specified date
//@saved_messages_topic Saved Messages topic which message will be returned //@saved_messages_topic_id Identifier of Saved Messages topic which message will be returned
//@date Point in time (Unix timestamp) relative to which to search for messages //@date Point in time (Unix timestamp) relative to which to search for messages
getSavedMessagesTopicMessageByDate saved_messages_topic:SavedMessagesTopic date:int32 = Message; getSavedMessagesTopicMessageByDate saved_messages_topic_id:int53 date:int32 = Message;
//@description Deletes all messages in a Saved Messages topic @saved_messages_topic Saved Messages topic which messages will be deleted //@description Deletes all messages in a Saved Messages topic @saved_messages_topic_id Identifier of Saved Messages topic which messages will be deleted
deleteSavedMessagesTopicHistory saved_messages_topic:SavedMessagesTopic = Ok; deleteSavedMessagesTopicHistory saved_messages_topic_id:int53 = Ok;
//@description Deletes all messages between the specified dates in a Saved Messages topic. Messages sent in the last 30 seconds will not be deleted //@description Deletes all messages between the specified dates in a Saved Messages topic. Messages sent in the last 30 seconds will not be deleted
//@saved_messages_topic Saved Messages topic which messages will be deleted //@saved_messages_topic_id Identifier of Saved Messages topic which messages will be deleted
//@min_date The minimum date of the messages to delete //@min_date The minimum date of the messages to delete
//@max_date The maximum date of the messages to delete //@max_date The maximum date of the messages to delete
deleteSavedMessagesTopicMessagesByDate saved_messages_topic:SavedMessagesTopic min_date:int32 max_date:int32 = Ok; deleteSavedMessagesTopicMessagesByDate saved_messages_topic_id:int53 min_date:int32 max_date:int32 = Ok;
//@description Changes the pinned state of a Saved Messages topic. There can be up to getOption("pinned_saved_messages_topic_count_max") pinned topics. The limit can be increased with Telegram Premium //@description Changes the pinned state of a Saved Messages topic. There can be up to getOption("pinned_saved_messages_topic_count_max") pinned topics. The limit can be increased with Telegram Premium
//@saved_messages_topic Saved Messages topic to pin or unpin //@saved_messages_topic_id Identifier of Saved Messages topic to pin or unpin
//@is_pinned Pass true to pin the topic; pass false to unpin it //@is_pinned Pass true to pin the topic; pass false to unpin it
toggleSavedMessagesTopicIsPinned saved_messages_topic:SavedMessagesTopic is_pinned:Bool = Ok; toggleSavedMessagesTopicIsPinned saved_messages_topic_id:int53 is_pinned:Bool = Ok;
//@description Changes the order of pinned Saved Messages topics @saved_messages_topics The new list of pinned Saved Messages topics //@description Changes the order of pinned Saved Messages topics @saved_messages_topic_ids Identifiers of the new pinned Saved Messages topics
setPinnedSavedMessagesTopics saved_messages_topics:vector<SavedMessagesTopic> = Ok; setPinnedSavedMessagesTopics saved_messages_topic_ids:vector<int53> = Ok;
//@description Returns a list of common group chats with a given user. Chats are sorted by their type and creation date //@description Returns a list of common group chats with a given user. Chats are sorted by their type and creation date
@ -7327,8 +7329,8 @@ deleteChat chat_id:int53 = Ok;
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
//@filter Additional filter for messages to search; pass null to search for all messages //@filter Additional filter for messages to search; pass null to search for all messages
//@message_thread_id If not 0, only messages in the specified thread will be returned; supergroups only //@message_thread_id If not 0, only messages in the specified thread will be returned; supergroups only
//@saved_messages_topic If not null, only messages in the specified Saved Messages topic will be returned; pass null to return all messages, or for chats other than Saved Messages //@saved_messages_topic_id If not 0, only messages in the specified Saved Messages topic will be returned; pass 0 to return all messages, or for chats other than Saved Messages
searchChatMessages chat_id:int53 query:string sender_id:MessageSender from_message_id:int53 offset:int32 limit:int32 filter:SearchMessagesFilter message_thread_id:int53 saved_messages_topic:SavedMessagesTopic = FoundChatMessages; searchChatMessages chat_id:int53 query:string sender_id:MessageSender from_message_id:int53 offset:int32 limit:int32 filter:SearchMessagesFilter message_thread_id:int53 saved_messages_topic_id:int53 = FoundChatMessages;
//@description Searches for messages in all chats except secret chats. Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)). //@description Searches for messages in all chats except secret chats. Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)).
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
@ -7352,14 +7354,14 @@ searchSecretMessages chat_id:int53 query:string offset:string limit:int32 filter
//@description Searches for messages tagged by the given reaction and with the given words in the Saved Messages chat; for Telegram Premium users only. //@description Searches for messages tagged by the given reaction and with the given words in the Saved Messages chat; for Telegram Premium users only.
//-Returns the results in reverse chronological order, i.e. in order of decreasing message_id //-Returns the results in reverse chronological order, i.e. in order of decreasing message_id
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
//@saved_messages_topic If not null, only messages in the specified Saved Messages topic will be considered; pass null to consider all messages //@saved_messages_topic_id If not 0, only messages in the specified Saved Messages topic will be considered; pass 0 to consider all messages
//@tag Tag to search for; pass null to return all suitable messages //@tag Tag to search for; pass null to return all suitable messages
//@query Query to search for //@query Query to search for
//@from_message_id Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message //@from_message_id Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message
//@offset Specify 0 to get results from exactly the message from_message_id or a negative offset to get the specified message and some newer messages //@offset Specify 0 to get results from exactly the message from_message_id or a negative offset to get the specified message and some newer messages
//@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than -offset. //@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than -offset.
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
searchSavedMessages saved_messages_topic:SavedMessagesTopic tag:ReactionType query:string from_message_id:int53 offset:int32 limit:int32 = FoundChatMessages; searchSavedMessages saved_messages_topic_id:int53 tag:ReactionType query:string from_message_id:int53 offset:int32 limit:int32 = FoundChatMessages;
//@description Searches for call messages. Returns the results in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib //@description Searches for call messages. Returns the results in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib
//@offset Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results //@offset Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
@ -7390,30 +7392,30 @@ getChatMessageByDate chat_id:int53 date:int32 = Message;
//@filter Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention, searchMessagesFilterUnreadMention, and searchMessagesFilterUnreadReaction are unsupported in this function //@filter Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention, searchMessagesFilterUnreadMention, and searchMessagesFilterUnreadReaction are unsupported in this function
//@from_message_id The message identifier from which to return information about message positions //@from_message_id The message identifier from which to return information about message positions
//@limit The expected number of message positions to be returned; 50-2000. A smaller number of positions can be returned, if there are not enough appropriate messages //@limit The expected number of message positions to be returned; 50-2000. A smaller number of positions can be returned, if there are not enough appropriate messages
//@saved_messages_topic If not null, only messages in the specified Saved Messages topic will be considered; pass null to consider all messages, or for chats other than Saved Messages //@saved_messages_topic_id If not 0, only messages in the specified Saved Messages topic will be considered; pass 0 to consider all messages, or for chats other than Saved Messages
getChatSparseMessagePositions chat_id:int53 filter:SearchMessagesFilter from_message_id:int53 limit:int32 saved_messages_topic:SavedMessagesTopic = MessagePositions; getChatSparseMessagePositions chat_id:int53 filter:SearchMessagesFilter from_message_id:int53 limit:int32 saved_messages_topic_id:int53 = MessagePositions;
//@description Returns information about the next messages of the specified type in the chat split by days. Returns the results in reverse chronological order. Can return partial result for the last returned day. Behavior of this method depends on the value of the option "utc_time_offset" //@description Returns information about the next messages of the specified type in the chat split by days. Returns the results in reverse chronological order. Can return partial result for the last returned day. Behavior of this method depends on the value of the option "utc_time_offset"
//@chat_id Identifier of the chat in which to return information about messages //@chat_id Identifier of the chat in which to return information about messages
//@filter Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention, searchMessagesFilterUnreadMention, and searchMessagesFilterUnreadReaction are unsupported in this function //@filter Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention, searchMessagesFilterUnreadMention, and searchMessagesFilterUnreadReaction are unsupported in this function
//@from_message_id The message identifier from which to return information about messages; use 0 to get results from the last message //@from_message_id The message identifier from which to return information about messages; use 0 to get results from the last message
//@saved_messages_topic If not null, only messages in the specified Saved Messages topic will be considered; pass null to consider all messages, or for chats other than Saved Messages //@saved_messages_topic_id If not0, only messages in the specified Saved Messages topic will be considered; pass 0 to consider all messages, or for chats other than Saved Messages
getChatMessageCalendar chat_id:int53 filter:SearchMessagesFilter from_message_id:int53 saved_messages_topic:SavedMessagesTopic = MessageCalendar; getChatMessageCalendar chat_id:int53 filter:SearchMessagesFilter from_message_id:int53 saved_messages_topic_id:int53 = MessageCalendar;
//@description Returns approximate number of messages of the specified type in the chat //@description Returns approximate number of messages of the specified type in the chat
//@chat_id Identifier of the chat in which to count messages //@chat_id Identifier of the chat in which to count messages
//@filter Filter for message content; searchMessagesFilterEmpty is unsupported in this function //@filter Filter for message content; searchMessagesFilterEmpty is unsupported in this function
//@saved_messages_topic If not null, only messages in the specified Saved Messages topic will be counted; pass null to count all messages, or for chats other than Saved Messages //@saved_messages_topic_id If not 0, only messages in the specified Saved Messages topic will be counted; pass 0 to count all messages, or for chats other than Saved Messages
//@return_local Pass true to get the number of messages without sending network requests, or -1 if the number of messages is unknown locally //@return_local Pass true to get the number of messages without sending network requests, or -1 if the number of messages is unknown locally
getChatMessageCount chat_id:int53 filter:SearchMessagesFilter saved_messages_topic:SavedMessagesTopic return_local:Bool = Count; getChatMessageCount chat_id:int53 filter:SearchMessagesFilter saved_messages_topic_id:int53 return_local:Bool = Count;
//@description Returns approximate 1-based position of a message among messages, which can be found by the specified filter in the chat. Cannot be used in secret chats //@description Returns approximate 1-based position of a message among messages, which can be found by the specified filter in the chat. Cannot be used in secret chats
//@chat_id Identifier of the chat in which to find message position //@chat_id Identifier of the chat in which to find message position
//@message_id Message identifier //@message_id Message identifier
//@filter Filter for message content; searchMessagesFilterEmpty, searchMessagesFilterUnreadMention, searchMessagesFilterUnreadReaction, and searchMessagesFilterFailedToSend are unsupported in this function //@filter Filter for message content; searchMessagesFilterEmpty, searchMessagesFilterUnreadMention, searchMessagesFilterUnreadReaction, and searchMessagesFilterFailedToSend are unsupported in this function
//@message_thread_id If not 0, only messages in the specified thread will be considered; supergroups only //@message_thread_id If not 0, only messages in the specified thread will be considered; supergroups only
//@saved_messages_topic If not null, only messages in the specified Saved Messages topic will be considered; pass null to consider all relevant messages, or for chats other than Saved Messages //@saved_messages_topic_id If not 0, only messages in the specified Saved Messages topic will be considered; pass 0 to consider all relevant messages, or for chats other than Saved Messages
getChatMessagePosition chat_id:int53 message_id:int53 filter:SearchMessagesFilter message_thread_id:int53 saved_messages_topic:SavedMessagesTopic = Count; getChatMessagePosition chat_id:int53 message_id:int53 filter:SearchMessagesFilter message_thread_id:int53 saved_messages_topic_id:int53 = Count;
//@description Returns all scheduled messages in a chat. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id) @chat_id Chat identifier //@description Returns all scheduled messages in a chat. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id) @chat_id Chat identifier
getChatScheduledMessages chat_id:int53 = Messages; getChatScheduledMessages chat_id:int53 = Messages;
@ -7745,8 +7747,8 @@ getMessageAddedReactions chat_id:int53 message_id:int53 reaction_type:ReactionTy
setDefaultReactionType reaction_type:ReactionType = Ok; setDefaultReactionType reaction_type:ReactionType = Ok;
//@description Returns tags used in Saved Messages or a Saved Messages topic //@description Returns tags used in Saved Messages or a Saved Messages topic
//@saved_messages_topic Saved Messages topic which tags will be returned; pass null to get all Saved Messages tags //@saved_messages_topic_id Identifier of Saved Messages topic which tags will be returned; pass 0 to get all Saved Messages tags
getSavedMessagesTags saved_messages_topic:SavedMessagesTopic = SavedMessagesTags; getSavedMessagesTags saved_messages_topic_id:int53 = SavedMessagesTags;
//@description Changes label of a Saved Messages tag; for Telegram Premium users only @tag The tag which label will be changed @label New label for the tag; 0-12 characters //@description Changes label of a Saved Messages tag; for Telegram Premium users only @tag The tag which label will be changed @label New label for the tag; 0-12 characters
setSavedMessagesTagLabel tag:ReactionType label:string = Ok; setSavedMessagesTagLabel tag:ReactionType label:string = Ok;

View File

@ -22556,9 +22556,9 @@ td_api::object_ptr<td_api::message> MessagesManager::get_dialog_event_log_messag
m->message_id.get(), std::move(sender), get_chat_id_object(dialog_id, "get_dialog_event_log_message_object"), m->message_id.get(), std::move(sender), get_chat_id_object(dialog_id, "get_dialog_event_log_message_object"),
nullptr, nullptr, m->is_outgoing, m->is_pinned, false, false, false, can_be_saved, false, false, false, false, nullptr, nullptr, m->is_outgoing, m->is_pinned, false, false, false, can_be_saved, false, false, false, false,
false, false, false, false, false, true, m->is_channel_post, m->is_topic_message, false, m->date, edit_date, false, false, false, false, false, true, m->is_channel_post, m->is_topic_message, false, m->date, edit_date,
std::move(forward_info), std::move(import_info), std::move(interaction_info), Auto(), nullptr, 0, nullptr, std::move(forward_info), std::move(import_info), std::move(interaction_info), Auto(), nullptr, 0, 0, nullptr, 0.0,
nullptr, 0.0, 0.0, via_bot_user_id, m->author_signature, 0, 0.0, via_bot_user_id, m->author_signature, 0, get_restriction_reason_description(m->restriction_reasons),
get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup)); std::move(content), std::move(reply_markup));
} }
tl_object_ptr<td_api::message> MessagesManager::get_message_object(MessageFullId message_full_id, const char *source) { tl_object_ptr<td_api::message> MessagesManager::get_message_object(MessageFullId message_full_id, const char *source) {
@ -22668,9 +22668,10 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
can_get_media_timestamp_links, can_report_reactions, has_timestamped_media, m->is_channel_post, can_get_media_timestamp_links, can_report_reactions, has_timestamped_media, m->is_channel_post,
m->is_topic_message, m->contains_unread_mention, date, edit_date, std::move(forward_info), std::move(import_info), m->is_topic_message, m->contains_unread_mention, date, edit_date, std::move(forward_info), std::move(import_info),
std::move(interaction_info), std::move(unread_reactions), std::move(reply_to), top_thread_message_id, std::move(interaction_info), std::move(unread_reactions), std::move(reply_to), top_thread_message_id,
m->saved_messages_topic_id.get_saved_messages_topic_object(td_), std::move(self_destruct_type), ttl_expires_in, td_->saved_messages_manager_->get_saved_messages_topic_id_object(m->saved_messages_topic_id),
auto_delete_in, via_bot_user_id, m->author_signature, m->media_album_id, std::move(self_destruct_type), ttl_expires_in, auto_delete_in, via_bot_user_id, m->author_signature,
get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup)); m->media_album_id, get_restriction_reason_description(m->restriction_reasons), std::move(content),
std::move(reply_markup));
} }
tl_object_ptr<td_api::messages> MessagesManager::get_messages_object(int32 total_count, DialogId dialog_id, tl_object_ptr<td_api::messages> MessagesManager::get_messages_object(int32 total_count, DialogId dialog_id,

View File

@ -16,6 +16,7 @@
#include "td/telegram/OptionManager.h" #include "td/telegram/OptionManager.h"
#include "td/telegram/ReactionManager.hpp" #include "td/telegram/ReactionManager.hpp"
#include "td/telegram/ReactionType.hpp" #include "td/telegram/ReactionType.hpp"
#include "td/telegram/SavedMessagesManager.h"
#include "td/telegram/StickerFormat.h" #include "td/telegram/StickerFormat.h"
#include "td/telegram/StickersManager.h" #include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
@ -1102,7 +1103,8 @@ td_api::object_ptr<td_api::updateSavedMessagesTags> ReactionManager::get_update_
SavedMessagesTopicId saved_messages_topic_id, const SavedReactionTags *tags) const { SavedMessagesTopicId saved_messages_topic_id, const SavedReactionTags *tags) const {
CHECK(tags != nullptr); CHECK(tags != nullptr);
return td_api::make_object<td_api::updateSavedMessagesTags>( return td_api::make_object<td_api::updateSavedMessagesTags>(
saved_messages_topic_id.get_saved_messages_topic_object(td_), tags->get_saved_messages_tags_object()); td_->saved_messages_manager_->get_saved_messages_topic_id_object(saved_messages_topic_id),
tags->get_saved_messages_tags_object());
} }
void ReactionManager::send_update_saved_messages_tags(SavedMessagesTopicId saved_messages_topic_id, void ReactionManager::send_update_saved_messages_tags(SavedMessagesTopicId saved_messages_topic_id,

View File

@ -314,6 +314,28 @@ void SavedMessagesManager::tear_down() {
parent_.reset(); parent_.reset();
} }
SavedMessagesTopicId SavedMessagesManager::get_topic_id(int64 topic_id) const {
if (topic_id == 0) {
return SavedMessagesTopicId();
}
auto saved_messages_topic_id = SavedMessagesTopicId(DialogId(topic_id));
if (saved_messages_topics_.count(saved_messages_topic_id) == 0) {
// an invalid topic identifier
return SavedMessagesTopicId(DialogId(std::numeric_limits<int64>::max()));
}
return saved_messages_topic_id;
}
int64 SavedMessagesManager::get_saved_messages_topic_id_object(SavedMessagesTopicId saved_messages_topic_id) {
if (saved_messages_topic_id == SavedMessagesTopicId()) {
return 0;
}
add_topic(saved_messages_topic_id);
return saved_messages_topic_id.get_unique_id();
}
SavedMessagesManager::SavedMessagesTopic *SavedMessagesManager::get_topic( SavedMessagesManager::SavedMessagesTopic *SavedMessagesManager::get_topic(
SavedMessagesTopicId saved_messages_topic_id) { SavedMessagesTopicId saved_messages_topic_id) {
CHECK(saved_messages_topic_id.is_valid()); CHECK(saved_messages_topic_id.is_valid());
@ -331,6 +353,7 @@ SavedMessagesManager::SavedMessagesTopic *SavedMessagesManager::add_topic(
if (result == nullptr) { if (result == nullptr) {
result = make_unique<SavedMessagesTopic>(); result = make_unique<SavedMessagesTopic>();
result->saved_messages_topic_id_ = saved_messages_topic_id; result->saved_messages_topic_id_ = saved_messages_topic_id;
send_update_saved_messages_topic(result.get());
} }
return result.get(); return result.get();
} }
@ -614,25 +637,26 @@ void SavedMessagesManager::on_get_saved_messages_topics(
promise.set_value(Unit()); promise.set_value(Unit());
} }
td_api::object_ptr<td_api::foundSavedMessagesTopic> SavedMessagesManager::get_found_saved_messages_topic_object( td_api::object_ptr<td_api::savedMessagesTopic> SavedMessagesManager::get_saved_messages_topic_object(
const SavedMessagesTopic *topic) const { const SavedMessagesTopic *topic) const {
CHECK(topic != nullptr); CHECK(topic != nullptr);
td_api::object_ptr<td_api::message> last_message_object; td_api::object_ptr<td_api::message> last_message_object;
if (topic->last_message_id_ != MessageId()) { if (topic->last_message_id_ != MessageId()) {
last_message_object = td_->messages_manager_->get_message_object( last_message_object = td_->messages_manager_->get_message_object(
{td_->dialog_manager_->get_my_dialog_id(), topic->last_message_id_}, "get_found_saved_messages_topic_object"); {td_->dialog_manager_->get_my_dialog_id(), topic->last_message_id_}, "get_saved_messages_topic_object");
} }
auto public_order = TopicDate(topic->private_order_, topic->saved_messages_topic_id_) <= topic_list_.last_topic_date_ auto public_order = TopicDate(topic->private_order_, topic->saved_messages_topic_id_) <= topic_list_.last_topic_date_
? topic->private_order_ ? topic->private_order_
: static_cast<int64>(0); : static_cast<int64>(0);
return td_api::make_object<td_api::foundSavedMessagesTopic>( return td_api::make_object<td_api::savedMessagesTopic>(
topic->saved_messages_topic_id_.get_saved_messages_topic_object(td_), topic->pinned_order_ != 0, public_order, topic->saved_messages_topic_id_.get_unique_id(),
std::move(last_message_object)); topic->saved_messages_topic_id_.get_saved_messages_topic_type_object(td_), topic->pinned_order_ != 0,
public_order, std::move(last_message_object));
} }
td_api::object_ptr<td_api::updateSavedMessagesTopic> SavedMessagesManager::get_update_saved_messages_topic_object( td_api::object_ptr<td_api::updateSavedMessagesTopic> SavedMessagesManager::get_update_saved_messages_topic_object(
const SavedMessagesTopic *topic) const { const SavedMessagesTopic *topic) const {
return td_api::make_object<td_api::updateSavedMessagesTopic>(get_found_saved_messages_topic_object(topic)); return td_api::make_object<td_api::updateSavedMessagesTopic>(get_saved_messages_topic_object(topic));
} }
void SavedMessagesManager::send_update_saved_messages_topic(const SavedMessagesTopic *topic) const { void SavedMessagesManager::send_update_saved_messages_topic(const SavedMessagesTopic *topic) const {

View File

@ -26,6 +26,10 @@ class SavedMessagesManager final : public Actor {
public: public:
SavedMessagesManager(Td *td, ActorShared<> parent); SavedMessagesManager(Td *td, ActorShared<> parent);
SavedMessagesTopicId get_topic_id(int64 topic_id) const;
int64 get_saved_messages_topic_id_object(SavedMessagesTopicId saved_messages_topic_id);
void set_topic_last_message_id(SavedMessagesTopicId saved_messages_topic_id, MessageId last_message_id, void set_topic_last_message_id(SavedMessagesTopicId saved_messages_topic_id, MessageId last_message_id,
int32 last_message_date); int32 last_message_date);
@ -71,7 +75,7 @@ class SavedMessagesManager final : public Actor {
int32 last_message_date_ = 0; int32 last_message_date_ = 0;
int64 pinned_order_ = 0; int64 pinned_order_ = 0;
int64 private_order_ = 0; int64 private_order_ = 0;
bool is_changed_ = true; bool is_changed_ = false;
}; };
class TopicDate { class TopicDate {
@ -156,8 +160,7 @@ class SavedMessagesManager final : public Actor {
void on_topic_changed(SavedMessagesTopic *topic); void on_topic_changed(SavedMessagesTopic *topic);
td_api::object_ptr<td_api::foundSavedMessagesTopic> get_found_saved_messages_topic_object( td_api::object_ptr<td_api::savedMessagesTopic> get_saved_messages_topic_object(const SavedMessagesTopic *topic) const;
const SavedMessagesTopic *topic) const;
td_api::object_ptr<td_api::updateSavedMessagesTopic> get_update_saved_messages_topic_object( td_api::object_ptr<td_api::updateSavedMessagesTopic> get_update_saved_messages_topic_object(
const SavedMessagesTopic *topic) const; const SavedMessagesTopic *topic) const;

View File

@ -47,41 +47,19 @@ SavedMessagesTopicId::SavedMessagesTopicId(DialogId my_dialog_id, const MessageF
dialog_id_ = my_dialog_id; dialog_id_ = my_dialog_id;
} }
SavedMessagesTopicId::SavedMessagesTopicId(const Td *td, td_api::object_ptr<td_api::SavedMessagesTopicType> SavedMessagesTopicId::get_saved_messages_topic_type_object(
const td_api::object_ptr<td_api::SavedMessagesTopic> &saved_messages_topic) {
if (saved_messages_topic == nullptr) {
return;
}
switch (saved_messages_topic->get_id()) {
case td_api::savedMessagesTopicMyNotes::ID:
dialog_id_ = td->dialog_manager_->get_my_dialog_id();
break;
case td_api::savedMessagesTopicAuthorHidden::ID:
dialog_id_ = HIDDEN_AUTHOR_DIALOG_ID;
break;
case td_api::savedMessagesTopicSavedFromChat::ID:
dialog_id_ =
DialogId(static_cast<const td_api::savedMessagesTopicSavedFromChat *>(saved_messages_topic.get())->chat_id_);
break;
default:
UNREACHABLE();
break;
}
}
td_api::object_ptr<td_api::SavedMessagesTopic> SavedMessagesTopicId::get_saved_messages_topic_object(
const Td *td) const { const Td *td) const {
if (dialog_id_ == DialogId()) { if (dialog_id_ == DialogId()) {
return nullptr; return nullptr;
} }
if (dialog_id_ == td->dialog_manager_->get_my_dialog_id()) { if (dialog_id_ == td->dialog_manager_->get_my_dialog_id()) {
return td_api::make_object<td_api::savedMessagesTopicMyNotes>(); return td_api::make_object<td_api::savedMessagesTopicTypeMyNotes>();
} }
if (is_author_hidden()) { if (is_author_hidden()) {
return td_api::make_object<td_api::savedMessagesTopicAuthorHidden>(); return td_api::make_object<td_api::savedMessagesTopicTypeAuthorHidden>();
} }
return td_api::make_object<td_api::savedMessagesTopicSavedFromChat>( return td_api::make_object<td_api::savedMessagesTopicTypeSavedFromChat>(
td->messages_manager_->get_chat_id_object(dialog_id_, "savedMessagesTopicSavedFromChat")); td->messages_manager_->get_chat_id_object(dialog_id_, "savedMessagesTopicTypeSavedFromChat"));
} }
bool SavedMessagesTopicId::have_input_peer(Td *td) const { bool SavedMessagesTopicId::have_input_peer(Td *td) const {

View File

@ -41,8 +41,6 @@ class SavedMessagesTopicId {
SavedMessagesTopicId(DialogId my_dialog_id, const MessageForwardInfo *message_forward_info, SavedMessagesTopicId(DialogId my_dialog_id, const MessageForwardInfo *message_forward_info,
DialogId real_forward_from_dialog_id); DialogId real_forward_from_dialog_id);
SavedMessagesTopicId(const Td *td, const td_api::object_ptr<td_api::SavedMessagesTopic> &saved_messages_topic);
bool is_valid() const { bool is_valid() const {
return dialog_id_.is_valid(); return dialog_id_.is_valid();
} }
@ -57,7 +55,7 @@ class SavedMessagesTopicId {
return dialog_id_.get(); return dialog_id_.get();
} }
td_api::object_ptr<td_api::SavedMessagesTopic> get_saved_messages_topic_object(const Td *td) const; td_api::object_ptr<td_api::SavedMessagesTopicType> get_saved_messages_topic_type_object(const Td *td) const;
telegram_api::object_ptr<telegram_api::InputPeer> get_input_peer(const Td *td) const; telegram_api::object_ptr<telegram_api::InputPeer> get_input_peer(const Td *td) const;

View File

@ -5066,30 +5066,30 @@ void Td::on_request(uint64 id, const td_api::loadSavedMessagesTopics &request) {
void Td::on_request(uint64 id, const td_api::getSavedMessagesTopicHistory &request) { void Td::on_request(uint64 id, const td_api::getSavedMessagesTopicHistory &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_REQUEST_PROMISE(); CREATE_REQUEST_PROMISE();
saved_messages_manager_->get_saved_messages_topic_history(SavedMessagesTopicId(this, request.saved_messages_topic_), saved_messages_manager_->get_saved_messages_topic_history(
MessageId(request.from_message_id_), request.offset_, saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_), MessageId(request.from_message_id_),
request.limit_, std::move(promise)); request.offset_, request.limit_, std::move(promise));
} }
void Td::on_request(uint64 id, const td_api::getSavedMessagesTopicMessageByDate &request) { void Td::on_request(uint64 id, const td_api::getSavedMessagesTopicMessageByDate &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_REQUEST_PROMISE(); CREATE_REQUEST_PROMISE();
saved_messages_manager_->get_saved_messages_topic_message_by_date( saved_messages_manager_->get_saved_messages_topic_message_by_date(
SavedMessagesTopicId(this, request.saved_messages_topic_), request.date_, std::move(promise)); saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_), request.date_, std::move(promise));
} }
void Td::on_request(uint64 id, const td_api::deleteSavedMessagesTopicHistory &request) { void Td::on_request(uint64 id, const td_api::deleteSavedMessagesTopicHistory &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
saved_messages_manager_->delete_saved_messages_topic_history( saved_messages_manager_->delete_saved_messages_topic_history(
SavedMessagesTopicId(this, request.saved_messages_topic_), std::move(promise)); saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_), std::move(promise));
} }
void Td::on_request(uint64 id, const td_api::deleteSavedMessagesTopicMessagesByDate &request) { void Td::on_request(uint64 id, const td_api::deleteSavedMessagesTopicMessagesByDate &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
saved_messages_manager_->delete_saved_messages_topic_messages_by_date( saved_messages_manager_->delete_saved_messages_topic_messages_by_date(
SavedMessagesTopicId(this, request.saved_messages_topic_), request.min_date_, request.max_date_, saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_), request.min_date_, request.max_date_,
std::move(promise)); std::move(promise));
} }
@ -5097,14 +5097,14 @@ void Td::on_request(uint64 id, const td_api::toggleSavedMessagesTopicIsPinned &r
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
saved_messages_manager_->toggle_saved_messages_topic_is_pinned( saved_messages_manager_->toggle_saved_messages_topic_is_pinned(
SavedMessagesTopicId(this, request.saved_messages_topic_), request.is_pinned_, std::move(promise)); saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_), request.is_pinned_, std::move(promise));
} }
void Td::on_request(uint64 id, const td_api::setPinnedSavedMessagesTopics &request) { void Td::on_request(uint64 id, const td_api::setPinnedSavedMessagesTopics &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
auto saved_messages_topic_ids = transform(request.saved_messages_topics_, auto saved_messages_topic_ids = transform(
[this](const auto &topic) { return SavedMessagesTopicId(this, topic); }); request.saved_messages_topic_ids_, [this](int64 topic) { return saved_messages_manager_->get_topic_id(topic); });
saved_messages_manager_->set_pinned_saved_messages_topics(std::move(saved_messages_topic_ids), std::move(promise)); saved_messages_manager_->set_pinned_saved_messages_topics(std::move(saved_messages_topic_ids), std::move(promise));
} }
@ -5301,7 +5301,7 @@ void Td::on_request(uint64 id, const td_api::getMessageThreadHistory &request) {
void Td::on_request(uint64 id, td_api::getChatMessageCalendar &request) { void Td::on_request(uint64 id, td_api::getChatMessageCalendar &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_REQUEST(GetChatMessageCalendarRequest, request.chat_id_, CREATE_REQUEST(GetChatMessageCalendarRequest, request.chat_id_,
SavedMessagesTopicId(this, request.saved_messages_topic_), request.from_message_id_, saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_), request.from_message_id_,
std::move(request.filter_)); std::move(request.filter_));
} }
@ -5310,7 +5310,8 @@ void Td::on_request(uint64 id, td_api::searchChatMessages &request) {
CLEAN_INPUT_STRING(request.query_); CLEAN_INPUT_STRING(request.query_);
CREATE_REQUEST(SearchChatMessagesRequest, request.chat_id_, std::move(request.query_), std::move(request.sender_id_), CREATE_REQUEST(SearchChatMessagesRequest, request.chat_id_, std::move(request.query_), std::move(request.sender_id_),
request.from_message_id_, request.offset_, request.limit_, std::move(request.filter_), request.from_message_id_, request.offset_, request.limit_, std::move(request.filter_),
request.message_thread_id_, SavedMessagesTopicId(this, request.saved_messages_topic_), ReactionType()); request.message_thread_id_, saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_),
ReactionType());
} }
void Td::on_request(uint64 id, td_api::searchSecretMessages &request) { void Td::on_request(uint64 id, td_api::searchSecretMessages &request) {
@ -5339,7 +5340,7 @@ void Td::on_request(uint64 id, td_api::searchSavedMessages &request) {
CLEAN_INPUT_STRING(request.query_); CLEAN_INPUT_STRING(request.query_);
CREATE_REQUEST(SearchChatMessagesRequest, dialog_manager_->get_my_dialog_id().get(), std::move(request.query_), CREATE_REQUEST(SearchChatMessagesRequest, dialog_manager_->get_my_dialog_id().get(), std::move(request.query_),
nullptr, request.from_message_id_, request.offset_, request.limit_, nullptr, 0, nullptr, request.from_message_id_, request.offset_, request.limit_, nullptr, 0,
SavedMessagesTopicId(this, request.saved_messages_topic_), ReactionType(request.tag_)); saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_), ReactionType(request.tag_));
} }
void Td::on_request(uint64 id, const td_api::searchCallMessages &request) { void Td::on_request(uint64 id, const td_api::searchCallMessages &request) {
@ -5380,7 +5381,7 @@ void Td::on_request(uint64 id, const td_api::getChatSparseMessagePositions &requ
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_REQUEST_PROMISE(); CREATE_REQUEST_PROMISE();
messages_manager_->get_dialog_sparse_message_positions( messages_manager_->get_dialog_sparse_message_positions(
DialogId(request.chat_id_), SavedMessagesTopicId(this, request.saved_messages_topic_), DialogId(request.chat_id_), saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_),
get_message_search_filter(request.filter_), MessageId(request.from_message_id_), request.limit_, get_message_search_filter(request.filter_), MessageId(request.from_message_id_), request.limit_,
std::move(promise)); std::move(promise));
} }
@ -5396,7 +5397,7 @@ void Td::on_request(uint64 id, const td_api::getChatMessageCount &request) {
} }
}); });
messages_manager_->get_dialog_message_count( messages_manager_->get_dialog_message_count(
DialogId(request.chat_id_), SavedMessagesTopicId(this, request.saved_messages_topic_), DialogId(request.chat_id_), saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_),
get_message_search_filter(request.filter_), request.return_local_, std::move(query_promise)); get_message_search_filter(request.filter_), request.return_local_, std::move(query_promise));
} }
@ -5412,7 +5413,7 @@ void Td::on_request(uint64 id, const td_api::getChatMessagePosition &request) {
}); });
messages_manager_->get_dialog_message_position( messages_manager_->get_dialog_message_position(
{DialogId(request.chat_id_), MessageId(request.message_id_)}, get_message_search_filter(request.filter_), {DialogId(request.chat_id_), MessageId(request.message_id_)}, get_message_search_filter(request.filter_),
MessageId(request.message_thread_id_), SavedMessagesTopicId(this, request.saved_messages_topic_), MessageId(request.message_thread_id_), saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_),
std::move(query_promise)); std::move(query_promise));
} }
@ -5490,7 +5491,7 @@ void Td::on_request(uint64 id, const td_api::setDefaultReactionType &request) {
void Td::on_request(uint64 id, const td_api::getSavedMessagesTags &request) { void Td::on_request(uint64 id, const td_api::getSavedMessagesTags &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_REQUEST_PROMISE(); CREATE_REQUEST_PROMISE();
reaction_manager_->get_saved_messages_tags(SavedMessagesTopicId(this, request.saved_messages_topic_), reaction_manager_->get_saved_messages_tags(saved_messages_manager_->get_topic_id(request.saved_messages_topic_id_),
std::move(promise)); std::move(promise));
} }

View File

@ -342,7 +342,7 @@ class CliClient final : public Actor {
LOG(ERROR) << (last_message_id >> 20); LOG(ERROR) << (last_message_id >> 20);
send_request(td_api::make_object<td_api::searchChatMessages>( send_request(td_api::make_object<td_api::searchChatMessages>(
search_chat_id_, string(), nullptr, last_message_id, 0, 100, as_search_messages_filter("pvi"), 0, search_chat_id_, string(), nullptr, last_message_id, 0, 100, as_search_messages_filter("pvi"), 0,
get_saved_messages_topic())); get_saved_messages_topic_id()));
} else { } else {
search_chat_id_ = 0; search_chat_id_ = 0;
} }
@ -946,21 +946,15 @@ class CliClient final : public Actor {
return nullptr; return nullptr;
} }
td_api::object_ptr<td_api::SavedMessagesTopic> as_saved_messages_topic(int64 saved_messages_topic) const { int64 as_saved_messages_topic_id(int64 saved_messages_topic_id) const {
if (saved_messages_topic == 0) { if (saved_messages_topic_id == -1) {
return nullptr; return 2666000;
} }
if (saved_messages_topic == my_id_) { return saved_messages_topic_id;
return td_api::make_object<td_api::savedMessagesTopicMyNotes>();
}
if (saved_messages_topic == -1) {
return td_api::make_object<td_api::savedMessagesTopicAuthorHidden>();
}
return td_api::make_object<td_api::savedMessagesTopicSavedFromChat>(saved_messages_topic);
} }
td_api::object_ptr<td_api::SavedMessagesTopic> get_saved_messages_topic() const { int64 get_saved_messages_topic_id() const {
return as_saved_messages_topic(saved_messages_topic_); return as_saved_messages_topic_id(saved_messages_topic_id_);
} }
td_api::object_ptr<td_api::linkPreviewOptions> get_link_preview_options() const { td_api::object_ptr<td_api::linkPreviewOptions> get_link_preview_options() const {
@ -2763,27 +2757,27 @@ class CliClient final : public Actor {
int32 offset; int32 offset;
string limit; string limit;
get_args(args, from_message_id, offset, limit); get_args(args, from_message_id, offset, limit);
send_request(td_api::make_object<td_api::getSavedMessagesTopicHistory>(get_saved_messages_topic(), send_request(td_api::make_object<td_api::getSavedMessagesTopicHistory>(get_saved_messages_topic_id(),
from_message_id, offset, as_limit(limit))); from_message_id, offset, as_limit(limit)));
} else if (op == "gsmtmbd") { } else if (op == "gsmtmbd") {
send_request(td_api::make_object<td_api::getSavedMessagesTopicMessageByDate>(get_saved_messages_topic(), send_request(td_api::make_object<td_api::getSavedMessagesTopicMessageByDate>(get_saved_messages_topic_id(),
to_integer<int32>(args))); to_integer<int32>(args)));
} else if (op == "dsmth" && args.empty()) { } else if (op == "dsmth" && args.empty()) {
send_request(td_api::make_object<td_api::deleteSavedMessagesTopicHistory>(get_saved_messages_topic())); send_request(td_api::make_object<td_api::deleteSavedMessagesTopicHistory>(get_saved_messages_topic_id()));
} else if (op == "dsmtmbd") { } else if (op == "dsmtmbd") {
int32 min_date; int32 min_date;
int32 max_date; int32 max_date;
get_args(args, min_date, max_date); get_args(args, min_date, max_date);
send_request(td_api::make_object<td_api::deleteSavedMessagesTopicMessagesByDate>(get_saved_messages_topic(), send_request(td_api::make_object<td_api::deleteSavedMessagesTopicMessagesByDate>(get_saved_messages_topic_id(),
min_date, max_date)); min_date, max_date));
} else if (op == "tsmtip") { } else if (op == "tsmtip") {
bool is_pinned; bool is_pinned;
get_args(args, is_pinned); get_args(args, is_pinned);
send_request( send_request(
td_api::make_object<td_api::toggleSavedMessagesTopicIsPinned>(get_saved_messages_topic(), is_pinned)); td_api::make_object<td_api::toggleSavedMessagesTopicIsPinned>(get_saved_messages_topic_id(), is_pinned));
} else if (op == "spsmt") { } else if (op == "spsmt") {
send_request(td_api::make_object<td_api::setPinnedSavedMessagesTopics>( send_request(td_api::make_object<td_api::setPinnedSavedMessagesTopics>(
transform(autosplit(args), [this](Slice str) { return as_saved_messages_topic(as_chat_id(str)); }))); transform(autosplit(args), [this](Slice str) { return as_saved_messages_topic_id(as_chat_id(str)); })));
} else if (op == "gcc" || op == "GetCommonChats") { } else if (op == "gcc" || op == "GetCommonChats") {
UserId user_id; UserId user_id;
ChatId offset_chat_id; ChatId offset_chat_id;
@ -2862,7 +2856,7 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::getMessageAddedReactions>( send_request(td_api::make_object<td_api::getMessageAddedReactions>(
chat_id, message_id, as_reaction_type(reaction), offset, as_limit(limit))); chat_id, message_id, as_reaction_type(reaction), offset, as_limit(limit)));
} else if (op == "gsmts") { } else if (op == "gsmts") {
send_request(td_api::make_object<td_api::getSavedMessagesTags>(get_saved_messages_topic())); send_request(td_api::make_object<td_api::getSavedMessagesTags>(get_saved_messages_topic_id()));
} else if (op == "ssmtl") { } else if (op == "ssmtl") {
string reaction; string reaction;
string label; string label;
@ -2892,11 +2886,11 @@ class CliClient final : public Actor {
get_args(args, chat_id, filter); get_args(args, chat_id, filter);
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", nullptr, 0, 0, 100, send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", nullptr, 0, 0, 100,
as_search_messages_filter(filter), as_search_messages_filter(filter),
message_thread_id_, get_saved_messages_topic())); message_thread_id_, get_saved_messages_topic_id()));
} else if (op == "spvf") { } else if (op == "spvf") {
search_chat_id_ = as_chat_id(args); search_chat_id_ = as_chat_id(args);
send_request(td_api::make_object<td_api::searchChatMessages>( send_request(td_api::make_object<td_api::searchChatMessages>(
search_chat_id_, "", nullptr, 0, 0, 100, as_search_messages_filter("pvi"), 0, get_saved_messages_topic())); search_chat_id_, "", nullptr, 0, 0, 100, as_search_messages_filter("pvi"), 0, get_saved_messages_topic_id()));
} else if (op == "Search" || op == "SearchA" || op == "SearchM") { } else if (op == "Search" || op == "SearchA" || op == "SearchM") {
string query; string query;
string limit; string limit;
@ -2917,14 +2911,14 @@ class CliClient final : public Actor {
SearchQuery query; SearchQuery query;
get_args(args, chat_id, query); get_args(args, chat_id, query);
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, query.query, nullptr, 0, 0, query.limit, send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, query.query, nullptr, 0, 0, query.limit,
nullptr, 0, get_saved_messages_topic())); nullptr, 0, get_saved_messages_topic_id()));
} else if (op == "SMME") { } else if (op == "SMME") {
ChatId chat_id; ChatId chat_id;
string limit; string limit;
get_args(args, chat_id, limit); get_args(args, chat_id, limit);
send_request(td_api::make_object<td_api::searchChatMessages>( send_request(td_api::make_object<td_api::searchChatMessages>(
chat_id, "", td_api::make_object<td_api::messageSenderUser>(my_id_), 0, 0, as_limit(limit), nullptr, 0, chat_id, "", td_api::make_object<td_api::messageSenderUser>(my_id_), 0, 0, as_limit(limit), nullptr, 0,
get_saved_messages_topic())); get_saved_messages_topic_id()));
} else if (op == "SMU" || op == "SMC") { } else if (op == "SMU" || op == "SMC") {
ChatId chat_id; ChatId chat_id;
string sender_id; string sender_id;
@ -2933,7 +2927,7 @@ class CliClient final : public Actor {
get_args(args, chat_id, sender_id, from_message_id, limit); get_args(args, chat_id, sender_id, from_message_id, limit);
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", as_message_sender(sender_id), send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", as_message_sender(sender_id),
from_message_id, 0, as_limit(limit), nullptr, 0, from_message_id, 0, as_limit(limit), nullptr, 0,
get_saved_messages_topic())); get_saved_messages_topic_id()));
} else if (op == "SM") { } else if (op == "SM") {
ChatId chat_id; ChatId chat_id;
string filter; string filter;
@ -2943,7 +2937,7 @@ class CliClient final : public Actor {
get_args(args, chat_id, filter, limit, offset_message_id, offset); get_args(args, chat_id, filter, limit, offset_message_id, offset);
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", nullptr, offset_message_id, offset, send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", nullptr, offset_message_id, offset,
as_limit(limit), as_search_messages_filter(filter), as_limit(limit), as_search_messages_filter(filter),
0, get_saved_messages_topic())); 0, get_saved_messages_topic_id()));
} else if (op == "SC") { } else if (op == "SC") {
string limit; string limit;
string offset; string offset;
@ -2968,7 +2962,7 @@ class CliClient final : public Actor {
MessageId from_message_id; MessageId from_message_id;
get_args(args, chat_id, filter, from_message_id); get_args(args, chat_id, filter, from_message_id);
send_request(td_api::make_object<td_api::getChatMessageCalendar>(chat_id, as_search_messages_filter(filter), send_request(td_api::make_object<td_api::getChatMessageCalendar>(chat_id, as_search_messages_filter(filter),
from_message_id, get_saved_messages_topic())); from_message_id, get_saved_messages_topic_id()));
} else if (op == "SearchAudio" || op == "SearchDocument" || op == "SearchPhoto" || op == "SearchChatPhoto") { } else if (op == "SearchAudio" || op == "SearchDocument" || op == "SearchPhoto" || op == "SearchChatPhoto") {
ChatId chat_id; ChatId chat_id;
MessageId offset_message_id; MessageId offset_message_id;
@ -2976,15 +2970,15 @@ class CliClient final : public Actor {
get_args(args, chat_id, offset_message_id, query); get_args(args, chat_id, offset_message_id, query);
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, query.query, nullptr, offset_message_id, 0, send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, query.query, nullptr, offset_message_id, 0,
query.limit, as_search_messages_filter(op), 0, query.limit, as_search_messages_filter(op), 0,
get_saved_messages_topic())); get_saved_messages_topic_id()));
} else if (op == "ssms") { } else if (op == "ssms") {
string tag; string tag;
MessageId from_message_id; MessageId from_message_id;
int32 offset; int32 offset;
SearchQuery query; SearchQuery query;
get_args(args, tag, from_message_id, offset, query); get_args(args, tag, from_message_id, offset, query);
send_request(td_api::make_object<td_api::searchSavedMessages>(get_saved_messages_topic(), as_reaction_type(tag), send_request(td_api::make_object<td_api::searchSavedMessages>(
query.query, from_message_id, offset, query.limit)); get_saved_messages_topic_id(), as_reaction_type(tag), query.query, from_message_id, offset, query.limit));
} else if (op == "gcmbd") { } else if (op == "gcmbd") {
ChatId chat_id; ChatId chat_id;
int32 date; int32 date;
@ -2997,21 +2991,21 @@ class CliClient final : public Actor {
string limit; string limit;
get_args(args, chat_id, filter, from_message_id, limit); get_args(args, chat_id, filter, from_message_id, limit);
send_request(td_api::make_object<td_api::getChatSparseMessagePositions>( send_request(td_api::make_object<td_api::getChatSparseMessagePositions>(
chat_id, as_search_messages_filter(filter), from_message_id, as_limit(limit), get_saved_messages_topic())); chat_id, as_search_messages_filter(filter), from_message_id, as_limit(limit), get_saved_messages_topic_id()));
} else if (op == "gcmc") { } else if (op == "gcmc") {
ChatId chat_id; ChatId chat_id;
string filter; string filter;
bool return_local; bool return_local;
get_args(args, chat_id, filter, return_local); get_args(args, chat_id, filter, return_local);
send_request(td_api::make_object<td_api::getChatMessageCount>(chat_id, as_search_messages_filter(filter), send_request(td_api::make_object<td_api::getChatMessageCount>(chat_id, as_search_messages_filter(filter),
get_saved_messages_topic(), return_local)); get_saved_messages_topic_id(), return_local));
} else if (op == "gcmp") { } else if (op == "gcmp") {
ChatId chat_id; ChatId chat_id;
MessageId message_id; MessageId message_id;
string filter; string filter;
get_args(args, chat_id, message_id, filter); get_args(args, chat_id, message_id, filter);
send_request(td_api::make_object<td_api::getChatMessagePosition>( send_request(td_api::make_object<td_api::getChatMessagePosition>(
chat_id, message_id, as_search_messages_filter(filter), message_thread_id_, get_saved_messages_topic())); chat_id, message_id, as_search_messages_filter(filter), message_thread_id_, get_saved_messages_topic_id()));
} else if (op == "gup" || op == "gupp") { } else if (op == "gup" || op == "gupp") {
UserId user_id; UserId user_id;
int32 offset; int32 offset;
@ -4681,7 +4675,7 @@ class CliClient final : public Actor {
get_args(args, link_preview_is_disabled_, link_preview_url_, link_preview_force_small_media_, get_args(args, link_preview_is_disabled_, link_preview_url_, link_preview_force_small_media_,
link_preview_force_large_media_, link_preview_show_above_text_); link_preview_force_large_media_, link_preview_show_above_text_);
} else if (op == "ssmt") { } else if (op == "ssmt") {
saved_messages_topic_ = as_chat_id(args); saved_messages_topic_id_ = as_chat_id(args);
} else if (op == "sm" || op == "sms" || op == "smf") { } else if (op == "sm" || op == "sms" || op == "smf") {
ChatId chat_id; ChatId chat_id;
string message; string message;
@ -6547,7 +6541,7 @@ class CliClient final : public Actor {
bool link_preview_force_small_media_ = false; bool link_preview_force_small_media_ = false;
bool link_preview_force_large_media_ = false; bool link_preview_force_large_media_ = false;
bool link_preview_show_above_text_ = false; bool link_preview_show_above_text_ = false;
int64 saved_messages_topic_ = 0; int64 saved_messages_topic_id_ = 0;
ConcurrentScheduler *scheduler_{nullptr}; ConcurrentScheduler *scheduler_{nullptr};