Receive access hashes
This commit is contained in:
parent
3a4e03c19f
commit
0ee1d7edc1
@ -347,6 +347,20 @@ userTypeBot can_join_groups:Bool can_read_all_group_messages:Bool is_inline:Bool
|
||||
//@description No information on the user besides the user identifier is available, yet this user has not been deleted. This object is extremely rare and must be handled like a deleted user. It is not possible to perform any actions on users of this type
|
||||
userTypeUnknown = UserType;
|
||||
|
||||
//@class AccessHashType @description Represents the type of an access hash. The following types are possible: user, channel
|
||||
|
||||
//@description An access hash of an user
|
||||
accessHashTypeUser = AccessHashType;
|
||||
|
||||
//@description An access hash of a channel
|
||||
accessHashTypeChannel = AccessHashType;
|
||||
|
||||
|
||||
//@description Access hash @chat_id Chat identifier
|
||||
//@type Access hash type
|
||||
//@access_hash Access hash
|
||||
accessHash chat_id:int53 type:AccessHashType access_hash:int64 = AccessHash;
|
||||
|
||||
|
||||
//@description Represents a command supported by a bot @command Text of the bot command @param_description Description of the bot command
|
||||
botCommand command:string description:string = BotCommand;
|
||||
@ -3668,6 +3682,9 @@ updateUserStatus user_id:int32 status:UserStatus = Update;
|
||||
//@description Some data of a user has changed. This update is guaranteed to come before the user identifier is returned to the application @user New data about the user
|
||||
updateUser user:user = Update;
|
||||
|
||||
//@description Some data of a user or a chat has changed. This update is guaranteed to come before the user or chat identifier is returned to the application @access_hash Access hash
|
||||
updateAccessHash access_hash:accessHash = Update;
|
||||
|
||||
//@description Some data of a basic group has changed. This update is guaranteed to come before the basic group identifier is returned to the application @basic_group New data about the group
|
||||
updateBasicGroup basic_group:basicGroup = Update;
|
||||
|
||||
|
@ -8284,6 +8284,10 @@ class ContactsManager::UserLogEvent {
|
||||
|
||||
void ContactsManager::save_user(User *u, UserId user_id, bool from_binlog) {
|
||||
if (!G()->parameters().use_chat_info_db) {
|
||||
if (u != nullptr && G()->shared_config().get_option_boolean("receive_access_hashes", false)) {
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateAccessHash>(get_user_access_hash_object(user_id, u)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
CHECK(u != nullptr);
|
||||
@ -8822,6 +8826,10 @@ class ContactsManager::ChannelLogEvent {
|
||||
|
||||
void ContactsManager::save_channel(Channel *c, ChannelId channel_id, bool from_binlog) {
|
||||
if (!G()->parameters().use_chat_info_db) {
|
||||
if (c != nullptr && G()->shared_config().get_option_boolean("receive_access_hashes", false)) {
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateAccessHash>(get_channel_access_hash_object(channel_id, c)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
CHECK(c != nullptr);
|
||||
@ -15818,6 +15826,28 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id) con
|
||||
return get_user_object(user_id, get_user(user_id));
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::accessHash> ContactsManager::get_user_access_hash_object(UserId user_id, const User *u) const {
|
||||
if (u == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
tl_object_ptr<td_api::AccessHashType> type = make_tl_object<td_api::accessHashTypeUser>();
|
||||
if (!u->is_min_access_hash && u->access_hash != 0) {
|
||||
DialogId dialog_id(user_id);
|
||||
return make_tl_object<td_api::accessHash>(dialog_id.get(), std::move(type), u->access_hash);
|
||||
}
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::accessHash> ContactsManager::get_channel_access_hash_object(ChannelId channel_id, const Channel *c) const {
|
||||
if (c == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
tl_object_ptr<td_api::AccessHashType> type = make_tl_object<td_api::accessHashTypeChannel>();
|
||||
if (c->access_hash != 0) {
|
||||
DialogId dialog_id(channel_id);
|
||||
return make_tl_object<td_api::accessHash>(dialog_id.get(), std::move(type), c->access_hash);
|
||||
}
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, const User *u) const {
|
||||
if (u == nullptr) {
|
||||
return nullptr;
|
||||
|
@ -1449,6 +1449,10 @@ class ContactsManager final : public Actor {
|
||||
|
||||
tl_object_ptr<td_api::user> get_user_object(UserId user_id, const User *u) const;
|
||||
|
||||
tl_object_ptr<td_api::accessHash> get_user_access_hash_object(UserId user_id, const User *u) const;
|
||||
|
||||
tl_object_ptr<td_api::accessHash> get_channel_access_hash_object(ChannelId channel_id, const Channel *c) const;
|
||||
|
||||
tl_object_ptr<td_api::userFullInfo> get_user_full_info_object(UserId user_id, const UserFull *user_full) const;
|
||||
|
||||
static td_api::object_ptr<td_api::updateBasicGroup> get_update_unknown_basic_group_object(ChatId chat_id);
|
||||
|
@ -7752,6 +7752,9 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
|
||||
if (set_boolean_option("reuse_uploaded_photos_by_hash")) {
|
||||
return;
|
||||
}
|
||||
if (set_boolean_option("receive_access_hashes")) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if (set_integer_option("session_count", 0, 50)) {
|
||||
|
Loading…
Reference in New Issue
Block a user