Add searchMessagesFilterPinned.

GitOrigin-RevId: 322b7b59d91b0de47ac3bbc3734b1f81130fd152
This commit is contained in:
levlam 2020-10-20 02:41:24 +03:00
parent ef09c6c5a9
commit f2f214f46b
7 changed files with 22 additions and 6 deletions

View File

@ -1898,6 +1898,9 @@ searchMessagesFilterUnreadMention = SearchMessagesFilter;
//@description Returns only failed to send messages. This filter can be used only if the message database is used
searchMessagesFilterFailedToSend = SearchMessagesFilter;
//@description Returns only pinned messages
searchMessagesFilterPinned = SearchMessagesFilter;
//@class ChatAction @description Describes the different types of activity in a chat
@ -3707,7 +3710,7 @@ searchChatMessages chat_id:int53 query:string sender:MessageSender from_message_
//@offset_chat_id The chat identifier of the last found message, or 0 for the first request
//@offset_message_id The message identifier of the last found message, or 0 for the first request
//@limit The maximum number of messages to be returned; up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached
//@filter Filter for message content in the search results; searchMessagesFilterCall, searchMessagesFilterMissedCall, searchMessagesFilterMention, searchMessagesFilterUnreadMention and searchMessagesFilterFailedToSend are unsupported in this function
//@filter Filter for message content in the search results; searchMessagesFilterCall, searchMessagesFilterMissedCall, searchMessagesFilterMention, searchMessagesFilterUnreadMention, searchMessagesFilterFailedToSend and searchMessagesFilterPinned are unsupported in this function
//@min_date If not 0, the minimum date of the messages to return
//@max_date If not 0, the maximum date of the messages to return
searchMessages chat_list:ChatList query:string offset_date:int32 offset_chat_id:int53 offset_message_id:int53 limit:int32 filter:SearchMessagesFilter min_date:int32 max_date:int32 = Messages;

Binary file not shown.

View File

@ -262,6 +262,7 @@ inputMessagesFilterRoundVideo#b549da53 = MessagesFilter;
inputMessagesFilterMyMentions#c1f8e69a = MessagesFilter;
inputMessagesFilterGeo#e7026d0d = MessagesFilter;
inputMessagesFilterContacts#e062db83 = MessagesFilter;
inputMessagesFilterPinned#1bb00451 = MessagesFilter;
updateNewMessage#1f2b0afd message:Message pts:int pts_count:int = Update;
updateMessageID#4e90bfd6 id:int random_id:long = Update;

Binary file not shown.

View File

@ -43,6 +43,8 @@ tl_object_ptr<telegram_api::MessagesFilter> get_input_messages_filter(MessageSea
return make_tl_object<telegram_api::inputMessagesFilterRoundVoice>();
case MessageSearchFilter::Mention:
return make_tl_object<telegram_api::inputMessagesFilterMyMentions>();
case MessageSearchFilter::Pinned:
return make_tl_object<telegram_api::inputMessagesFilterPinned>();
case MessageSearchFilter::UnreadMention:
case MessageSearchFilter::FailedToSend:
default:
@ -90,6 +92,8 @@ MessageSearchFilter get_message_search_filter(const tl_object_ptr<td_api::Search
return MessageSearchFilter::UnreadMention;
case td_api::searchMessagesFilterFailedToSend::ID:
return MessageSearchFilter::FailedToSend;
case td_api::searchMessagesFilterPinned::ID:
return MessageSearchFilter::Pinned;
default:
UNREACHABLE();
return MessageSearchFilter::Empty;
@ -132,6 +136,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, MessageSearchFilter fil
return string_builder << "UnreadMention";
case MessageSearchFilter::FailedToSend:
return string_builder << "FailedToSend";
case MessageSearchFilter::Pinned:
return string_builder << "Pinned";
default:
UNREACHABLE();
return string_builder;

View File

@ -33,6 +33,7 @@ enum class MessageSearchFilter : int32 {
Mention,
UnreadMention,
FailedToSend,
Pinned,
Size
};

View File

@ -5753,11 +5753,16 @@ int32 MessagesManager::get_message_index_mask(DialogId dialog_id, const Message
if (!m->message_id.is_server() && !is_secret) {
return 0;
}
int32 index_mask = 0;
if (m->is_pinned) {
index_mask |= message_search_filter_index_mask(MessageSearchFilter::Pinned);
}
// retain second condition just in case
if (m->is_content_secret || (m->ttl > 0 && !is_secret)) {
return 0;
return index_mask;
}
int32 index_mask = get_message_content_index_mask(m->content.get(), td_, m->is_outgoing);
index_mask |= get_message_content_index_mask(m->content.get(), td_, m->is_outgoing);
if (m->contains_mention) {
index_mask |= message_search_filter_index_mask(MessageSearchFilter::Mention);
if (m->contains_unread_mention) {
@ -20138,7 +20143,7 @@ std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
random_id);
break;
case DialogType::SecretChat:
if (filter == MessageSearchFilter::UnreadMention) {
if (filter == MessageSearchFilter::UnreadMention || filter == MessageSearchFilter::Pinned) {
promise.set_value(Unit());
} else {
promise.set_error(Status::Error(500, "Search messages in secret chats is not supported"));
@ -20905,7 +20910,7 @@ std::pair<int32, vector<FullMessageId>> MessagesManager::search_messages(
if (filter == MessageSearchFilter::Call || filter == MessageSearchFilter::MissedCall ||
filter == MessageSearchFilter::Mention || filter == MessageSearchFilter::UnreadMention ||
filter == MessageSearchFilter::FailedToSend) {
filter == MessageSearchFilter::FailedToSend || filter == MessageSearchFilter::Pinned) {
promise.set_error(Status::Error(400, "The filter is not supported"));
return {};
}
@ -21110,7 +21115,7 @@ int32 MessagesManager::get_dialog_message_count(DialogId dialog_id, MessageSearc
}
if (filter == MessageSearchFilter::Empty) {
promise.set_error(Status::Error(6, "SearchMessagesFilterEmpty is not supported"));
promise.set_error(Status::Error(6, "Can't use searchMessagesFilterEmpty"));
return -1;
}