Update layer to 76: add messageWebsiteConnected.

GitOrigin-RevId: 8cb5128a7d7eac2afe0622fc901392bf318fa460
This commit is contained in:
levlam 2018-02-22 03:36:40 +03:00
parent f4afe7f63e
commit d1f1a14a37
21 changed files with 190 additions and 72 deletions

View File

@ -68,7 +68,7 @@ rsa_public_key n:string e:string = RSAPublicKey;
---functions---
req_pq#60469778 nonce:int128 = ResPQ;
req_pq_multi#be7e8ef1 nonce:int128 = ResPQ;
req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:string q:string public_key_fingerprint:long encrypted_data:string = Server_DH_Params;

Binary file not shown.

View File

@ -93,6 +93,8 @@ messageEntityCode#28a20571 offset:int length:int = MessageEntity;
messageEntityPre#73924be0 offset:int length:int language:string = MessageEntity;
messageEntityTextUrl#76a6d327 offset:int length:int url:string = MessageEntity;
messageEntityMentionName#352dca58 offset:int length:int user_id:int = MessageEntity;
messageEntityPhone#9b69e34b offset:int length:int = MessageEntity;
messageEntityCashtag#4c4e743f offset:int length:int = MessageEntity;
inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet;
inputStickerSetEmpty#ffb62b95 = InputStickerSet;
decryptedMessageMediaVenue#8a0df56f lat:double long:double title:string address:string provider:string venue_id:string = DecryptedMessageMedia;

Binary file not shown.

View File

@ -907,6 +907,9 @@ messagePaymentSuccessfulBot invoice_message_id:int53 currency:string total_amoun
//@description A contact has registered with Telegram
messageContactRegistered = MessageContent;
//@description The current user has connected a website by logging in using Telegram Login Widget on it @domain_name Domain name of the connected website
messageWebsiteConnected domain_name:string = MessageContent;
//@description Message content that is not supported by the client
messageUnsupported = MessageContent;

Binary file not shown.

View File

