Update layer to 97. Support new privacies.

GitOrigin-RevId: d78d9e44557cd1ed77fc83c25986764c4547fb35
This commit is contained in:
levlam 2019-05-14 03:18:34 +03:00
parent 784aaa13d4
commit 7cd835f4fa
10 changed files with 110 additions and 24 deletions

View File

@ -2195,6 +2195,12 @@ userPrivacySettingRules rules:vector<UserPrivacySettingRule> = UserPrivacySettin
//@description A privacy setting for managing whether the user's online status is visible
userPrivacySettingShowStatus = UserPrivacySetting;
//@description A privacy setting for managing whether the user's profile photo is visible
userPrivacySettingShowProfilePhoto = UserPrivacySetting;
//@description A privacy setting for managing whether the user account can be linked in forwarded messages
userPrivacySettingShowLinkInForwardedMessages = UserPrivacySetting;
//@description A privacy setting for managing whether the user can be invited to chats
userPrivacySettingAllowChatInvites = UserPrivacySetting;

Binary file not shown.

View File

@ -420,11 +420,15 @@ inputPrivacyKeyStatusTimestamp#4f96cb18 = InputPrivacyKey;
inputPrivacyKeyChatInvite#bdfb0426 = InputPrivacyKey;
inputPrivacyKeyPhoneCall#fabadc5f = InputPrivacyKey;
inputPrivacyKeyPhoneP2P#db9e70d2 = InputPrivacyKey;
inputPrivacyKeyForwards#a4dd4c08 = InputPrivacyKey;
inputPrivacyKeyProfilePhoto#5719bacc = InputPrivacyKey;
privacyKeyStatusTimestamp#bc2eab30 = PrivacyKey;
privacyKeyChatInvite#500e6dfa = PrivacyKey;
privacyKeyPhoneCall#3d662b7b = PrivacyKey;
privacyKeyPhoneP2P#39491cc8 = PrivacyKey;
privacyKeyForwards#69ec56a3 = PrivacyKey;
privacyKeyProfilePhoto#96151fed = PrivacyKey;
inputPrivacyValueAllowContacts#d09e07b = InputPrivacyRule;
inputPrivacyValueAllowAll#184b35ce = InputPrivacyRule;
@ -496,7 +500,7 @@ inputStickerSetEmpty#ffb62b95 = InputStickerSet;
inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet;
inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet;
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;
stickerSet#6a90bcb7 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 thumb:flags.4?PhotoSize count:int hash:int = StickerSet;
messages.stickerSet#b60a24a6 set:StickerSet packs:Vector<StickerPack> documents:Vector<Document> = messages.StickerSet;
@ -606,7 +610,7 @@ messages.botResults#947ca848 flags:# gallery:flags.0?true query_id:long next_off
exportedMessageLink#5dab1af4 link:string html:string = ExportedMessageLink;
messageFwdHeader#559ebe6d flags:# from_id:flags.0?int date:int channel_id:flags.1?int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int = MessageFwdHeader;
messageFwdHeader#ec338270 flags:# from_id:flags.0?int from_name:flags.5?string date:int channel_id:flags.1?int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int = MessageFwdHeader;
auth.codeTypeSms#72a3158c = auth.CodeType;
auth.codeTypeCall#741cd3e3 = auth.CodeType;
@ -1000,6 +1004,15 @@ autoDownloadSettings#d246fd47 flags:# disabled:flags.0?true video_preload_large:
account.autoDownloadSettings#63cacf26 low:AutoDownloadSettings medium:AutoDownloadSettings high:AutoDownloadSettings = account.AutoDownloadSettings;
emojiKeyword#d5b3b9f9 keyword:string emoticons:Vector<string> = EmojiKeyword;
emojiKeywordDeleted#236df622 keyword:string emoticons:Vector<string> = EmojiKeyword;
emojiKeywordsDifference#5cc761bd lang_code:string from_version:int version:int keywords:Vector<EmojiKeyword> = EmojiKeywordsDifference;
emojiURL#a575739d url:string = EmojiURL;
emojiLanguage#b3fb5361 lang_code:string = EmojiLanguage;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -1210,6 +1223,10 @@ messages.getOnlines#6e2be050 peer:InputPeer = ChatOnlines;
messages.getStatsURL#812c2ae6 flags:# dark:flags.0?true peer:InputPeer params:string = StatsURL;
messages.editChatAbout#def60797 peer:InputPeer about:string = Bool;
messages.editChatDefaultBannedRights#a5866b41 peer:InputPeer banned_rights:ChatBannedRights = Updates;
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;
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

