Move MessageSearchFilter to separate files.
GitOrigin-RevId: 07b7df009b4e74a145b5ebc1966190630545baef
This commit is contained in:
parent
7d6546b27a
commit
46f42d80b6
@ -444,6 +444,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/MessageEntity.cpp
|
td/telegram/MessageEntity.cpp
|
||||||
td/telegram/MessageId.cpp
|
td/telegram/MessageId.cpp
|
||||||
td/telegram/MessagesDb.cpp
|
td/telegram/MessagesDb.cpp
|
||||||
|
td/telegram/MessageSearchFilter.cpp
|
||||||
td/telegram/MessagesManager.cpp
|
td/telegram/MessagesManager.cpp
|
||||||
td/telegram/misc.cpp
|
td/telegram/misc.cpp
|
||||||
td/telegram/net/AuthDataShared.cpp
|
td/telegram/net/AuthDataShared.cpp
|
||||||
@ -615,6 +616,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/MessageEntity.h
|
td/telegram/MessageEntity.h
|
||||||
td/telegram/MessageId.h
|
td/telegram/MessageId.h
|
||||||
td/telegram/MessagesDb.h
|
td/telegram/MessagesDb.h
|
||||||
|
td/telegram/MessageSearchFilter.h
|
||||||
td/telegram/MessagesManager.h
|
td/telegram/MessagesManager.h
|
||||||
td/telegram/misc.h
|
td/telegram/misc.h
|
||||||
td/telegram/net/AuthDataShared.h
|
td/telegram/net/AuthDataShared.h
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
enum class AccessRights : int32 { Read, Edit, Write };
|
enum class AccessRights : int32 { Read, Edit, Write };
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "td/telegram/MessageEntity.h"
|
#include "td/telegram/MessageEntity.h"
|
||||||
#include "td/telegram/MessageEntity.hpp"
|
#include "td/telegram/MessageEntity.hpp"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
#include "td/telegram/MessagesDb.h"
|
#include "td/telegram/MessageSearchFilter.h"
|
||||||
#include "td/telegram/misc.h"
|
#include "td/telegram/misc.h"
|
||||||
#include "td/telegram/net/DcId.h"
|
#include "td/telegram/net/DcId.h"
|
||||||
#include "td/telegram/Payments.h"
|
#include "td/telegram/Payments.h"
|
||||||
|
100
td/telegram/MessageSearchFilter.cpp
Normal file
100
td/telegram/MessageSearchFilter.cpp
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#include "td/telegram/MessageSearchFilter.h"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
tl_object_ptr<telegram_api::MessagesFilter> get_input_messages_filter(MessageSearchFilter filter) {
|
||||||
|
switch (filter) {
|
||||||
|
case MessageSearchFilter::Empty:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterEmpty>();
|
||||||
|
case MessageSearchFilter::Animation:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterGif>();
|
||||||
|
case MessageSearchFilter::Audio:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterMusic>();
|
||||||
|
case MessageSearchFilter::Document:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterDocument>();
|
||||||
|
case MessageSearchFilter::Photo:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterPhotos>();
|
||||||
|
case MessageSearchFilter::Video:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterVideo>();
|
||||||
|
case MessageSearchFilter::VoiceNote:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterVoice>();
|
||||||
|
case MessageSearchFilter::PhotoAndVideo:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterPhotoVideo>();
|
||||||
|
case MessageSearchFilter::Url:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterUrl>();
|
||||||
|
case MessageSearchFilter::ChatPhoto:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterChatPhotos>();
|
||||||
|
case MessageSearchFilter::Call:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterPhoneCalls>(0, false /*ignored*/);
|
||||||
|
case MessageSearchFilter::MissedCall:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterPhoneCalls>(
|
||||||
|
telegram_api::inputMessagesFilterPhoneCalls::MISSED_MASK, false /*ignored*/);
|
||||||
|
case MessageSearchFilter::VideoNote:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterRoundVideo>();
|
||||||
|
case MessageSearchFilter::VoiceAndVideoNote:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterRoundVoice>();
|
||||||
|
case MessageSearchFilter::Mention:
|
||||||
|
return make_tl_object<telegram_api::inputMessagesFilterMyMentions>();
|
||||||
|
case MessageSearchFilter::UnreadMention:
|
||||||
|
case MessageSearchFilter::FailedToSend:
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageSearchFilter get_message_search_filter(
|
||||||
|
const tl_object_ptr<td_api::SearchMessagesFilter> &filter) {
|
||||||
|
if (filter == nullptr) {
|
||||||
|
return MessageSearchFilter::Empty;
|
||||||
|
}
|
||||||
|
switch (filter->get_id()) {
|
||||||
|
case td_api::searchMessagesFilterEmpty::ID:
|
||||||
|
return MessageSearchFilter::Empty;
|
||||||
|
case td_api::searchMessagesFilterAnimation::ID:
|
||||||
|
return MessageSearchFilter::Animation;
|
||||||
|
case td_api::searchMessagesFilterAudio::ID:
|
||||||
|
return MessageSearchFilter::Audio;
|
||||||
|
case td_api::searchMessagesFilterDocument::ID:
|
||||||
|
return MessageSearchFilter::Document;
|
||||||
|
case td_api::searchMessagesFilterPhoto::ID:
|
||||||
|
return MessageSearchFilter::Photo;
|
||||||
|
case td_api::searchMessagesFilterVideo::ID:
|
||||||
|
return MessageSearchFilter::Video;
|
||||||
|
case td_api::searchMessagesFilterVoiceNote::ID:
|
||||||
|
return MessageSearchFilter::VoiceNote;
|
||||||
|
case td_api::searchMessagesFilterPhotoAndVideo::ID:
|
||||||
|
return MessageSearchFilter::PhotoAndVideo;
|
||||||
|
case td_api::searchMessagesFilterUrl::ID:
|
||||||
|
return MessageSearchFilter::Url;
|
||||||
|
case td_api::searchMessagesFilterChatPhoto::ID:
|
||||||
|
return MessageSearchFilter::ChatPhoto;
|
||||||
|
case td_api::searchMessagesFilterCall::ID:
|
||||||
|
return MessageSearchFilter::Call;
|
||||||
|
case td_api::searchMessagesFilterMissedCall::ID:
|
||||||
|
return MessageSearchFilter::MissedCall;
|
||||||
|
case td_api::searchMessagesFilterVideoNote::ID:
|
||||||
|
return MessageSearchFilter::VideoNote;
|
||||||
|
case td_api::searchMessagesFilterVoiceAndVideoNote::ID:
|
||||||
|
return MessageSearchFilter::VoiceAndVideoNote;
|
||||||
|
case td_api::searchMessagesFilterMention::ID:
|
||||||
|
return MessageSearchFilter::Mention;
|
||||||
|
case td_api::searchMessagesFilterUnreadMention::ID:
|
||||||
|
return MessageSearchFilter::UnreadMention;
|
||||||
|
case td_api::searchMessagesFilterFailedToSend::ID:
|
||||||
|
return MessageSearchFilter::FailedToSend;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return MessageSearchFilter::Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
61
td/telegram/MessageSearchFilter.h
Normal file
61
td/telegram/MessageSearchFilter.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/telegram/td_api.h"
|
||||||
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
// append only before Size
|
||||||
|
enum class MessageSearchFilter : int32 {
|
||||||
|
Empty,
|
||||||
|
Animation,
|
||||||
|
Audio,
|
||||||
|
Document,
|
||||||
|
Photo,
|
||||||
|
Video,
|
||||||
|
VoiceNote,
|
||||||
|
PhotoAndVideo,
|
||||||
|
Url,
|
||||||
|
ChatPhoto,
|
||||||
|
Call,
|
||||||
|
MissedCall,
|
||||||
|
VideoNote,
|
||||||
|
VoiceAndVideoNote,
|
||||||
|
Mention,
|
||||||
|
UnreadMention,
|
||||||
|
FailedToSend,
|
||||||
|
Size
|
||||||
|
};
|
||||||
|
|
||||||
|
inline constexpr size_t message_search_filter_count() {
|
||||||
|
return static_cast<int32>(MessageSearchFilter::Size) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int32 message_search_filter_index(MessageSearchFilter filter) {
|
||||||
|
CHECK(filter != MessageSearchFilter::Empty);
|
||||||
|
return static_cast<int32>(filter) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int32 message_search_filter_index_mask(MessageSearchFilter filter) {
|
||||||
|
if (filter == MessageSearchFilter::Empty) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1 << message_search_filter_index(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int32 call_message_search_filter_index(MessageSearchFilter filter) {
|
||||||
|
CHECK(filter == MessageSearchFilter::Call || filter == MessageSearchFilter::MissedCall);
|
||||||
|
return static_cast<int32>(filter) - static_cast<int32>(MessageSearchFilter::Call);
|
||||||
|
}
|
||||||
|
|
||||||
|
tl_object_ptr<telegram_api::MessagesFilter> get_input_messages_filter(MessageSearchFilter filter);
|
||||||
|
|
||||||
|
MessageSearchFilter get_message_search_filter(const tl_object_ptr<td_api::SearchMessagesFilter> &filter);
|
||||||
|
|
||||||
|
} // namespace td
|
@ -7,6 +7,7 @@
|
|||||||
#include "td/telegram/MessagesDb.h"
|
#include "td/telegram/MessagesDb.h"
|
||||||
|
|
||||||
#include "td/telegram/logevent/LogEvent.h"
|
#include "td/telegram/logevent/LogEvent.h"
|
||||||
|
#include "td/telegram/MessageSearchFilter.h"
|
||||||
#include "td/telegram/Version.h"
|
#include "td/telegram/Version.h"
|
||||||
|
|
||||||
#include "td/db/SqliteConnectionSafe.h"
|
#include "td/db/SqliteConnectionSafe.h"
|
||||||
@ -755,7 +756,7 @@ class MessagesDbImpl : public MessagesDbSyncInterface {
|
|||||||
} else if (index_i + 1 == static_cast<int>(MessageSearchFilter::MissedCall)) {
|
} else if (index_i + 1 == static_cast<int>(MessageSearchFilter::MissedCall)) {
|
||||||
pos = 1;
|
pos = 1;
|
||||||
} else {
|
} else {
|
||||||
return Status::Error(PSLICE() << "Index_mask is not Call or MissedCall " << query.index_mask);
|
return Status::Error(PSLICE() << "Index mask is not Call or MissedCall " << query.index_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &stmt = get_calls_stmts_[pos];
|
auto &stmt = get_calls_stmts_[pos];
|
||||||
|
@ -26,28 +26,6 @@ namespace td {
|
|||||||
class SqliteConnectionSafe;
|
class SqliteConnectionSafe;
|
||||||
class SqliteDb;
|
class SqliteDb;
|
||||||
|
|
||||||
// append only before Size
|
|
||||||
enum class MessageSearchFilter : int32 {
|
|
||||||
Empty,
|
|
||||||
Animation,
|
|
||||||
Audio,
|
|
||||||
Document,
|
|
||||||
Photo,
|
|
||||||
Video,
|
|
||||||
VoiceNote,
|
|
||||||
PhotoAndVideo,
|
|
||||||
Url,
|
|
||||||
ChatPhoto,
|
|
||||||
Call,
|
|
||||||
MissedCall,
|
|
||||||
VideoNote,
|
|
||||||
VoiceAndVideoNote,
|
|
||||||
Mention,
|
|
||||||
UnreadMention,
|
|
||||||
FailedToSend,
|
|
||||||
Size
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MessagesDbMessagesQuery {
|
struct MessagesDbMessagesQuery {
|
||||||
DialogId dialog_id;
|
DialogId dialog_id;
|
||||||
int32 index_mask{0};
|
int32 index_mask{0};
|
||||||
@ -178,25 +156,4 @@ std::shared_ptr<MessagesDbSyncSafeInterface> create_messages_db_sync(
|
|||||||
std::shared_ptr<MessagesDbAsyncInterface> create_messages_db_async(std::shared_ptr<MessagesDbSyncSafeInterface> sync_db,
|
std::shared_ptr<MessagesDbAsyncInterface> create_messages_db_async(std::shared_ptr<MessagesDbSyncSafeInterface> sync_db,
|
||||||
int32 scheduler_id);
|
int32 scheduler_id);
|
||||||
|
|
||||||
inline constexpr size_t message_search_filter_count() {
|
|
||||||
return static_cast<int32>(MessageSearchFilter::Size) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int32 message_search_filter_index(MessageSearchFilter filter) {
|
|
||||||
CHECK(filter != MessageSearchFilter::Empty);
|
|
||||||
return static_cast<int32>(filter) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int32 message_search_filter_index_mask(MessageSearchFilter filter) {
|
|
||||||
if (filter == MessageSearchFilter::Empty) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1 << message_search_filter_index(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int32 search_calls_filter_index(MessageSearchFilter filter) {
|
|
||||||
CHECK(filter == MessageSearchFilter::Call || filter == MessageSearchFilter::MissedCall);
|
|
||||||
return static_cast<int32>(filter) - static_cast<int32>(MessageSearchFilter::Call);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -1611,9 +1611,9 @@ class SearchMessagesQuery : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_query(G()->net_query_creator().create(telegram_api::messages_search(
|
send_query(G()->net_query_creator().create(telegram_api::messages_search(
|
||||||
flags, std::move(input_peer), query, std::move(sender_input_user),
|
flags, std::move(input_peer), query, std::move(sender_input_user), get_input_messages_filter(filter), 0,
|
||||||
MessagesManager::get_input_messages_filter(filter), 0, std::numeric_limits<int32>::max(),
|
std::numeric_limits<int32>::max(), from_message_id.get_server_message_id().get(), offset, limit,
|
||||||
from_message_id.get_server_message_id().get(), offset, limit, std::numeric_limits<int32>::max(), 0, 0)));
|
std::numeric_limits<int32>::max(), 0, 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1674,8 +1674,8 @@ class SearchMessagesGlobalQuery : public Td::ResultHandler {
|
|||||||
flags |= telegram_api::messages_searchGlobal::FOLDER_ID_MASK;
|
flags |= telegram_api::messages_searchGlobal::FOLDER_ID_MASK;
|
||||||
}
|
}
|
||||||
send_query(G()->net_query_creator().create(telegram_api::messages_searchGlobal(
|
send_query(G()->net_query_creator().create(telegram_api::messages_searchGlobal(
|
||||||
flags, folder_id.get(), query, MessagesManager::get_input_messages_filter(filter), offset_date_,
|
flags, folder_id.get(), query, get_input_messages_filter(filter), offset_date_, std::move(input_peer),
|
||||||
std::move(input_peer), offset_message_id.get_server_message_id().get(), limit)));
|
offset_message_id.get_server_message_id().get(), limit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_result(uint64 id, BufferSlice packet) override {
|
void on_result(uint64 id, BufferSlice packet) override {
|
||||||
@ -8633,7 +8633,7 @@ void MessagesManager::on_get_dialog_messages_search_result(DialogId dialog_id, c
|
|||||||
if (G()->parameters().use_message_db) {
|
if (G()->parameters().use_message_db) {
|
||||||
bool update_state = false;
|
bool update_state = false;
|
||||||
|
|
||||||
auto &old_message_count = calls_db_state_.message_count_by_index[search_calls_filter_index(filter)];
|
auto &old_message_count = calls_db_state_.message_count_by_index[call_message_search_filter_index(filter)];
|
||||||
if (old_message_count != total_count) {
|
if (old_message_count != total_count) {
|
||||||
LOG(INFO) << "Update calls database message count to " << total_count;
|
LOG(INFO) << "Update calls database message count to " << total_count;
|
||||||
old_message_count = total_count;
|
old_message_count = total_count;
|
||||||
@ -8641,7 +8641,7 @@ void MessagesManager::on_get_dialog_messages_search_result(DialogId dialog_id, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto &old_first_db_message_id =
|
auto &old_first_db_message_id =
|
||||||
calls_db_state_.first_calls_database_message_id_by_index[search_calls_filter_index(filter)];
|
calls_db_state_.first_calls_database_message_id_by_index[call_message_search_filter_index(filter)];
|
||||||
bool from_the_end = !from_message_id.is_valid() || from_message_id >= MessageId::max();
|
bool from_the_end = !from_message_id.is_valid() || from_message_id >= MessageId::max();
|
||||||
LOG(INFO) << "Have from_the_end = " << from_the_end << ", old_first_db_message_id = " << old_first_db_message_id
|
LOG(INFO) << "Have from_the_end = " << from_the_end << ", old_first_db_message_id = " << old_first_db_message_id
|
||||||
<< ", first_added_message_id = " << first_added_message_id << ", from_message_id = " << from_message_id;
|
<< ", first_added_message_id = " << first_added_message_id << ", from_message_id = " << from_message_id;
|
||||||
@ -18603,8 +18603,8 @@ std::pair<int32, vector<FullMessageId>> MessagesManager::search_call_messages(Me
|
|||||||
if (use_db && G()->parameters().use_message_db) {
|
if (use_db && G()->parameters().use_message_db) {
|
||||||
// try to use database
|
// try to use database
|
||||||
MessageId first_db_message_id =
|
MessageId first_db_message_id =
|
||||||
calls_db_state_.first_calls_database_message_id_by_index[search_calls_filter_index(filter_type)];
|
calls_db_state_.first_calls_database_message_id_by_index[call_message_search_filter_index(filter_type)];
|
||||||
int32 message_count = calls_db_state_.message_count_by_index[search_calls_filter_index(filter_type)];
|
int32 message_count = calls_db_state_.message_count_by_index[call_message_search_filter_index(filter_type)];
|
||||||
auto fixed_from_message_id = from_message_id;
|
auto fixed_from_message_id = from_message_id;
|
||||||
if (fixed_from_message_id == MessageId()) {
|
if (fixed_from_message_id == MessageId()) {
|
||||||
fixed_from_message_id = MessageId::max();
|
fixed_from_message_id = MessageId::max();
|
||||||
@ -19222,7 +19222,7 @@ void MessagesManager::on_messages_db_calls_result(Result<MessagesDbCallsResult>
|
|||||||
res.push_back(FullMessageId(message.dialog_id, m->message_id));
|
res.push_back(FullMessageId(message.dialog_id, m->message_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it->second.first = calls_db_state_.message_count_by_index[search_calls_filter_index(filter)];
|
it->second.first = calls_db_state_.message_count_by_index[call_message_search_filter_index(filter)];
|
||||||
|
|
||||||
if (res.empty() && first_db_message_id != MessageId::min()) {
|
if (res.empty() && first_db_message_id != MessageId::min()) {
|
||||||
LOG(INFO) << "No messages in database found";
|
LOG(INFO) << "No messages in database found";
|
||||||
@ -27333,93 +27333,6 @@ void MessagesManager::clear_active_dialog_actions(DialogId dialog_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::MessagesFilter> MessagesManager::get_input_messages_filter(MessageSearchFilter filter) {
|
|
||||||
switch (filter) {
|
|
||||||
case MessageSearchFilter::Empty:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterEmpty>();
|
|
||||||
case MessageSearchFilter::Animation:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterGif>();
|
|
||||||
case MessageSearchFilter::Audio:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterMusic>();
|
|
||||||
case MessageSearchFilter::Document:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterDocument>();
|
|
||||||
case MessageSearchFilter::Photo:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterPhotos>();
|
|
||||||
case MessageSearchFilter::Video:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterVideo>();
|
|
||||||
case MessageSearchFilter::VoiceNote:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterVoice>();
|
|
||||||
case MessageSearchFilter::PhotoAndVideo:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterPhotoVideo>();
|
|
||||||
case MessageSearchFilter::Url:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterUrl>();
|
|
||||||
case MessageSearchFilter::ChatPhoto:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterChatPhotos>();
|
|
||||||
case MessageSearchFilter::Call:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterPhoneCalls>(0, false /*ignored*/);
|
|
||||||
case MessageSearchFilter::MissedCall:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterPhoneCalls>(
|
|
||||||
telegram_api::inputMessagesFilterPhoneCalls::MISSED_MASK, false /*ignored*/);
|
|
||||||
case MessageSearchFilter::VideoNote:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterRoundVideo>();
|
|
||||||
case MessageSearchFilter::VoiceAndVideoNote:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterRoundVoice>();
|
|
||||||
case MessageSearchFilter::Mention:
|
|
||||||
return make_tl_object<telegram_api::inputMessagesFilterMyMentions>();
|
|
||||||
case MessageSearchFilter::UnreadMention:
|
|
||||||
case MessageSearchFilter::FailedToSend:
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageSearchFilter MessagesManager::get_message_search_filter(
|
|
||||||
const tl_object_ptr<td_api::SearchMessagesFilter> &filter) {
|
|
||||||
if (filter == nullptr) {
|
|
||||||
return MessageSearchFilter::Empty;
|
|
||||||
}
|
|
||||||
switch (filter->get_id()) {
|
|
||||||
case td_api::searchMessagesFilterEmpty::ID:
|
|
||||||
return MessageSearchFilter::Empty;
|
|
||||||
case td_api::searchMessagesFilterAnimation::ID:
|
|
||||||
return MessageSearchFilter::Animation;
|
|
||||||
case td_api::searchMessagesFilterAudio::ID:
|
|
||||||
return MessageSearchFilter::Audio;
|
|
||||||
case td_api::searchMessagesFilterDocument::ID:
|
|
||||||
return MessageSearchFilter::Document;
|
|
||||||
case td_api::searchMessagesFilterPhoto::ID:
|
|
||||||
return MessageSearchFilter::Photo;
|
|
||||||
case td_api::searchMessagesFilterVideo::ID:
|
|
||||||
return MessageSearchFilter::Video;
|
|
||||||
case td_api::searchMessagesFilterVoiceNote::ID:
|
|
||||||
return MessageSearchFilter::VoiceNote;
|
|
||||||
case td_api::searchMessagesFilterPhotoAndVideo::ID:
|
|
||||||
return MessageSearchFilter::PhotoAndVideo;
|
|
||||||
case td_api::searchMessagesFilterUrl::ID:
|
|
||||||
return MessageSearchFilter::Url;
|
|
||||||
case td_api::searchMessagesFilterChatPhoto::ID:
|
|
||||||
return MessageSearchFilter::ChatPhoto;
|
|
||||||
case td_api::searchMessagesFilterCall::ID:
|
|
||||||
return MessageSearchFilter::Call;
|
|
||||||
case td_api::searchMessagesFilterMissedCall::ID:
|
|
||||||
return MessageSearchFilter::MissedCall;
|
|
||||||
case td_api::searchMessagesFilterVideoNote::ID:
|
|
||||||
return MessageSearchFilter::VideoNote;
|
|
||||||
case td_api::searchMessagesFilterVoiceAndVideoNote::ID:
|
|
||||||
return MessageSearchFilter::VoiceAndVideoNote;
|
|
||||||
case td_api::searchMessagesFilterMention::ID:
|
|
||||||
return MessageSearchFilter::Mention;
|
|
||||||
case td_api::searchMessagesFilterUnreadMention::ID:
|
|
||||||
return MessageSearchFilter::UnreadMention;
|
|
||||||
case td_api::searchMessagesFilterFailedToSend::ID:
|
|
||||||
return MessageSearchFilter::FailedToSend;
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
return MessageSearchFilter::Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<DialogListId> MessagesManager::get_dialog_lists_to_add_dialog(DialogId dialog_id) {
|
vector<DialogListId> MessagesManager::get_dialog_lists_to_add_dialog(DialogId dialog_id) {
|
||||||
vector<DialogListId> result;
|
vector<DialogListId> result;
|
||||||
const Dialog *d = get_dialog_force(dialog_id);
|
const Dialog *d = get_dialog_force(dialog_id);
|
||||||
|
@ -6,10 +6,6 @@
|
|||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/telegram/secret_api.h"
|
|
||||||
#include "td/telegram/td_api.h"
|
|
||||||
#include "td/telegram/telegram_api.h"
|
|
||||||
|
|
||||||
#include "td/telegram/AccessRights.h"
|
#include "td/telegram/AccessRights.h"
|
||||||
#include "td/telegram/ChannelId.h"
|
#include "td/telegram/ChannelId.h"
|
||||||
#include "td/telegram/Dependencies.h"
|
#include "td/telegram/Dependencies.h"
|
||||||
@ -32,6 +28,7 @@
|
|||||||
#include "td/telegram/MessageCopyOptions.h"
|
#include "td/telegram/MessageCopyOptions.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
#include "td/telegram/MessagesDb.h"
|
#include "td/telegram/MessagesDb.h"
|
||||||
|
#include "td/telegram/MessageSearchFilter.h"
|
||||||
#include "td/telegram/net/NetQuery.h"
|
#include "td/telegram/net/NetQuery.h"
|
||||||
#include "td/telegram/Notification.h"
|
#include "td/telegram/Notification.h"
|
||||||
#include "td/telegram/NotificationGroupId.h"
|
#include "td/telegram/NotificationGroupId.h"
|
||||||
@ -47,6 +44,10 @@
|
|||||||
#include "td/telegram/ServerMessageId.h"
|
#include "td/telegram/ServerMessageId.h"
|
||||||
#include "td/telegram/UserId.h"
|
#include "td/telegram/UserId.h"
|
||||||
|
|
||||||
|
#include "td/telegram/secret_api.h"
|
||||||
|
#include "td/telegram/td_api.h"
|
||||||
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
#include "td/actor/MultiPromise.h"
|
#include "td/actor/MultiPromise.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
@ -734,10 +735,6 @@ class MessagesManager : public Actor {
|
|||||||
void on_resolved_username(const string &username, DialogId dialog_id);
|
void on_resolved_username(const string &username, DialogId dialog_id);
|
||||||
void drop_username(const string &username);
|
void drop_username(const string &username);
|
||||||
|
|
||||||
static tl_object_ptr<telegram_api::MessagesFilter> get_input_messages_filter(MessageSearchFilter filter);
|
|
||||||
|
|
||||||
static MessageSearchFilter get_message_search_filter(const tl_object_ptr<td_api::SearchMessagesFilter> &filter);
|
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(DialogId dialogId) const;
|
tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(DialogId dialogId) const;
|
||||||
|
|
||||||
void on_update_dialog_notify_settings(DialogId dialog_id,
|
void on_update_dialog_notify_settings(DialogId dialog_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user