@ -155,6 +155,7 @@ messageActionPaymentSent#40699cd0 currency:string total_amount:long = MessageAct
messageActionPhoneCall#80e11a7f flags:# call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction;
messageActionScreenshotTaken#4792929b = MessageAction;
messageActionCustomAction#fae69f56 message:string = MessageAction;
messageActionBotAllowed#abe9affe domain:string = MessageAction;
dialog#e4def5db flags:# pinned:flags.2?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage = Dialog;
@ -307,8 +308,8 @@ updateRecentStickers#9a422c20 = Update;
updateConfig#a229dd06 = Update;
updatePtsChanged#3354678f = Update;
updateChannelWebPage#40771900 channel_id:int webpage:WebPage pts:int pts_count:int = Update;
updateDialogPinned#d711a2cc flags:# pinned:flags.0?true peer:Peer = Update;
updatePinnedDialogs#d8caf68d flags:# order:flags.0?Vector<Peer> = Update;
updateDialogPinned#19d27f3c flags:# pinned:flags.0?true peer:DialogPeer = Update;
updatePinnedDialogs#ea4cb65b flags:# order:flags.0?Vector<DialogPeer> = Update;
updateBotWebhookJSON#8317c0c3 data:DataJSON = Update;
updateBotWebhookJSONQuery#9b9240a6 query_id:long data:DataJSON timeout:int = Update;
updateBotShippingQuery#e0cdc940 query_id:long user_id:int payload:bytes shipping_address:PostAddress = Update;
@ -346,7 +347,7 @@ upload.fileCdnRedirect#ea52fe5a dc_id:int file_token:bytes encryption_key:bytes
dcOption#5d8c6cc flags:# ipv6:flags.0?true media_only:flags.1?true tcpo_only:flags.2?true cdn:flags.3?true static:flags.4?true id:int ip_address:string port:int = DcOption;
config#9c840964 flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector<DcOption> chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int chat_big_size:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string suggested_lang_code:flags.2?string lang_pack_version:flags.2?int disabled_features:Vector<DisabledFeature> = Config;
config#e644ec1f flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true ignore_phone_entities:flags.5?true revoke_pm_inbox:flags.6?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector<DcOption> chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int chat_big_size:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string suggested_lang_code:flags.2?string lang_pack_version:flags.2?int = Config;
nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc;
@ -490,7 +491,7 @@ inputStickerSetEmpty#ffb62b95 = InputStickerSet;
inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet;
inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet;
stickerSet#cd303b41 flags:# installed:flags.0?true archived:flags.1?true official:flags.2?true masks:flags.3?true id:long access_hash:long title:string short_name:string count:int hash:int = StickerSet;
stickerSet#5585a139 flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string count:int hash:int = StickerSet;
messages.stickerSet#b60a24a6 set:StickerSet packs:Vector<StickerPack> documents:Vector<Document> = messages.StickerSet;
@ -527,6 +528,8 @@ messageEntityPre#73924be0 offset:int length:int language:string = MessageEntity;
messageEntityTextUrl#76a6d327 offset:int length:int url:string = MessageEntity;
messageEntityMentionName#352dca58 offset:int length:int user_id:int = MessageEntity;
inputMessageEntityMentionName#208e68c9 offset:int length:int user_id:InputUser = MessageEntity;
messageEntityPhone#9b69e34b offset:int length:int = MessageEntity;
messageEntityCashtag#4c4e743f offset:int length:int = MessageEntity;
inputChannelEmpty#ee8c1e86 = InputChannel;
inputChannel#afeb712e channel_id:int access_hash:long = InputChannel;
@ -637,7 +640,7 @@ messages.featuredStickersNotModified#4ede3cf = messages.FeaturedStickers;
messages.featuredStickers#f89d88e5 hash:int sets:Vector<StickerSetCovered> unread:Vector<long> = messages.FeaturedStickers;
messages.recentStickersNotModified#b17f890 = messages.RecentStickers;
messages.recentStickers#5ce20970 hash:int stickers:Vector<Document> = messages.RecentStickers;
messages.recentStickers#22f3afb3 hash:int packs:Vector<StickerPack> stickers:Vector<Document> dates:Vector<int> = messages.RecentStickers;
messages.archivedStickers#4fcba9c8 count:int sets:Vector<StickerSetCovered> = messages.ArchivedStickers;
@ -830,6 +833,13 @@ inputMessageID#a676a322 id:int = InputMessage;
inputMessageReplyTo#bad88395 id:int = InputMessage;
inputMessagePinned#86872538 = InputMessage;
inputDialogPeer#fcaafeb7 peer:InputPeer = InputDialogPeer;
dialogPeer#e56dbf05 peer:Peer = DialogPeer;
messages.foundStickerSetsNotModified#d54b65d = messages.FoundStickerSets;
messages.foundStickerSets#b35bcea9 hash:int sets:Vector<StickerSet> = messages.FoundStickerSets;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -909,7 +919,7 @@ contacts.resetSaved#879537f1 = Bool;
messages.getMessages#63c66506 id:Vector<InputMessage> = messages.Messages;
messages.getDialogs#191ba9c5 flags:# exclude_pinned:flags.0?true offset_date:int offset_id:int offset_peer:InputPeer limit:int = messages.Dialogs;
messages.getHistory#dcbb8260 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages;
messages.search#39e9ea0 flags:# peer:InputPeer q:string from_id:flags.0?InputUser filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages;
messages.search#8614ef68 flags:# peer:InputPeer q:string from_id:flags.0?InputUser filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages;
messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages;
messages.deleteHistory#1c015b09 flags:# just_clear:flags.0?true peer:InputPeer max_id:int = messages.AffectedHistory;
messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector<int> = messages.AffectedMessages;
@ -940,7 +950,7 @@ messages.sendEncryptedService#32d439a4 peer:InputEncryptedChat random_id:long da
messages.receivedQueue#55a5bb66 max_qts:int = Vector<long>;
messages.reportEncryptedSpam#4b0c8c0f peer:InputEncryptedChat = Bool;
messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages;
messages.getStickers#ae22e045 emoticon:string hash:string = messages.Stickers;
messages.getStickers#85cb5182 flags:# exclude_featured:flags.0?true emoticon:string hash:string = messages.Stickers;
messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers;
messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vector<MessageEntity> = MessageMedia;
messages.exportChatInvite#7d885289 chat_id:int = ExportedChatInvite;
@ -968,7 +978,7 @@ messages.editMessage#5d1b8dd flags:# no_webpage:flags.1?true stop_geo_live:flags
messages.editInlineBotMessage#b0e08243 flags:# no_webpage:flags.1?true stop_geo_live:flags.12?true id:InputBotInlineMessageID message:flags.11?string reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> geo_point:flags.13?InputGeoPoint = Bool;
messages.getBotCallbackAnswer#810a9fec flags:# game:flags.1?true peer:InputPeer msg_id:int data:flags.0?bytes = messages.BotCallbackAnswer;
messages.setBotCallbackAnswer#d58f130a flags:# alert:flags.1?true query_id:long message:flags.0?string url:flags.2?string cache_time:int = Bool;
messages.getPeerDialogs#2d9776b9 peers:Vector<InputPeer> = messages.PeerDialogs;
messages.getPeerDialogs#e470bcfd peers:Vector<InputDialogPeer> = messages.PeerDialogs;
messages.saveDraft#bc39e14b flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int peer:InputPeer message:string entities:flags.3?Vector<MessageEntity> = Bool;
messages.getAllDrafts#6a3f8d65 = Updates;
messages.getFeaturedStickers#2dacca4f hash:int = messages.FeaturedStickers;
@ -986,8 +996,8 @@ messages.getInlineGameHighScores#f635e1b id:InputBotInlineMessageID user_id:Inpu
messages.getCommonChats#d0a48c4 user_id:InputUser max_id:int limit:int = messages.Chats;
messages.getAllChats#eba80ff0 except_ids:Vector<int> = messages.Chats;
messages.getWebPage#32ca8f91 url:string hash:int = WebPage;
messages.toggleDialogPin#3289be6a flags:# pinned:flags.0?true peer:InputPeer = Bool;
messages.reorderPinnedDialogs#959ff644 flags:# force:flags.0?true order:Vector<InputPeer> = Bool;
messages.toggleDialogPin#a731e257 flags:# pinned:flags.0?true peer:InputDialogPeer = Bool;
messages.reorderPinnedDialogs#5b51d63f flags:# force:flags.0?true order:Vector<InputDialogPeer> = Bool;
messages.getPinnedDialogs#e254d64e = messages.PeerDialogs;
messages.setBotShippingResults#e5f672fa flags:# query_id:long error:flags.0?string shipping_options:flags.1?Vector<ShippingOption> = Bool;
messages.setBotPrecheckoutResults#9c2dd95 flags:# success:flags.1?true query_id:long error:flags.0?string = Bool;
@ -997,9 +1007,10 @@ messages.getFavedStickers#21ce0b0e hash:int = messages.FavedStickers;
messages.faveSticker#b9ffc55b id:InputDocument unfave:Bool = Bool;
messages.getUnreadMentions#46578472 peer:InputPeer offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages;
messages.readMentions#f0189d3 peer:InputPeer = messages.AffectedHistory;
messages.getRecentLocations#249431e2 peer:InputPeer limit:int = messages.Messages;
messages.getRecentLocations#bbc45b09 peer:InputPeer limit:int hash:int = messages.Messages;
messages.sendMultiMedia#2095512f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int multi_media:Vector<InputSingleMedia> = Updates;
messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile;
messages.searchStickerSets#c2b7d08b flags:# exclude_featured:flags.0?true q:string hash:int = messages.FoundStickerSets;
updates.getState#edd4882a = updates.State;
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;

