Update to layer 100. Add td_api::userPrivacySettingShowPhoneNumber and td_api::topChatCategoryForwardChats.
GitOrigin-RevId: 96fd17d9fef8e08b4415ec0d8e13e6cdb37f589b
This commit is contained in:
parent
12ea695b54
commit
779fbb6d83
@ -2260,6 +2260,9 @@ userPrivacySettingShowProfilePhoto = UserPrivacySetting;
|
||||
//@description A privacy setting for managing whether a link to the user's account is included in forwarded messages
|
||||
userPrivacySettingShowLinkInForwardedMessages = UserPrivacySetting;
|
||||
|
||||
//@description A privacy setting for managing whether the user's phone number is visible
|
||||
userPrivacySettingShowPhoneNumber = UserPrivacySetting;
|
||||
|
||||
//@description A privacy setting for managing whether the user can be invited to chats
|
||||
userPrivacySettingAllowChatInvites = UserPrivacySetting;
|
||||
|
||||
@ -2500,6 +2503,9 @@ topChatCategoryInlineBots = TopChatCategory;
|
||||
//@description A category containing frequently used chats used for calls
|
||||
topChatCategoryCalls = TopChatCategory;
|
||||
|
||||
//@description A category containing frequently used chats used to forward messages
|
||||
topChatCategoryForwardChats = TopChatCategory;
|
||||
|
||||
|
||||
//@class TMeUrlType @description Describes the type of a URL linking to an internal Telegram entity
|
||||
|
||||
|
Binary file not shown.
@ -110,11 +110,11 @@ userStatusLastMonth#77ebc742 = UserStatus;
|
||||
chatEmpty#9ba2d800 id:int = Chat;
|
||||
chat#3bda1bde flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat;
|
||||
chatForbidden#7328bdb id:int title:string = Chat;
|
||||
channel#4df30834 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat;
|
||||
channel#4df30834 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat;
|
||||
channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat;
|
||||
|
||||
chatFull#1b7c9db3 flags:# can_set_username:flags.7?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int folder_id:flags.11?int = ChatFull;
|
||||
channelFull#3648977 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_view_stats:flags.12?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int pts:int = ChatFull;
|
||||
channelFull#9882e516 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_view_stats:flags.12?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.13?int pts:int = ChatFull;
|
||||
|
||||
chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant;
|
||||
chatParticipantCreator#da13538a user_id:int = ChatParticipant;
|
||||
@ -232,7 +232,7 @@ messages.dialogsSlice#71e094f3 count:int dialogs:Vector<Dialog> messages:Vector<
|
||||
messages.dialogsNotModified#f0e3e596 count:int = messages.Dialogs;
|
||||
|
||||
messages.messages#8c718e87 messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
|
||||
messages.messagesSlice#a6c47aaa flags:# inexact:flags.1?true count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
|
||||
messages.messagesSlice#c8edce1e flags:# inexact:flags.1?true count:int next_rate:flags.0?int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
|
||||
messages.channelMessages#99262e37 flags:# inexact:flags.1?true pts:int count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
|
||||
messages.messagesNotModified#74535f21 count:int = messages.Messages;
|
||||
|
||||
@ -425,6 +425,7 @@ inputPrivacyKeyPhoneCall#fabadc5f = InputPrivacyKey;
|
||||
inputPrivacyKeyPhoneP2P#db9e70d2 = InputPrivacyKey;
|
||||
inputPrivacyKeyForwards#a4dd4c08 = InputPrivacyKey;
|
||||
inputPrivacyKeyProfilePhoto#5719bacc = InputPrivacyKey;
|
||||
inputPrivacyKeyPhoneNumber#352dafa = InputPrivacyKey;
|
||||
|
||||
privacyKeyStatusTimestamp#bc2eab30 = PrivacyKey;
|
||||
privacyKeyChatInvite#500e6dfa = PrivacyKey;
|
||||
@ -432,6 +433,7 @@ privacyKeyPhoneCall#3d662b7b = PrivacyKey;
|
||||
privacyKeyPhoneP2P#39491cc8 = PrivacyKey;
|
||||
privacyKeyForwards#69ec56a3 = PrivacyKey;
|
||||
privacyKeyProfilePhoto#96151fed = PrivacyKey;
|
||||
privacyKeyPhoneNumber#d19ae46d = PrivacyKey;
|
||||
|
||||
inputPrivacyValueAllowContacts#d09e07b = InputPrivacyRule;
|
||||
inputPrivacyValueAllowAll#184b35ce = InputPrivacyRule;
|
||||
@ -439,6 +441,8 @@ inputPrivacyValueAllowUsers#131cc67f users:Vector<InputUser> = InputPrivacyRule;
|
||||
inputPrivacyValueDisallowContacts#ba52007 = InputPrivacyRule;
|
||||
inputPrivacyValueDisallowAll#d66b66c9 = InputPrivacyRule;
|
||||
inputPrivacyValueDisallowUsers#90110467 users:Vector<InputUser> = InputPrivacyRule;
|
||||
inputPrivacyValueAllowChatParticipants#4c81c1ba chats:Vector<int> = InputPrivacyRule;
|
||||
inputPrivacyValueDisallowChatParticipants#d82363af chats:Vector<int> = InputPrivacyRule;
|
||||
|
||||
privacyValueAllowContacts#fffe1bac = PrivacyRule;
|
||||
privacyValueAllowAll#65427b82 = PrivacyRule;
|
||||
@ -446,8 +450,10 @@ privacyValueAllowUsers#4d5bbe0c users:Vector<int> = PrivacyRule;
|
||||
privacyValueDisallowContacts#f888fa1a = PrivacyRule;
|
||||
privacyValueDisallowAll#8b73e763 = PrivacyRule;
|
||||
privacyValueDisallowUsers#c7f49b7 users:Vector<int> = PrivacyRule;
|
||||
privacyValueAllowChatParticipants#18be796b chats:Vector<int> = PrivacyRule;
|
||||
privacyValueDisallowChatParticipants#acae0690 chats:Vector<int> = PrivacyRule;
|
||||
|
||||
account.privacyRules#554abb6f rules:Vector<PrivacyRule> users:Vector<User> = account.PrivacyRules;
|
||||
account.privacyRules#50a04e45 rules:Vector<PrivacyRule> chats:Vector<Chat> users:Vector<User> = account.PrivacyRules;
|
||||
|
||||
accountDaysTTL#b8d0afdf days:int = AccountDaysTTL;
|
||||
|
||||
@ -471,7 +477,6 @@ messages.affectedMessages#84d19185 pts:int pts_count:int = messages.AffectedMess
|
||||
|
||||
contactLinkUnknown#5f4f9247 = ContactLink;
|
||||
contactLinkNone#feedd3ad = ContactLink;
|
||||
contactLinkHasPhone#268f3f59 = ContactLink;
|
||||
contactLinkContact#d502c2d0 = ContactLink;
|
||||
|
||||
webPageEmpty#eb1477e8 id:long = WebPage;
|
||||
@ -643,6 +648,8 @@ topPeerCategoryCorrespondents#637b7ed = TopPeerCategory;
|
||||
topPeerCategoryGroups#bd17a14a = TopPeerCategory;
|
||||
topPeerCategoryChannels#161d9628 = TopPeerCategory;
|
||||
topPeerCategoryPhoneCalls#1e76a78c = TopPeerCategory;
|
||||
topPeerCategoryForwardUsers#a8406ca9 = TopPeerCategory;
|
||||
topPeerCategoryForwardChats#fbeec0f0 = TopPeerCategory;
|
||||
|
||||
topPeerCategoryPeers#fb834291 category:TopPeerCategory count:int peers:Vector<TopPeer> = TopPeerCategoryPeers;
|
||||
|
||||
@ -827,6 +834,7 @@ channelAdminLogEventActionChangeStickerSet#b1c3caa7 prev_stickerset:InputSticker
|
||||
channelAdminLogEventActionTogglePreHistoryHidden#5f5c95f1 new_value:Bool = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionDefaultBannedRights#2df5fc0a prev_banned_rights:ChatBannedRights new_banned_rights:ChatBannedRights = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionStopPoll#8f079643 message:Message = ChannelAdminLogEventAction;
|
||||
channelAdminLogEventActionChangeLinkedChat#a26f881b prev_value:int new_value:int = ChannelAdminLogEventAction;
|
||||
|
||||
channelAdminLogEvent#3b5a3e40 id:long date:int user_id:int action:ChannelAdminLogEventAction = ChannelAdminLogEvent;
|
||||
|
||||
@ -1031,6 +1039,12 @@ inputFolderPeer#fbd2c296 peer:InputPeer folder_id:int = InputFolderPeer;
|
||||
|
||||
folderPeer#e9baa668 peer:Peer folder_id:int = FolderPeer;
|
||||
|
||||
messages.searchCounter#e844ebff flags:# inexact:flags.1?true filter:MessagesFilter count:int = messages.SearchCounter;
|
||||
|
||||
urlAuthResultRequest#92d33a0e flags:# request_write_access:flags.0?true bot:User domain:string = UrlAuthResult;
|
||||
urlAuthResultAccepted#8f8c0e4e url:string = UrlAuthResult;
|
||||
urlAuthResultDefault#a9d6db1f = UrlAuthResult;
|
||||
|
||||
---functions---
|
||||
|
||||
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
||||
@ -1129,7 +1143,7 @@ contacts.unblock#e54100bd id:InputUser = Bool;
|
||||
contacts.getBlocked#f57c350f offset:int limit:int = contacts.Blocked;
|
||||
contacts.search#11f812d8 q:string limit:int = contacts.Found;
|
||||
contacts.resolveUsername#f93ccba3 username:string = contacts.ResolvedPeer;
|
||||
contacts.getTopPeers#d4982db5 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true groups:flags.10?true channels:flags.15?true offset:int limit:int hash:int = contacts.TopPeers;
|
||||
contacts.getTopPeers#d4982db5 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true offset:int limit:int hash:int = contacts.TopPeers;
|
||||
contacts.resetTopPeerRating#1ae373ac category:TopPeerCategory peer:InputPeer = Bool;
|
||||
contacts.resetSaved#879537f1 = Bool;
|
||||
contacts.getSaved#82f1e39f = Vector<SavedContact>;
|
||||
@ -1183,7 +1197,7 @@ messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_par
|
||||
messages.getMessagesViews#c4c8a55d peer:InputPeer id:Vector<int> increment:Bool = Vector<int>;
|
||||
messages.editChatAdmin#a9e69f2e chat_id:int user_id:InputUser is_admin:Bool = Bool;
|
||||
messages.migrateChat#15a3b8e3 chat_id:int = Updates;
|
||||
messages.searchGlobal#9e3cacb0 q:string offset_date:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
|
||||
messages.searchGlobal#f79c611 q:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
|
||||
messages.reorderStickerSets#78337739 flags:# masks:flags.0?true order:Vector<long> = Bool;
|
||||
messages.getDocumentByHash#338e2464 sha256:bytes size:int mime_type:string = Document;
|
||||
messages.searchGifs#bf9a776b q:string offset:int = messages.FoundGifs;
|
||||
@ -1245,6 +1259,9 @@ messages.getEmojiKeywords#35a0e062 lang_code:string = EmojiKeywordsDifference;
|
||||
messages.getEmojiKeywordsDifference#1508b6af lang_code:string from_version:int = EmojiKeywordsDifference;
|
||||
messages.getEmojiKeywordsLanguages#4e9963b2 lang_codes:Vector<string> = Vector<EmojiLanguage>;
|
||||
messages.getEmojiURL#d5b10c26 lang_code:string = EmojiURL;
|
||||
messages.getSearchCounters#732eef00 peer:InputPeer filters:Vector<MessagesFilter> = Vector<messages.SearchCounter>;
|
||||
messages.requestUrlAuth#e33f5613 peer:InputPeer msg_id:int button_id:int = UrlAuthResult;
|
||||
messages.acceptUrlAuth#f729ea98 flags:# write_allowed:flags.0?true peer:InputPeer msg_id:int button_id:int = UrlAuthResult;
|
||||
|
||||
updates.getState#edd4882a = updates.State;
|
||||
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
||||
@ -1313,6 +1330,8 @@ channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector<int> = Bool
|
||||
channels.deleteHistory#af369d42 channel:InputChannel max_id:int = Bool;
|
||||
channels.togglePreHistoryHidden#eabbb94c channel:InputChannel enabled:Bool = Updates;
|
||||
channels.getLeftChannels#8341ecc0 offset:int = messages.Chats;
|
||||
channels.getGroupsForDiscussion#f5dad378 = messages.Chats;
|
||||
channels.setDiscussionGroup#40582bb2 broadcast:InputChannel group:InputChannel = Bool;
|
||||
|
||||
bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON;
|
||||
bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool;
|
||||
|
Binary file not shown.
@ -7314,8 +7314,6 @@ ContactsManager::LinkState ContactsManager::get_link_state(tl_object_ptr<telegra
|
||||
return LinkState::Unknown;
|
||||
case telegram_api::contactLinkNone::ID:
|
||||
return LinkState::None;
|
||||
case telegram_api::contactLinkHasPhone::ID:
|
||||
return LinkState::KnowsPhoneNumber;
|
||||
case telegram_api::contactLinkContact::ID:
|
||||
return LinkState::Contact;
|
||||
default:
|
||||
|
@ -24305,6 +24305,12 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
||||
send_closure(G()->top_dialog_manager(), &TopDialogManager::on_dialog_used, TopDialogCategory::BotInline,
|
||||
DialogId(m->via_bot_user_id), m->date);
|
||||
}
|
||||
if (m->forward_info != nullptr && d->last_outgoing_forwarded_message_date < m->date) {
|
||||
TopDialogCategory category =
|
||||
dialog_id.get_type() == DialogType::User ? TopDialogCategory::ForwardUsers : TopDialogCategory::ForwardChats;
|
||||
send_closure(G()->top_dialog_manager(), &TopDialogManager::on_dialog_used, category, dialog_id, m->date);
|
||||
d->last_outgoing_forwarded_message_date = m->date;
|
||||
}
|
||||
|
||||
TopDialogCategory category = TopDialogCategory::Size;
|
||||
switch (dialog_id.get_type()) {
|
||||
|
@ -1011,6 +1011,7 @@ class MessagesManager : public Actor {
|
||||
int32 pending_last_message_date = 0;
|
||||
MessageId pending_last_message_id;
|
||||
MessageId max_notification_message_id;
|
||||
int32 last_outgoing_forwarded_message_date = 0;
|
||||
|
||||
MessageId max_added_message_id;
|
||||
MessageId being_added_message_id;
|
||||
|
@ -48,6 +48,9 @@ PrivacyManager::UserPrivacySetting::UserPrivacySetting(const telegram_api::Priva
|
||||
case telegram_api::privacyKeyProfilePhoto::ID:
|
||||
type_ = Type::UserProfilePhoto;
|
||||
break;
|
||||
case telegram_api::privacyKeyPhoneNumber::ID:
|
||||
type_ = Type::UserPhoneNumber;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
type_ = Type::UserStatus;
|
||||
@ -68,6 +71,8 @@ tl_object_ptr<td_api::UserPrivacySetting> PrivacyManager::UserPrivacySetting::as
|
||||
return make_tl_object<td_api::userPrivacySettingShowLinkInForwardedMessages>();
|
||||
case Type::UserProfilePhoto:
|
||||
return make_tl_object<td_api::userPrivacySettingShowProfilePhoto>();
|
||||
case Type::UserPhoneNumber:
|
||||
return make_tl_object<td_api::userPrivacySettingShowPhoneNumber>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
@ -87,6 +92,8 @@ tl_object_ptr<telegram_api::InputPrivacyKey> PrivacyManager::UserPrivacySetting:
|
||||
return make_tl_object<telegram_api::inputPrivacyKeyForwards>();
|
||||
case Type::UserProfilePhoto:
|
||||
return make_tl_object<telegram_api::inputPrivacyKeyProfilePhoto>();
|
||||
case Type::UserPhoneNumber:
|
||||
return make_tl_object<telegram_api::inputPrivacyKeyPhoneNumber>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
@ -113,6 +120,9 @@ PrivacyManager::UserPrivacySetting::UserPrivacySetting(const td_api::UserPrivacy
|
||||
case td_api::userPrivacySettingShowProfilePhoto::ID:
|
||||
type_ = Type::UserProfilePhoto;
|
||||
break;
|
||||
case td_api::userPrivacySettingShowPhoneNumber::ID:
|
||||
type_ = Type::UserPhoneNumber;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
type_ = Type::UserStatus;
|
||||
@ -244,6 +254,7 @@ vector<int32> PrivacyManager::UserPrivacySettingRule::user_ids_as_td_api() const
|
||||
Result<PrivacyManager::UserPrivacySettingRules> PrivacyManager::UserPrivacySettingRules::from_telegram_api(
|
||||
tl_object_ptr<telegram_api::account_privacyRules> rules) {
|
||||
G()->td().get_actor_unsafe()->contacts_manager_->on_get_users(std::move(rules->users_), "on get privacy rules");
|
||||
G()->td().get_actor_unsafe()->contacts_manager_->on_get_chats(std::move(rules->chats_), "on get privacy rules");
|
||||
return from_telegram_api(std::move(rules->rules_));
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ class PrivacyManager : public NetQueryCallback {
|
||||
PeerToPeerCall,
|
||||
LinkInForwardedMessages,
|
||||
UserProfilePhoto,
|
||||
UserPhoneNumber,
|
||||
Size
|
||||
};
|
||||
|
||||
|
@ -5448,7 +5448,8 @@ void Td::on_request(uint64 id, td_api::getTopChats &request) {
|
||||
}
|
||||
});
|
||||
send_closure(top_dialog_manager_, &TopDialogManager::get_top_dialogs,
|
||||
top_dialog_category_from_td_api(*request.category_), request.limit_, std::move(query_promise));
|
||||
top_dialog_category_from_td_api(*request.category_), narrow_cast<size_t>(request.limit_),
|
||||
std::move(query_promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::removeTopChat &request) {
|
||||
@ -5457,10 +5458,14 @@ void Td::on_request(uint64 id, const td_api::removeTopChat &request) {
|
||||
return send_error_raw(id, 400, "Top chat category should not be empty");
|
||||
}
|
||||
|
||||
DialogId dialog_id(request.chat_id_);
|
||||
if (!dialog_id.is_valid()) {
|
||||
return send_error_raw(id, 400, "Invalid chat identifier");
|
||||
}
|
||||
send_closure(top_dialog_manager_, &TopDialogManager::remove_dialog,
|
||||
top_dialog_category_from_td_api(*request.category_), DialogId(request.chat_id_),
|
||||
messages_manager_->get_input_peer(DialogId(request.chat_id_), AccessRights::Read));
|
||||
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
||||
top_dialog_category_from_td_api(*request.category_), dialog_id,
|
||||
messages_manager_->get_input_peer(dialog_id, AccessRights::Read));
|
||||
send_closure(actor_id(this), &Td::send_result, id, td_api::make_object<td_api::ok>());
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getChats &request) {
|
||||
|
@ -50,6 +50,10 @@ static CSlice top_dialog_category_name(TopDialogCategory category) {
|
||||
return CSlice("channel");
|
||||
case TopDialogCategory::Call:
|
||||
return CSlice("call");
|
||||
case TopDialogCategory::ForwardUsers:
|
||||
return CSlice("forward_users");
|
||||
case TopDialogCategory::ForwardChats:
|
||||
return CSlice("forward_chats");
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -69,6 +73,10 @@ static TopDialogCategory top_dialog_category_from_telegram_api(const telegram_ap
|
||||
return TopDialogCategory::Channel;
|
||||
case telegram_api::topPeerCategoryPhoneCalls::ID:
|
||||
return TopDialogCategory::Call;
|
||||
case telegram_api::topPeerCategoryForwardUsers::ID:
|
||||
return TopDialogCategory::ForwardUsers;
|
||||
case telegram_api::topPeerCategoryForwardChats::ID:
|
||||
return TopDialogCategory::ForwardChats;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -88,6 +96,10 @@ static tl_object_ptr<telegram_api::TopPeerCategory> top_dialog_category_as_teleg
|
||||
return make_tl_object<telegram_api::topPeerCategoryChannels>();
|
||||
case TopDialogCategory::Call:
|
||||
return make_tl_object<telegram_api::topPeerCategoryPhoneCalls>();
|
||||
case TopDialogCategory::ForwardUsers:
|
||||
return make_tl_object<telegram_api::topPeerCategoryForwardUsers>();
|
||||
case TopDialogCategory::ForwardChats:
|
||||
return make_tl_object<telegram_api::topPeerCategoryForwardChats>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -174,6 +186,11 @@ void TopDialogManager::remove_dialog(TopDialogCategory category, DialogId dialog
|
||||
if (!is_active_ || !is_enabled_) {
|
||||
return;
|
||||
}
|
||||
CHECK(dialog_id.is_valid());
|
||||
|
||||
if (category == TopDialogCategory::ForwardUsers && dialog_id.get_type() != DialogType::User) {
|
||||
category = TopDialogCategory::ForwardChats;
|
||||
}
|
||||
|
||||
auto pos = static_cast<size_t>(category);
|
||||
CHECK(pos < by_category_.size());
|
||||
@ -276,13 +293,28 @@ void TopDialogManager::normalize_rating() {
|
||||
}
|
||||
|
||||
void TopDialogManager::do_get_top_dialogs(GetTopDialogsQuery &&query) {
|
||||
auto pos = static_cast<size_t>(query.category);
|
||||
CHECK(pos < by_category_.size());
|
||||
auto &top_dialogs = by_category_[pos];
|
||||
vector<DialogId> dialog_ids;
|
||||
if (query.category != TopDialogCategory::ForwardUsers) {
|
||||
auto pos = static_cast<size_t>(query.category);
|
||||
CHECK(pos < by_category_.size());
|
||||
dialog_ids = transform(by_category_[pos].dialogs, [](const auto &x) { return x.dialog_id; });
|
||||
} else {
|
||||
// merge ForwardUsers and ForwardChats
|
||||
auto &users = by_category_[static_cast<size_t>(TopDialogCategory::ForwardUsers)];
|
||||
auto &chats = by_category_[static_cast<size_t>(TopDialogCategory::ForwardChats)];
|
||||
size_t users_pos = 0;
|
||||
size_t chats_pos = 0;
|
||||
while (users_pos < users.dialogs.size() || chats_pos < chats.dialogs.size()) {
|
||||
if (chats_pos == chats.dialogs.size() ||
|
||||
(users_pos < users.dialogs.size() && users.dialogs[users_pos] < chats.dialogs[chats_pos])) {
|
||||
dialog_ids.push_back(users.dialogs[users_pos++].dialog_id);
|
||||
} else {
|
||||
dialog_ids.push_back(chats.dialogs[chats_pos++].dialog_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto limit = std::min({query.limit, MAX_TOP_DIALOGS_LIMIT, top_dialogs.dialogs.size()});
|
||||
|
||||
vector<DialogId> dialog_ids = transform(top_dialogs.dialogs, [](const auto &x) { return x.dialog_id; });
|
||||
auto limit = std::min({query.limit, MAX_TOP_DIALOGS_LIMIT, dialog_ids.size()});
|
||||
|
||||
auto promise = PromiseCreator::lambda([query = std::move(query), dialog_ids, limit](Result<Unit>) mutable {
|
||||
vector<DialogId> result;
|
||||
@ -351,11 +383,21 @@ void TopDialogManager::do_get_top_peers() {
|
||||
|
||||
int32 flags = contacts_getTopPeers::CORRESPONDENTS_MASK | contacts_getTopPeers::BOTS_PM_MASK |
|
||||
contacts_getTopPeers::BOTS_INLINE_MASK | contacts_getTopPeers::GROUPS_MASK |
|
||||
contacts_getTopPeers::CHANNELS_MASK | contacts_getTopPeers::PHONE_CALLS_MASK;
|
||||
contacts_getTopPeers::CHANNELS_MASK | contacts_getTopPeers::PHONE_CALLS_MASK |
|
||||
contacts_getTopPeers::FORWARD_USERS_MASK | contacts_getTopPeers::FORWARD_CHATS_MASK;
|
||||
|
||||
contacts_getTopPeers query{
|
||||
flags, true /*correspondents*/, true /*bot_pm*/, true /*bot_inline */, true /*phone_calls*/,
|
||||
true /*groups*/, true /*channels*/, 0 /*offset*/, 100 /*limit*/, hash};
|
||||
contacts_getTopPeers query{flags,
|
||||
true /*correspondents*/,
|
||||
true /*bot_pm*/,
|
||||
true /*bot_inline */,
|
||||
true /*phone_calls*/,
|
||||
true /*groups*/,
|
||||
true /*channels*/,
|
||||
true /*forward_users*/,
|
||||
true /*forward_chats*/,
|
||||
0 /*offset*/,
|
||||
100 /*limit*/,
|
||||
hash};
|
||||
auto net_query = G()->net_query_creator().create(create_storer(query));
|
||||
G()->net_query_dispatcher().dispatch_with_callback(std::move(net_query), actor_shared(this));
|
||||
}
|
||||
|
@ -23,7 +23,17 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
enum class TopDialogCategory : int32 { Correspondent, BotPM, BotInline, Group, Channel, Call, Size };
|
||||
enum class TopDialogCategory : int32 {
|
||||
Correspondent,
|
||||
BotPM,
|
||||
BotInline,
|
||||
Group,
|
||||
Channel,
|
||||
Call,
|
||||
ForwardUsers,
|
||||
ForwardChats,
|
||||
Size
|
||||
};
|
||||
|
||||
inline TopDialogCategory top_dialog_category_from_td_api(const td_api::TopChatCategory &category) {
|
||||
switch (category.get_id()) {
|
||||
@ -39,6 +49,8 @@ inline TopDialogCategory top_dialog_category_from_td_api(const td_api::TopChatCa
|
||||
return TopDialogCategory::Channel;
|
||||
case td_api::topChatCategoryCalls::ID:
|
||||
return TopDialogCategory::Call;
|
||||
case td_api::topChatCategoryForwardChats::ID:
|
||||
return TopDialogCategory::ForwardUsers;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
Reference in New Issue
Block a user