Add chatAdministrator.is_owner.
GitOrigin-RevId: 8ba5a2e7b175cb5595a4d26e8050311960063938
This commit is contained in:
parent
14f1b3cd4b
commit
46ed865570
@ -320,8 +320,8 @@ userProfilePhotos total_count:int32 photos:vector<userProfilePhoto> = UserProfil
|
||||
users total_count:int32 user_ids:vector<int32> = Users;
|
||||
|
||||
|
||||
//@description Contains information about a chat administrator @user_id User identifier of the administrator @custom_title Custom title of the administrator
|
||||
chatAdministrator user_id:int32 custom_title:string = ChatAdministrator;
|
||||
//@description Contains information about a chat administrator @user_id User identifier of the administrator @custom_title Custom title of the administrator @is_owner True, if the user is the owner of the chat
|
||||
chatAdministrator user_id:int32 custom_title:string is_owner:Bool = ChatAdministrator;
|
||||
|
||||
//@description Represents a list of chat administrators @administrators A list of chat administrators
|
||||
chatAdministrators administrators:vector<chatAdministrator> = ChatAdministrators;
|
||||
@ -3564,7 +3564,7 @@ setChatMemberStatus chat_id:int53 user_id:int32 status:ChatMemberStatus = Ok;
|
||||
//@description Checks whether the current session can be used to transfer a chat ownership to another user
|
||||
canTransferOwnership = CanTransferOwnershipResult;
|
||||
|
||||
//@description Changes owner of a chat. The current user must be a current owner of the chat. Use the method canTransferOwnership to check whether the ownership can be transferred from the current session. Available only for supergroups and channel chats
|
||||
//@description Changes the owner of a chat. The current user must be a current owner of the chat. Use the method canTransferOwnership to check whether the ownership can be transferred from the current session. Available only for supergroups and channel chats
|
||||
//@chat_id Chat identifier @user_id Identifier of the user to which transfer the ownership. The ownership can't be transferred to a bot or to a deleted user @password The password of the current user
|
||||
transferChatOwnership chat_id:int53 user_id:int32 password:string = Ok;
|
||||
|
||||
|
Binary file not shown.
@ -2507,7 +2507,7 @@ class GetChannelAdministratorsQuery : public Td::ResultHandler {
|
||||
return promise_.set_error(Status::Error(3, "Supergroup not found"));
|
||||
}
|
||||
|
||||
hash = 0; // to load even only ranks changed
|
||||
hash = 0; // to load even only ranks or creator changed
|
||||
|
||||
channel_id_ = channel_id;
|
||||
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_getParticipants(
|
||||
@ -2537,7 +2537,8 @@ class GetChannelAdministratorsQuery : public Td::ResultHandler {
|
||||
<< " as an administrator of " << channel_id_;
|
||||
continue;
|
||||
}
|
||||
administrators.emplace_back(dialog_participant.user_id, dialog_participant.status.get_rank());
|
||||
administrators.emplace_back(dialog_participant.user_id, dialog_participant.status.get_rank(),
|
||||
dialog_participant.status.is_creator());
|
||||
}
|
||||
|
||||
td->contacts_manager_->on_update_channel_administrator_count(channel_id_,
|
||||
@ -8037,7 +8038,7 @@ void ContactsManager::update_chat_full(ChatFull *chat_full, ChatId chat_id, bool
|
||||
for (const auto &participant : chat_full->participants) {
|
||||
auto user_id = participant.user_id;
|
||||
if (participant.status.is_administrator()) {
|
||||
administrators.emplace_back(user_id, participant.status.get_rank());
|
||||
administrators.emplace_back(user_id, participant.status.get_rank(), participant.status.is_creator());
|
||||
}
|
||||
if (is_user_bot(user_id)) {
|
||||
bot_user_ids.push_back(user_id);
|
||||
@ -9356,7 +9357,8 @@ void ContactsManager::on_get_channel_participants_success(
|
||||
if (filter.is_recent()) {
|
||||
for (const auto &participant : result) {
|
||||
if (participant.status.is_administrator()) {
|
||||
administrators.emplace_back(participant.user_id, participant.status.get_rank());
|
||||
administrators.emplace_back(participant.user_id, participant.status.get_rank(),
|
||||
participant.status.is_creator());
|
||||
}
|
||||
if (is_user_bot(participant.user_id)) {
|
||||
bot_user_ids.push_back(participant.user_id);
|
||||
@ -9370,7 +9372,8 @@ void ContactsManager::on_get_channel_participants_success(
|
||||
}
|
||||
} else if (filter.is_administrators()) {
|
||||
for (const auto &participant : result) {
|
||||
administrators.emplace_back(participant.user_id, participant.status.get_rank());
|
||||
administrators.emplace_back(participant.user_id, participant.status.get_rank(),
|
||||
participant.status.is_creator());
|
||||
}
|
||||
} else if (filter.is_bots()) {
|
||||
bot_user_ids = transform(result, [](const DialogParticipant &participant) { return participant.user_id; });
|
||||
@ -9557,15 +9560,16 @@ void ContactsManager::speculative_add_channel_user(ChannelId channel_id, UserId
|
||||
for (auto &administrator : administrators) {
|
||||
if (administrator.get_user_id() == user_id) {
|
||||
is_found = true;
|
||||
if (administrator.get_rank() != new_status.get_rank()) {
|
||||
administrator = DialogAdministrator(user_id, new_status.get_rank());
|
||||
if (administrator.get_rank() != new_status.get_rank() ||
|
||||
administrator.is_creator() != new_status.is_creator()) {
|
||||
administrator = DialogAdministrator(user_id, new_status.get_rank(), new_status.is_creator());
|
||||
on_update_dialog_administrators(dialog_id, std::move(administrators), true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!is_found) {
|
||||
administrators.emplace_back(user_id, new_status.get_rank());
|
||||
administrators.emplace_back(user_id, new_status.get_rank(), new_status.is_creator());
|
||||
on_update_dialog_administrators(dialog_id, std::move(administrators), true);
|
||||
}
|
||||
} else {
|
||||
@ -10506,6 +10510,8 @@ void ContactsManager::on_update_channel_status(Channel *c, ChannelId channel_id,
|
||||
if (input_channel != nullptr) {
|
||||
send_get_channel_full_query(nullptr, channel_id, std::move(input_channel), Auto(), "update channel owner");
|
||||
}
|
||||
|
||||
reload_dialog_administrators(DialogId(channel_id), 0, Auto());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,12 @@ td_api::object_ptr<td_api::chatAdministrator> DialogAdministrator::get_chat_admi
|
||||
CHECK(contacts_manager != nullptr);
|
||||
CHECK(user_id_.is_valid());
|
||||
return td_api::make_object<td_api::chatAdministrator>(
|
||||
contacts_manager->get_user_id_object(user_id_, "get_chat_administrator_object"), rank_);
|
||||
contacts_manager->get_user_id_object(user_id_, "get_chat_administrator_object"), rank_, is_creator_);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const DialogAdministrator &administrator) {
|
||||
return string_builder << "DialogAdministrator[" << administrator.user_id_ << ", title = " << administrator.rank_
|
||||
<< "]";
|
||||
<< ", is_owner = " << administrator.is_creator_ << "]";
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -20,13 +20,15 @@ class ContactsManager;
|
||||
class DialogAdministrator {
|
||||
UserId user_id_;
|
||||
string rank_;
|
||||
bool is_creator_ = false;
|
||||
|
||||
friend StringBuilder &operator<<(StringBuilder &string_builder, const DialogAdministrator &location);
|
||||
|
||||
public:
|
||||
DialogAdministrator() = default;
|
||||
|
||||
DialogAdministrator(UserId user_id, const string &rank) : user_id_(user_id), rank_(rank) {
|
||||
DialogAdministrator(UserId user_id, const string &rank, bool is_creator)
|
||||
: user_id_(user_id), rank_(rank), is_creator_(is_creator) {
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chatAdministrator> get_chat_administrator_object(
|
||||
@ -40,12 +42,17 @@ class DialogAdministrator {
|
||||
return rank_;
|
||||
}
|
||||
|
||||
bool is_creator() const {
|
||||
return is_creator_;
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
using td::store;
|
||||
bool has_rank = !rank_.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_rank);
|
||||
STORE_FLAG(is_creator_);
|
||||
END_STORE_FLAGS();
|
||||
store(user_id_, storer);
|
||||
if (has_rank) {
|
||||
@ -59,6 +66,7 @@ class DialogAdministrator {
|
||||
bool has_rank;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_rank);
|
||||
PARSE_FLAG(is_creator_);
|
||||
END_PARSE_FLAGS();
|
||||
parse(user_id_, parser);
|
||||
if (has_rank) {
|
||||
@ -68,7 +76,8 @@ class DialogAdministrator {
|
||||
};
|
||||
|
||||
inline bool operator==(const DialogAdministrator &lhs, const DialogAdministrator &rhs) {
|
||||
return lhs.get_user_id() == rhs.get_user_id() && lhs.get_rank() == rhs.get_rank();
|
||||
return lhs.get_user_id() == rhs.get_user_id() && lhs.get_rank() == rhs.get_rank() &&
|
||||
lhs.is_creator() == rhs.is_creator();
|
||||
}
|
||||
|
||||
inline bool operator!=(const DialogAdministrator &lhs, const DialogAdministrator &rhs) {
|
||||
|
Reference in New Issue
Block a user