@ -3569,6 +3569,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
bool has_send_date = message_id.is_yet_unsent() && send_date != 0;
bool has_flags2 = true;
bool has_notification_id = notification_id.is_valid();
bool has_forward_sender_name = is_forwarded && !forward_info->sender_name.empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(is_channel_post);
STORE_FLAG(is_outgoing);
@ -3606,6 +3607,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
STORE_FLAG(has_notification_id);
STORE_FLAG(is_mention_notification_disabled);
STORE_FLAG(had_forward_info);
STORE_FLAG(has_forward_sender_name);
END_STORE_FLAGS();
}
@ -3631,6 +3633,9 @@ void MessagesManager::Message::store(StorerT &storer) const {
if (has_forward_author_signature) {
store(forward_info->author_signature, storer);
}
if (has_forward_sender_name) {
store(forward_info->sender_name, storer);
}
if (has_forward_from) {
store(forward_info->from_dialog_id, storer);
store(forward_info->from_message_id, storer);
@ -3695,6 +3700,7 @@ void MessagesManager::Message::parse(ParserT &parser) {
bool has_send_date;
bool has_flags2;
bool has_notification_id = false;
bool has_forward_sender_name = false;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_channel_post);
PARSE_FLAG(is_outgoing);
@ -3732,6 +3738,7 @@ void MessagesManager::Message::parse(ParserT &parser) {
PARSE_FLAG(has_notification_id);
PARSE_FLAG(is_mention_notification_disabled);
PARSE_FLAG(had_forward_info);
PARSE_FLAG(has_forward_sender_name);
END_PARSE_FLAGS();
}
@ -3762,6 +3769,9 @@ void MessagesManager::Message::parse(ParserT &parser) {
if (has_forward_author_signature) {
parse(forward_info->author_signature, parser);
}
if (has_forward_sender_name) {
parse(forward_info->sender_name, parser);
}
if (has_forward_from) {
parse(forward_info->from_dialog_id, parser);
parse(forward_info->from_message_id, parser);
@ -17788,8 +17798,12 @@ tl_object_ptr<td_api::gameHighScores> MessagesManager::get_game_high_scores_obje
}
bool MessagesManager::is_forward_info_sender_hidden(const MessageForwardInfo *forward_info) {
return forward_info->dialog_id == DialogId(static_cast<int64>(-1001228946795ll)) &&
!forward_info->author_signature.empty() && !forward_info->message_id.is_valid();
if (!forward_info->sender_name.empty()) {
return true;
}
DialogId hidden_sender_dialog_id(static_cast<int64>(G()->is_test_dc() ? -1000010460537ll : -1001228946795ll));
return forward_info->dialog_id == hidden_sender_dialog_id && !forward_info->author_signature.empty() &&
!forward_info->message_id.is_valid();
}
unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_forward_info(
@ -17810,6 +17824,7 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
string author_signature;
DialogId from_dialog_id;
MessageId from_message_id;
string sender_name;
if ((flags & MESSAGE_FORWARD_HEADER_FLAG_HAS_AUTHOR_ID) != 0) {
sender_user_id = UserId(forward_header->from_id_);
if (!sender_user_id.is_valid()) {
@ -17843,6 +17858,9 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
from_message_id = MessageId();
}
}
if ((flags & MESSAGE_FORWARD_HEADER_FLAG_HAS_SENDER_NAME) != 0) {
sender_name = std::move(forward_header->from_name_);
}
DialogId dialog_id;
if (!channel_id.is_valid()) {
@ -17851,7 +17869,7 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
LOG(ERROR) << "Receive non-empty message id in message forward header: " << oneline(to_string(forward_header));
message_id = MessageId();
}
} else {
} else if (sender_name.empty()) {
LOG(ERROR) << "Receive wrong message forward header: " << oneline(to_string(forward_header));
return nullptr;
}
@ -17869,7 +17887,8 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
}
return td::make_unique<MessageForwardInfo>(sender_user_id, forward_header->date_, dialog_id, message_id,
author_signature, from_dialog_id, from_message_id);
std::move(author_signature), std::move(sender_name), from_dialog_id,
from_message_id);
}
td_api::object_ptr<td_api::messageForwardInfo> MessagesManager::get_message_forward_info_object(
@ -17880,7 +17899,8 @@ td_api::object_ptr<td_api::messageForwardInfo> MessagesManager::get_message_forw
auto origin = [&]() -> td_api::object_ptr<td_api::MessageForwardOrigin> {
if (is_forward_info_sender_hidden(forward_info.get())) {
return td_api::make_object<td_api::messageForwardOriginHiddenUser>(forward_info->author_signature);
return td_api::make_object<td_api::messageForwardOriginHiddenUser>(
forward_info->sender_name.empty() ? forward_info->author_signature : forward_info->sender_name);
}
if (forward_info->dialog_id.is_valid()) {
return td_api::make_object<td_api::messageForwardOriginChannel>(
@ -18136,14 +18156,14 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
: forwarded_message->author_signature;
forward_info = td::make_unique<MessageForwardInfo>(
UserId(), forwarded_message->date, from_dialog_id, forwarded_message->message_id,
std::move(author_signature), saved_from_dialog_id, saved_from_message_id);
std::move(author_signature), "", saved_from_dialog_id, saved_from_message_id);
} else {
LOG(ERROR) << "Don't know how to forward a channel post not from a channel";
}
} else if (forwarded_message->sender_user_id.is_valid()) {
forward_info =
make_unique<MessageForwardInfo>(forwarded_message->sender_user_id, forwarded_message->date, DialogId(),
MessageId(), "", saved_from_dialog_id, saved_from_message_id);
MessageId(), "", "", saved_from_dialog_id, saved_from_message_id);
} else {
LOG(ERROR) << "Don't know how to forward a non-channel post message without forward info and sender";
}