Binary file not shown.

View File

@ -56,7 +56,7 @@ Result<size_t> AuthKeyHandshake::fill_data_with_hash(uint8 *data_with_hash, cons
}
Status AuthKeyHandshake::on_res_pq(Slice message, Callback *connection, PublicRsaKeyInterface *public_rsa_key) {
TRY_RESULT(res_pq, fetch_result<mtproto_api::req_pq>(message));
TRY_RESULT(res_pq, fetch_result<mtproto_api::req_pq_multi>(message));
if (res_pq->nonce_ != nonce) {
return Status::Error("Nonce mismatch");
}
@ -272,7 +272,7 @@ Status AuthKeyHandshake::on_start(Callback *connection) {
return Status::Error(PSLICE() << "on_start called after start " << tag("state", state_));
}
Random::secure_bytes(nonce.raw, sizeof(nonce));
send(connection, create_storer(mtproto_api::req_pq(nonce)));
send(connection, create_storer(mtproto_api::req_pq_multi(nonce)));
state_ = ResPQ;
return Status::OK();

View File

@ -41,7 +41,7 @@ class PingConnection : private RawConnection::Callback {
if (!was_ping_) {
UInt128 nonce;
Random::secure_bytes(nonce.raw, sizeof(nonce));
raw_connection_->send_no_crypto(PacketStorer<NoCryptoImpl>(1, create_storer(mtproto_api::req_pq(nonce))));
raw_connection_->send_no_crypto(PacketStorer<NoCryptoImpl>(1, create_storer(mtproto_api::req_pq_multi(nonce))));
was_ping_ = true;
}
return raw_connection_->flush(AuthKey(), *this);

View File

@ -706,6 +706,12 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
shared_config.set_option_empty("notify_cloud_delay_ms");
shared_config.set_option_empty("notify_default_delay_ms");
if (is_from_main_dc) {
for (auto &feature : shared_config.get_options("disabled_")) {
shared_config.set_option_empty(feature.first);
}
}
// TODO implement online status updates
// shared_config.set_option_integer("online_update_period_ms", config->online_update_period_ms_);
// shared_config.set_option_integer("offline_blur_timeout_ms", config->offline_blur_timeout_ms_);
@ -716,19 +722,6 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
// shared_config.set_option_integer("push_chat_period_ms", config->push_chat_period_ms_);
// shared_config.set_option_integer("push_chat_limit", config->push_chat_limit_);
if (is_from_main_dc) {
auto old_disabled_features = shared_config.get_options("disabled_");
for (auto &feature : config->disabled_features_) {
string option_name = "disabled_" + feature->feature_;
shared_config.set_option_string(option_name, feature->description_);
old_disabled_features.erase(option_name);
}
for (auto &feature : old_disabled_features) {
shared_config.set_option_empty(feature.first);
}
}
}
} // namespace td