View File

@ -146,6 +146,7 @@ class MessagesManager : public Actor {
static constexpr int32 MESSAGE_FORWARD_HEADER_FLAG_HAS_MESSAGE_ID = 1 << 2;
static constexpr int32 MESSAGE_FORWARD_HEADER_FLAG_HAS_AUTHOR_SIGNATURE = 1 << 3;
static constexpr int32 MESSAGE_FORWARD_HEADER_FLAG_HAS_SAVED_FROM = 1 << 4;
static constexpr int32 MESSAGE_FORWARD_HEADER_FLAG_HAS_SENDER_NAME = 1 << 5;
static constexpr int32 SEND_MESSAGE_FLAG_IS_REPLY = 1 << 0;
static constexpr int32 SEND_MESSAGE_FLAG_DISABLE_WEB_PAGE_PREVIEW = 1 << 1;
@ -800,18 +801,20 @@ class MessagesManager : public Actor {
DialogId dialog_id;
MessageId message_id;
string author_signature;
string sender_name;
DialogId from_dialog_id;
MessageId from_message_id;
MessageForwardInfo() = default;
MessageForwardInfo(UserId sender_user_id, int32 date, DialogId dialog_id, MessageId message_id,
string author_signature, DialogId from_dialog_id, MessageId from_message_id)
string author_signature, string sender_name, DialogId from_dialog_id, MessageId from_message_id)
: sender_user_id(sender_user_id)
, date(date)
, dialog_id(dialog_id)
, message_id(message_id)
, author_signature(std::move(author_signature))
, sender_name(std::move(sender_name))
, from_dialog_id(from_dialog_id)
, from_message_id(from_message_id) {
}
@ -819,7 +822,8 @@ class MessagesManager : public Actor {
bool operator==(const MessageForwardInfo &rhs) const {
return sender_user_id == rhs.sender_user_id && date == rhs.date && dialog_id == rhs.dialog_id &&
message_id == rhs.message_id && author_signature == rhs.author_signature &&
from_dialog_id == rhs.from_dialog_id && from_message_id == rhs.from_message_id;
sender_name == rhs.sender_name && from_dialog_id == rhs.from_dialog_id &&
from_message_id == rhs.from_message_id;
}
bool operator!=(const MessageForwardInfo &rhs) const {
@ -828,9 +832,10 @@ class MessagesManager : public Actor {
friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageForwardInfo &forward_info) {
return string_builder << "MessageForwardInfo[sender " << forward_info.sender_user_id << "("
<< forward_info.author_signature << "), source " << forward_info.dialog_id << ", source "
<< forward_info.message_id << ", from " << forward_info.from_dialog_id << ", from "
<< forward_info.from_message_id << " at " << forward_info.date << "]";
<< forward_info.author_signature << "/" << forward_info.sender_name << "), source "
<< forward_info.dialog_id << ", source " << forward_info.message_id << ", from "
<< forward_info.from_dialog_id << ", from " << forward_info.from_message_id << " at "
<< forward_info.date << "]";
}
};

View File

@ -27,10 +27,11 @@ Result<PrivacyManager::UserPrivacySetting> PrivacyManager::UserPrivacySetting::f
}
return UserPrivacySetting(*key);
}
PrivacyManager::UserPrivacySetting::UserPrivacySetting(const telegram_api::PrivacyKey &key) {
switch (key.get_id()) {
case telegram_api::privacyKeyStatusTimestamp::ID:
type_ = Type::UserState;
type_ = Type::UserStatus;
break;
case telegram_api::privacyKeyChatInvite::ID:
type_ = Type::ChatInvite;
@ -41,14 +42,21 @@ PrivacyManager::UserPrivacySetting::UserPrivacySetting(const telegram_api::Priva
case telegram_api::privacyKeyPhoneP2P::ID:
type_ = Type::PeerToPeerCall;
break;
case telegram_api::privacyKeyForwards::ID:
type_ = Type::LinkInForwardedMessages;
break;
case telegram_api::privacyKeyProfilePhoto::ID:
type_ = Type::UserProfilePhoto;
break;
default:
UNREACHABLE();
type_ = Type::UserState;
type_ = Type::UserStatus;
}
}
tl_object_ptr<td_api::UserPrivacySetting> PrivacyManager::UserPrivacySetting::as_td_api() const {
switch (type_) {
case Type::UserState:
case Type::UserStatus:
return make_tl_object<td_api::userPrivacySettingShowStatus>();
case Type::ChatInvite:
return make_tl_object<td_api::userPrivacySettingAllowChatInvites>();
@ -56,6 +64,10 @@ tl_object_ptr<td_api::UserPrivacySetting> PrivacyManager::UserPrivacySetting::as
return make_tl_object<td_api::userPrivacySettingAllowCalls>();
case Type::PeerToPeerCall:
return make_tl_object<td_api::userPrivacySettingAllowPeerToPeerCalls>();
case Type::LinkInForwardedMessages:
return make_tl_object<td_api::userPrivacySettingShowLinkInForwardedMessages>();
case Type::UserProfilePhoto:
return make_tl_object<td_api::userPrivacySettingShowProfilePhoto>();
default:
UNREACHABLE();
return nullptr;
@ -63,7 +75,7 @@ tl_object_ptr<td_api::UserPrivacySetting> PrivacyManager::UserPrivacySetting::as
}
tl_object_ptr<telegram_api::InputPrivacyKey> PrivacyManager::UserPrivacySetting::as_telegram_api() const {
switch (type_) {
case Type::UserState:
case Type::UserStatus:
return make_tl_object<telegram_api::inputPrivacyKeyStatusTimestamp>();
case Type::ChatInvite:
return make_tl_object<telegram_api::inputPrivacyKeyChatInvite>();
@ -71,6 +83,10 @@ tl_object_ptr<telegram_api::InputPrivacyKey> PrivacyManager::UserPrivacySetting:
return make_tl_object<telegram_api::inputPrivacyKeyPhoneCall>();
case Type::PeerToPeerCall:
return make_tl_object<telegram_api::inputPrivacyKeyPhoneP2P>();
case Type::LinkInForwardedMessages:
return make_tl_object<telegram_api::inputPrivacyKeyForwards>();
case Type::UserProfilePhoto:
return make_tl_object<telegram_api::inputPrivacyKeyProfilePhoto>();
default:
UNREACHABLE();
return nullptr;
@ -80,7 +96,7 @@ tl_object_ptr<telegram_api::InputPrivacyKey> PrivacyManager::UserPrivacySetting:
PrivacyManager::UserPrivacySetting::UserPrivacySetting(const td_api::UserPrivacySetting &key) {
switch (key.get_id()) {
case td_api::userPrivacySettingShowStatus::ID:
type_ = Type::UserState;
type_ = Type::UserStatus;
break;
case td_api::userPrivacySettingAllowChatInvites::ID:
type_ = Type::ChatInvite;
@ -91,9 +107,15 @@ PrivacyManager::UserPrivacySetting::UserPrivacySetting(const td_api::UserPrivacy
case td_api::userPrivacySettingAllowPeerToPeerCalls::ID:
type_ = Type::PeerToPeerCall;
break;
case td_api::userPrivacySettingShowLinkInForwardedMessages::ID:
type_ = Type::LinkInForwardedMessages;
break;
case td_api::userPrivacySettingShowProfilePhoto::ID:
type_ = Type::UserProfilePhoto;
break;
default:
UNREACHABLE();
type_ = Type::UserState;
type_ = Type::UserStatus;
}
}
@ -368,7 +390,7 @@ void PrivacyManager::do_update_privacy(UserPrivacySetting user_privacy_setting,
make_tl_object<td_api::updateUserPrivacySettingRules>(user_privacy_setting.as_td_api(),
info.rules.as_td_api()));
if ((from_update || was_synchronized) && user_privacy_setting.type() == UserPrivacySetting::Type::UserState) {
if ((from_update || was_synchronized) && user_privacy_setting.type() == UserPrivacySetting::Type::UserStatus) {
send_closure(G()->contacts_manager(), &ContactsManager::on_update_online_status_privacy);
}
}

View File

@ -38,7 +38,15 @@ class PrivacyManager : public NetQueryCallback {
private:
class UserPrivacySetting {
public:
enum class Type : int32 { UserState, ChatInvite, Call, PeerToPeerCall, Size };
enum class Type : int32 {
UserStatus,
ChatInvite,
Call,
PeerToPeerCall,
LinkInForwardedMessages,
UserProfilePhoto,
Size
};
static Result<UserPrivacySetting> from_td_api(tl_object_ptr<td_api::UserPrivacySetting> key);
explicit UserPrivacySetting(const telegram_api::PrivacyKey &key);

View File

@ -917,6 +917,12 @@ class CliClient final : public Actor {
if (setting == "p2p") {
return td_api::make_object<td_api::userPrivacySettingAllowPeerToPeerCalls>();
}
if (setting == "forward") {
return td_api::make_object<td_api::userPrivacySettingShowLinkInForwardedMessages>();
}
if (setting == "photo") {
return td_api::make_object<td_api::userPrivacySettingShowProfilePhoto>();
}
return nullptr;
}
@ -1529,7 +1535,9 @@ class CliClient final : public Actor {
std::tie(setting, allow) = split(args);
std::vector<tl_object_ptr<td_api::UserPrivacySettingRule>> rules;
if (as_bool(allow)) {
if (allow == "c" || allow == "contacts") {
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleAllowContacts>());
} else if (as_bool(allow)) {
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleAllowAll>());
} else {
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleRestrictAll>());

View File

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