View File

@ -7433,7 +7433,7 @@ void ContactsManager::on_update_chat_active(Chat *c, ChatId chat_id, bool is_act
}
}
void ContactsManager::on_update_chat_migrated_to(Chat *c, ChatId chat_id, ChannelId migrated_to_channel_id) {
void ContactsManager::on_update_chat_migrated_to_channel_id(Chat *c, ChatId chat_id, ChannelId migrated_to_channel_id) {
if (c->migrated_to_channel_id != migrated_to_channel_id && migrated_to_channel_id.is_valid()) {
LOG_IF(ERROR, c->migrated_to_channel_id.is_valid())
<< "Group upgraded to supergroup has changed from " << c->migrated_to_channel_id << " to "
@ -8757,7 +8757,7 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat) {
bool is_active = 0 == (chat.flags_ & CHAT_FLAG_IS_DEACTIVATED);
ChannelId migrated_to;
ChannelId migrated_to_channel_id;
if (chat.flags_ & CHAT_FLAG_WAS_MIGRATED) {
switch (chat.migrated_to_->get_id()) {
case telegram_api::inputChannelEmpty::ID: {
@ -8766,20 +8766,20 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat) {
}
case telegram_api::inputChannel::ID: {
auto input_channel = move_tl_object_as<telegram_api::inputChannel>(chat.migrated_to_);
migrated_to = ChannelId(input_channel->channel_id_);
if (!have_channel(migrated_to)) {
if (!migrated_to.is_valid()) {
LOG(ERROR) << "Receive invalid " << migrated_to << " in " << debug_str;
migrated_to_channel_id = ChannelId(input_channel->channel_id_);
if (!have_channel(migrated_to_channel_id)) {
if (!migrated_to_channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << migrated_to_channel_id << " in " << debug_str;
} else {
// temporarily create the channel
Channel *c = add_channel(migrated_to);
Channel *c = add_channel(migrated_to_channel_id);
c->access_hash = input_channel->access_hash_;
c->title = chat.title_;
c->status = DialogParticipantStatus::Left();
c->is_megagroup = true;
// we definitely need to call update_channel, because client should know about every added channel
update_channel(c, channel_id);
update_channel(c, migrated_to_channel_id);
// get info about the channel
td_->create_handler<GetChannelsQuery>(Promise<>())->send(std::move(input_channel));
@ -8807,8 +8807,8 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat) {
on_update_chat_rights(c, chat_id, is_creator, is_administrator, everyone_is_administrator);
on_update_chat_photo(c, chat_id, std::move(chat.photo_));
on_update_chat_active(c, chat_id, is_active);
on_update_chat_migrated_to(c, chat_id, migrated_to);
LOG_IF(ERROR, !is_active && !migrated_to.is_valid()) << chat_id << " is deactivated in " << debug_str;
on_update_chat_migrated_to_channel_id(c, chat_id, migrated_to_channel_id);
LOG_IF(ERROR, !is_active && !migrated_to_channel_id.is_valid()) << chat_id << " is deactivated in " << debug_str;
update_chat(c, chat_id);
}
@ -8833,7 +8833,7 @@ void ContactsManager::on_chat_update(telegram_api::chatForbidden &chat) {
on_update_chat_left(c, chat_id, true, true);
if (is_uninited) {
on_update_chat_active(c, chat_id, true);
on_update_chat_migrated_to(c, chat_id, ChannelId());
on_update_chat_migrated_to_channel_id(c, chat_id, ChannelId());
} else {
// leave active and migrated to as is
}

View File

@ -818,7 +818,7 @@ class ContactsManager : public Actor {
bool everyone_is_administrator);
void on_update_chat_title(Chat *c, ChatId chat_id, string &&title);
void on_update_chat_active(Chat *c, ChatId chat_id, bool is_active);
void on_update_chat_migrated_to(Chat *c, ChatId chat_id, ChannelId migrated_to_channel_id);
void on_update_chat_migrated_to_channel_id(Chat *c, ChatId chat_id, ChannelId migrated_to_channel_id);
bool on_update_chat_full_participants_short(ChatFull *chat_full, ChatId chat_id, int32 version);
void on_update_chat_full_participants(ChatFull *chat_full, ChatId chat_id, vector<DialogParticipant> participants,

View File

@ -103,48 +103,51 @@ DialogId::DialogId(SecretChatId chat_id) {
}
}
DialogId::DialogId(const tl_object_ptr<telegram_api::Peer> &peer) {
DialogId::DialogId(const tl_object_ptr<telegram_api::dialogPeer> &dialog_peer) {
id = get_peer_id(dialog_peer->peer_);
}
DialogId::DialogId(const tl_object_ptr<telegram_api::Peer> &peer) : id(get_peer_id(peer)) {
}
int64 DialogId::get_peer_id(const tl_object_ptr<telegram_api::Peer> &peer) {
CHECK(peer != nullptr);
int constructor_id = peer->get_id();
switch (constructor_id) {
switch (peer->get_id()) {
case telegram_api::peerUser::ID: {
auto peer_user = static_cast<const telegram_api::peerUser *>(peer.get());
UserId user_id(peer_user->user_id_);
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << user_id;
id = 0;
} else {
id = static_cast<int64>(user_id.get());
return 0;
}
return;
return static_cast<int64>(user_id.get());
}
case telegram_api::peerChat::ID: {
auto peer_chat = static_cast<const telegram_api::peerChat *>(peer.get());
ChatId chat_id(peer_chat->chat_id_);
if (!chat_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << chat_id;
id = 0;
} else {
id = -static_cast<int64>(chat_id.get());
return 0;
}
return;
return -static_cast<int64>(chat_id.get());
}
case telegram_api::peerChannel::ID: {
auto peer_channel = static_cast<const telegram_api::peerChannel *>(peer.get());
ChannelId channel_id(peer_channel->channel_id_);
if (!channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id;
id = 0;
} else {
id = MAX_CHANNEL_ID - static_cast<int64>(channel_id.get());
return 0;
}
return;
return MAX_CHANNEL_ID - static_cast<int64>(channel_id.get());
}
default:
UNREACHABLE();
return 0;
}
id = 0;
}
} // namespace td

View File

@ -34,6 +34,8 @@ class DialogId {
int64 id = 0;
static int64 get_peer_id(const tl_object_ptr<telegram_api::Peer> &peer);
public:
using UnderlyingType = decltype(id);
DialogId() = default;
@ -43,6 +45,7 @@ class DialogId {
template <class T, typename = std::enable_if_t<std::is_convertible<T, int64>::value>>
DialogId(T dialog_id) = delete;
explicit DialogId(const tl_object_ptr<telegram_api::dialogPeer> &dialog_peer);
explicit DialogId(const tl_object_ptr<telegram_api::Peer> &peer);
explicit DialogId(UserId user_id);
explicit DialogId(ChatId chat_id);

View File

@ -987,17 +987,15 @@ vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool onl
entities.emplace_back(MessageEntity::Type::Mention, narrow_cast<int32>(mention.begin() - text.begin()),
narrow_cast<int32>(mention.size()));
}
}
if (!skip_bot_commands && !only_urls) {
auto bot_commands = find_bot_commands(text);
for (auto &bot_command : bot_commands) {
entities.emplace_back(MessageEntity::Type::BotCommand, narrow_cast<int32>(bot_command.begin() - text.begin()),
narrow_cast<int32>(bot_command.size()));
if (!skip_bot_commands) {
auto bot_commands = find_bot_commands(text);
for (auto &bot_command : bot_commands) {
entities.emplace_back(MessageEntity::Type::BotCommand, narrow_cast<int32>(bot_command.begin() - text.begin()),
narrow_cast<int32>(bot_command.size()));
}
}
}
if (!only_urls) {
auto hashtags = find_hashtags(text);
for (auto &hashtag : hashtags) {
entities.emplace_back(MessageEntity::Type::Hashtag, narrow_cast<int32>(hashtag.begin() - text.begin()),
@ -1704,6 +1702,12 @@ vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manag
entities.emplace_back(MessageEntity::Type::Hashtag, entity_hashtag->offset_, entity_hashtag->length_);
break;
}
case telegram_api::messageEntityCashtag::ID:
// skip for now
break;
case telegram_api::messageEntityPhone::ID:
// skip for now
break;
case telegram_api::messageEntityBotCommand::ID: {
auto entity_bot_command = static_cast<const telegram_api::messageEntityBotCommand *>(entity.get());
entities.emplace_back(MessageEntity::Type::BotCommand, entity_bot_command->offset_,
@ -1796,6 +1800,12 @@ vector<MessageEntity> get_message_entities(vector<tl_object_ptr<secret_api::Mess
case secret_api::messageEntityHashtag::ID:
// skip, will find it ourselves
break;
case secret_api::messageEntityCashtag::ID:
// skip, will find it ourselves
break;
case secret_api::messageEntityPhone::ID:
// skip, will find it ourselves
break;
case secret_api::messageEntityBotCommand::ID:
// skip all bot commands in secret chats
break;

View File

@ -139,7 +139,7 @@ class GetDialogQuery : public Td::ResultHandler {
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getPeerDialogs(
td->messages_manager_->get_input_peers({dialog_id}, AccessRights::Read)))));
td->messages_manager_->get_input_dialog_peers({dialog_id}, AccessRights::Read)))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -219,7 +219,7 @@ class GetDialogsQuery : public Td::ResultHandler {
void send(vector<DialogId> &&dialog_ids) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getPeerDialogs(
td->messages_manager_->get_input_peers(dialog_ids, AccessRights::Read)))));
td->messages_manager_->get_input_dialog_peers(dialog_ids, AccessRights::Read)))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -891,7 +891,7 @@ class ToggleDialogPinQuery : public Td::ResultHandler {
void send(DialogId dialog_id, bool is_pinned) {
dialog_id_ = dialog_id;
is_pinned_ = is_pinned;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td->messages_manager_->get_input_dialog_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return;
}
@ -937,7 +937,7 @@ class ReorderPinnedDialogsQuery : public Td::ResultHandler {
void send(const vector<DialogId> &dialog_ids) {
int32 flags = telegram_api::messages_reorderPinnedDialogs::FORCE_MASK;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_reorderPinnedDialogs(
flags, true /*ignored*/, td->messages_manager_->get_input_peers(dialog_ids, AccessRights::Read)))));
flags, true /*ignored*/, td->messages_manager_->get_input_dialog_peers(dialog_ids, AccessRights::Read)))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1389,7 +1389,7 @@ class SearchMessagesQuery : public Td::ResultHandler {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_search(
flags, std::move(input_peer), query, std::move(sender_input_user),
MessagesManager::get_input_messages_filter(filter), 0, std::numeric_limits<int32>::max(),
from_message_id.get_server_message_id().get(), offset, limit, std::numeric_limits<int32>::max(), 0))));
from_message_id.get_server_message_id().get(), offset, limit, std::numeric_limits<int32>::max(), 0, 0))));
}
}
@ -1556,7 +1556,7 @@ class GetRecentLocationsQuery : public Td::ResultHandler {
random_id_ = random_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getRecentLocations(std::move(input_peer), limit))));
create_storer(telegram_api::messages_getRecentLocations(std::move(input_peer), limit, 0))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3569,6 +3569,11 @@ static void store(const MessageContent *content, StorerT &storer) {
store(m->message, storer);
break;
}
case MessageWebsiteConnected::ID: {
auto m = static_cast<const MessageWebsiteConnected *>(content);
store(m->domain_name, storer);
break;
}
default:
UNREACHABLE();
}
@ -3869,6 +3874,12 @@ static void parse(unique_ptr<MessageContent> &content, ParserT &parser) {
content = std::move(m);
break;
}
case MessageWebsiteConnected::ID: {
auto m = make_unique<MessageWebsiteConnected>();
parse(m->domain_name, parser);
content = std::move(m);
break;
}
default:
UNREACHABLE();
}
@ -4724,6 +4735,7 @@ int32 MessagesManager::get_message_content_index_mask(const MessageContent *cont
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
return 0;
default:
UNREACHABLE();
@ -4789,6 +4801,37 @@ vector<tl_object_ptr<telegram_api::InputPeer>> MessagesManager::get_input_peers(
return input_peers;
}
tl_object_ptr<telegram_api::inputDialogPeer> MessagesManager::get_input_dialog_peer(DialogId dialog_id,
AccessRights access_rights) const {
switch (dialog_id.get_type()) {
case DialogType::User:
case DialogType::Chat:
case DialogType::Channel:
case DialogType::None:
return make_tl_object<telegram_api::inputDialogPeer>(get_input_peer(dialog_id, access_rights));
case DialogType::SecretChat:
return nullptr;
default:
UNREACHABLE();
return nullptr;
}
}
vector<tl_object_ptr<telegram_api::inputDialogPeer>> MessagesManager::get_input_dialog_peers(
const vector<DialogId> &dialog_ids, AccessRights access_rights) const {
vector<tl_object_ptr<telegram_api::inputDialogPeer>> input_dialog_peers;
input_dialog_peers.reserve(dialog_ids.size());
for (auto &dialog_id : dialog_ids) {
auto input_dialog_peer = get_input_dialog_peer(dialog_id, access_rights);
if (input_dialog_peer == nullptr) {
LOG(ERROR) << "Have no access to " << dialog_id;
continue;
}
input_dialog_peers.push_back(std::move(input_dialog_peer));
}
return input_dialog_peers;
}
bool MessagesManager::have_input_peer(DialogId dialog_id, AccessRights access_rights) const {
switch (dialog_id.get_type()) {
case DialogType::User: {
@ -6984,6 +7027,7 @@ bool MessagesManager::is_service_message_content(int32 content_type) {
case MessagePaymentSuccessful::ID:
case MessageContactRegistered::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
return true;
default:
UNREACHABLE();
@ -7053,6 +7097,7 @@ string MessagesManager::get_search_text(const Message *m) {
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
return "";
default:
UNREACHABLE();
@ -7100,6 +7145,7 @@ bool MessagesManager::is_allowed_media_group_content(int32 content_type) {
case MessagePaymentSuccessful::ID:
case MessageContactRegistered::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
return false;
default:
UNREACHABLE();
@ -8374,6 +8420,10 @@ tl_object_ptr<td_api::MessageContent> MessagesManager::get_message_content_objec
const MessageCustomServiceAction *m = static_cast<const MessageCustomServiceAction *>(content);
return make_tl_object<td_api::messageCustomServiceAction>(m->message);
}
case MessageWebsiteConnected::ID: {
const MessageWebsiteConnected *m = static_cast<const MessageWebsiteConnected *>(content);
return make_tl_object<td_api::messageWebsiteConnected>(m->domain_name);
}
default:
UNREACHABLE();
return nullptr;
@ -13955,6 +14005,7 @@ SecretInputMedia MessagesManager::get_secret_input_media(const MessageContent *c
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
break;
default:
UNREACHABLE();
@ -14125,6 +14176,7 @@ tl_object_ptr<telegram_api::InputMedia> MessagesManager::get_input_media(
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
break;
default:
UNREACHABLE();
@ -14192,6 +14244,7 @@ void MessagesManager::delete_message_content_thumbnail(MessageContent *content)
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
break;
default:
UNREACHABLE();
@ -14480,6 +14533,7 @@ Status MessagesManager::can_send_message_content(DialogId dialog_id, const Messa
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
UNREACHABLE();
}
return Status::OK();
@ -14872,6 +14926,8 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, Dialo
break;
case MessageCustomServiceAction::ID:
break;
case MessageWebsiteConnected::ID:
break;
default:
UNREACHABLE();
break;
@ -16352,6 +16408,7 @@ bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, boo
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
return false;
default:
UNREACHABLE();
@ -16548,6 +16605,7 @@ void MessagesManager::edit_message_caption(FullMessageId full_message_id,
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
return promise.set_error(Status::Error(400, "There is no caption in the message to edit"));
default:
UNREACHABLE();
@ -18038,6 +18096,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
LOG(ERROR) << "Receive new file " << new_file_id << " in a sent message of the type " << content_type;
break;
default:
@ -20544,6 +20603,7 @@ unique_ptr<MessageContent> MessagesManager::dup_message_content(DialogId dialog_
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
case MessageCustomServiceAction::ID:
case MessageWebsiteConnected::ID:
return nullptr;
default:
UNREACHABLE();
@ -20706,6 +20766,10 @@ unique_ptr<MessageContent> MessagesManager::get_message_action_content(
auto custom_action = move_tl_object_as<telegram_api::messageActionCustomAction>(action);
return make_unique<MessageCustomServiceAction>(std::move(custom_action->message_));
}
case telegram_api::messageActionBotAllowed::ID: {
auto bot_allowed = move_tl_object_as<telegram_api::messageActionBotAllowed>(action);
return make_unique<MessageWebsiteConnected>(std::move(bot_allowed->domain_));
}
default:
UNREACHABLE();
}
@ -22192,6 +22256,14 @@ bool MessagesManager::update_message_content(DialogId dialog_id, const Message *
}
break;
}
case MessageWebsiteConnected::ID: {
auto old_ = static_cast<const MessageWebsiteConnected *>(old_content.get());
auto new_ = static_cast<const MessageWebsiteConnected *>(new_content.get());
if (old_->domain_name != new_->domain_name) {
need_update = true;
}
break;
}
case MessageUnsupported::ID:
break;
default:

View File

@ -612,6 +612,20 @@ class MessageCustomServiceAction : public MessageContent {
}
};
class MessageWebsiteConnected : public MessageContent {
public:
string domain_name;
MessageWebsiteConnected() = default;
explicit MessageWebsiteConnected(string &&domain_name) : domain_name(std::move(domain_name)) {
}
static const int32 ID = 37;
int32 get_id() const override {
return ID;
}
};
class InputMessageText {
public:
FormattedText text;
@ -834,6 +848,12 @@ class MessagesManager : public Actor {
vector<tl_object_ptr<telegram_api::InputPeer>> get_input_peers(const vector<DialogId> &dialog_ids,
AccessRights access_rights) const;
tl_object_ptr<telegram_api::inputDialogPeer> get_input_dialog_peer(DialogId dialog_id,
AccessRights access_rights) const;
vector<tl_object_ptr<telegram_api::inputDialogPeer>> get_input_dialog_peers(const vector<DialogId> &dialog_ids,
AccessRights access_rights) const;
tl_object_ptr<telegram_api::inputEncryptedChat> get_input_encrypted_chat(DialogId dialog_id,
AccessRights access_rights) const;

View File

@ -1354,7 +1354,7 @@ int64 StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::stickerSet
int64 set_id = set->id_;
StickerSet *s = add_sticker_set(set_id, set->access_hash_);
bool is_installed = (set->flags_ & telegram_api::stickerSet::INSTALLED_MASK) != 0;
bool is_installed = (set->flags_ & telegram_api::stickerSet::INSTALLED_DATE_MASK) != 0;
bool is_archived = (set->flags_ & telegram_api::stickerSet::ARCHIVED_MASK) != 0;
bool is_official = (set->flags_ & telegram_api::stickerSet::OFFICIAL_MASK) != 0;
bool is_masks = (set->flags_ & telegram_api::stickerSet::MASKS_MASK) != 0;

View File

@ -478,6 +478,7 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_
case telegram_api::messageActionChatEditPhoto::ID:
case telegram_api::messageActionChatDeletePhoto::ID:
case telegram_api::messageActionCustomAction::ID:
case telegram_api::messageActionBotAllowed::ID:
case telegram_api::messageActionHistoryClear::ID:
case telegram_api::messageActionChannelCreate::ID:
case telegram_api::messageActionPinMessage::ID:

View File

@ -18,7 +18,7 @@ class HeaderStorer {
}
template <class StorerT>
void store(StorerT &storer) const {
constexpr int32 LAYER = 75;
constexpr int32 LAYER = 76;
using td::store;
// invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X;