Fix channelParticipantSelf handling.
This commit is contained in:
parent
3b3801abbe
commit
813b141148
@ -2931,7 +2931,7 @@ class GetChannelParticipantQuery : public Td::ResultHandler {
|
|||||||
LOG(INFO) << "Receive result for GetChannelParticipantQuery: " << to_string(participant);
|
LOG(INFO) << "Receive result for GetChannelParticipantQuery: " << to_string(participant);
|
||||||
|
|
||||||
td->contacts_manager_->on_get_users(std::move(participant->users_), "GetChannelParticipantQuery");
|
td->contacts_manager_->on_get_users(std::move(participant->users_), "GetChannelParticipantQuery");
|
||||||
auto result = td->contacts_manager_->get_dialog_participant(channel_id_, std::move(participant->participant_));
|
DialogParticipant result(std::move(participant->participant_));
|
||||||
if (!result.is_valid()) {
|
if (!result.is_valid()) {
|
||||||
LOG(ERROR) << "Receive invalid " << result;
|
LOG(ERROR) << "Receive invalid " << result;
|
||||||
return promise_.set_error(Status::Error(500, "Receive invalid chat member"));
|
return promise_.set_error(Status::Error(500, "Receive invalid chat member"));
|
||||||
@ -3034,8 +3034,7 @@ class GetChannelAdministratorsQuery : public Td::ResultHandler {
|
|||||||
vector<DialogAdministrator> administrators;
|
vector<DialogAdministrator> administrators;
|
||||||
administrators.reserve(participants->participants_.size());
|
administrators.reserve(participants->participants_.size());
|
||||||
for (auto &participant : participants->participants_) {
|
for (auto &participant : participants->participants_) {
|
||||||
DialogParticipant dialog_participant =
|
DialogParticipant dialog_participant(std::move(participant));
|
||||||
td->contacts_manager_->get_dialog_participant(channel_id_, std::move(participant));
|
|
||||||
if (!dialog_participant.is_valid() || !dialog_participant.status.is_administrator()) {
|
if (!dialog_participant.is_valid() || !dialog_participant.status.is_administrator()) {
|
||||||
LOG(ERROR) << "Receive " << dialog_participant << " as an administrator of " << channel_id_;
|
LOG(ERROR) << "Receive " << dialog_participant << " as an administrator of " << channel_id_;
|
||||||
continue;
|
continue;
|
||||||
@ -11358,11 +11357,6 @@ const DialogParticipant *ContactsManager::get_chat_participant(const ChatFull *c
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogParticipant ContactsManager::get_dialog_participant(
|
|
||||||
ChannelId channel_id, tl_object_ptr<telegram_api::ChannelParticipant> &&participant_ptr) const {
|
|
||||||
return DialogParticipant(std::move(participant_ptr), get_channel_status(channel_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
tl_object_ptr<td_api::chatMember> ContactsManager::get_chat_member_object(
|
tl_object_ptr<td_api::chatMember> ContactsManager::get_chat_member_object(
|
||||||
const DialogParticipant &dialog_participant) const {
|
const DialogParticipant &dialog_participant) const {
|
||||||
UserId participant_user_id = dialog_participant.user_id;
|
UserId participant_user_id = dialog_participant.user_id;
|
||||||
@ -11464,7 +11458,7 @@ void ContactsManager::on_get_channel_participants(
|
|||||||
vector<DialogParticipant> result;
|
vector<DialogParticipant> result;
|
||||||
for (auto &participant_ptr : participants) {
|
for (auto &participant_ptr : participants) {
|
||||||
auto debug_participant = to_string(participant_ptr);
|
auto debug_participant = to_string(participant_ptr);
|
||||||
result.push_back(get_dialog_participant(channel_id, std::move(participant_ptr)));
|
result.emplace_back(std::move(participant_ptr));
|
||||||
const auto &participant = result.back();
|
const auto &participant = result.back();
|
||||||
if (!participant.is_valid() || (filter.is_bots() && !is_user_bot(participant.user_id)) ||
|
if (!participant.is_valid() || (filter.is_bots() && !is_user_bot(participant.user_id)) ||
|
||||||
(filter.is_administrators() && !participant.status.is_administrator()) ||
|
(filter.is_administrators() && !participant.status.is_administrator()) ||
|
||||||
@ -13125,14 +13119,14 @@ void ContactsManager::on_update_channel_participant(ChannelId channel_id, UserId
|
|||||||
DialogParticipant old_dialog_participant;
|
DialogParticipant old_dialog_participant;
|
||||||
DialogParticipant new_dialog_participant;
|
DialogParticipant new_dialog_participant;
|
||||||
if (old_participant != nullptr) {
|
if (old_participant != nullptr) {
|
||||||
old_dialog_participant = get_dialog_participant(channel_id, std::move(old_participant));
|
old_dialog_participant = DialogParticipant(std::move(old_participant));
|
||||||
if (new_participant == nullptr) {
|
if (new_participant == nullptr) {
|
||||||
new_dialog_participant = DialogParticipant::left(old_dialog_participant.user_id);
|
new_dialog_participant = DialogParticipant::left(old_dialog_participant.user_id);
|
||||||
} else {
|
} else {
|
||||||
new_dialog_participant = get_dialog_participant(channel_id, std::move(new_participant));
|
new_dialog_participant = DialogParticipant(std::move(new_participant));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
new_dialog_participant = get_dialog_participant(channel_id, std::move(new_participant));
|
new_dialog_participant = DialogParticipant(std::move(new_participant));
|
||||||
old_dialog_participant = DialogParticipant::left(new_dialog_participant.user_id);
|
old_dialog_participant = DialogParticipant::left(new_dialog_participant.user_id);
|
||||||
}
|
}
|
||||||
if (old_dialog_participant.user_id != new_dialog_participant.user_id || !old_dialog_participant.is_valid() ||
|
if (old_dialog_participant.user_id != new_dialog_participant.user_id || !old_dialog_participant.is_valid() ||
|
||||||
|
@ -521,9 +521,6 @@ class ContactsManager : public Actor {
|
|||||||
void ban_dialog_participant(DialogId dialog_id, UserId user_id, int32 banned_until_date, bool revoke_messages,
|
void ban_dialog_participant(DialogId dialog_id, UserId user_id, int32 banned_until_date, bool revoke_messages,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
DialogParticipant get_dialog_participant(ChannelId channel_id,
|
|
||||||
tl_object_ptr<telegram_api::ChannelParticipant> &&participant_ptr) const;
|
|
||||||
|
|
||||||
DialogParticipant get_dialog_participant(DialogId dialog_id, UserId user_id, int64 &random_id, bool force,
|
DialogParticipant get_dialog_participant(DialogId dialog_id, UserId user_id, int64 &random_id, bool force,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
@ -681,8 +681,7 @@ DialogParticipant::DialogParticipant(tl_object_ptr<telegram_api::ChatParticipant
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogParticipant::DialogParticipant(tl_object_ptr<telegram_api::ChannelParticipant> &&participant_ptr,
|
DialogParticipant::DialogParticipant(tl_object_ptr<telegram_api::ChannelParticipant> &&participant_ptr) {
|
||||||
DialogParticipantStatus my_status) {
|
|
||||||
CHECK(participant_ptr != nullptr);
|
CHECK(participant_ptr != nullptr);
|
||||||
switch (participant_ptr->get_id()) {
|
switch (participant_ptr->get_id()) {
|
||||||
case telegram_api::channelParticipant::ID: {
|
case telegram_api::channelParticipant::ID: {
|
||||||
@ -693,7 +692,7 @@ DialogParticipant::DialogParticipant(tl_object_ptr<telegram_api::ChannelParticip
|
|||||||
case telegram_api::channelParticipantSelf::ID: {
|
case telegram_api::channelParticipantSelf::ID: {
|
||||||
auto participant = move_tl_object_as<telegram_api::channelParticipantSelf>(participant_ptr);
|
auto participant = move_tl_object_as<telegram_api::channelParticipantSelf>(participant_ptr);
|
||||||
*this = {UserId(participant->user_id_), UserId(participant->inviter_id_), participant->date_,
|
*this = {UserId(participant->user_id_), UserId(participant->inviter_id_), participant->date_,
|
||||||
std::move(my_status)};
|
DialogParticipantStatus::Member()};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case telegram_api::channelParticipantCreator::ID: {
|
case telegram_api::channelParticipantCreator::ID: {
|
||||||
|
@ -395,8 +395,7 @@ struct DialogParticipant {
|
|||||||
DialogParticipant(tl_object_ptr<telegram_api::ChatParticipant> &&participant_ptr, int32 chat_creation_date,
|
DialogParticipant(tl_object_ptr<telegram_api::ChatParticipant> &&participant_ptr, int32 chat_creation_date,
|
||||||
bool is_creator);
|
bool is_creator);
|
||||||
|
|
||||||
DialogParticipant(tl_object_ptr<telegram_api::ChannelParticipant> &&participant_ptr,
|
explicit DialogParticipant(tl_object_ptr<telegram_api::ChannelParticipant> &&participant_ptr);
|
||||||
DialogParticipantStatus my_status);
|
|
||||||
|
|
||||||
static DialogParticipant left(UserId user_id) {
|
static DialogParticipant left(UserId user_id) {
|
||||||
return {user_id, UserId(), 0, DialogParticipantStatus::Left()};
|
return {user_id, UserId(), 0, DialogParticipantStatus::Left()};
|
||||||
|
@ -31223,48 +31223,48 @@ tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_ob
|
|||||||
return make_tl_object<td_api::chatEventMemberLeft>();
|
return make_tl_object<td_api::chatEventMemberLeft>();
|
||||||
case telegram_api::channelAdminLogEventActionParticipantInvite::ID: {
|
case telegram_api::channelAdminLogEventActionParticipantInvite::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantInvite>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantInvite>(action_ptr);
|
||||||
auto member = td_->contacts_manager_->get_dialog_participant(channel_id, std::move(action->participant_));
|
DialogParticipant dialog_participant(std::move(action->participant_));
|
||||||
if (!member.is_valid()) {
|
if (!dialog_participant.is_valid()) {
|
||||||
LOG(ERROR) << "Wrong invite: " << member;
|
LOG(ERROR) << "Wrong invite: " << dialog_participant;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return make_tl_object<td_api::chatEventMemberInvited>(
|
return make_tl_object<td_api::chatEventMemberInvited>(
|
||||||
td_->contacts_manager_->get_user_id_object(member.user_id, "chatEventMemberInvited"),
|
td_->contacts_manager_->get_user_id_object(dialog_participant.user_id, "chatEventMemberInvited"),
|
||||||
member.status.get_chat_member_status_object());
|
dialog_participant.status.get_chat_member_status_object());
|
||||||
}
|
}
|
||||||
case telegram_api::channelAdminLogEventActionParticipantToggleBan::ID: {
|
case telegram_api::channelAdminLogEventActionParticipantToggleBan::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleBan>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleBan>(action_ptr);
|
||||||
auto old_member =
|
DialogParticipant old_dialog_participant(std::move(action->prev_participant_));
|
||||||
td_->contacts_manager_->get_dialog_participant(channel_id, std::move(action->prev_participant_));
|
DialogParticipant new_dialog_participant(std::move(action->new_participant_));
|
||||||
auto new_member = td_->contacts_manager_->get_dialog_participant(channel_id, std::move(action->new_participant_));
|
if (old_dialog_participant.user_id != new_dialog_participant.user_id) {
|
||||||
if (old_member.user_id != new_member.user_id) {
|
LOG(ERROR) << old_dialog_participant.user_id << " VS " << new_dialog_participant.user_id;
|
||||||
LOG(ERROR) << old_member.user_id << " VS " << new_member.user_id;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!old_member.is_valid() || !new_member.is_valid()) {
|
if (!old_dialog_participant.is_valid() || !new_dialog_participant.is_valid()) {
|
||||||
LOG(ERROR) << "Wrong restrict: " << old_member << " -> " << new_member;
|
LOG(ERROR) << "Wrong restrict: " << old_dialog_participant << " -> " << new_dialog_participant;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return make_tl_object<td_api::chatEventMemberRestricted>(
|
return make_tl_object<td_api::chatEventMemberRestricted>(
|
||||||
td_->contacts_manager_->get_user_id_object(old_member.user_id, "chatEventMemberRestricted"),
|
td_->contacts_manager_->get_user_id_object(old_dialog_participant.user_id, "chatEventMemberRestricted"),
|
||||||
old_member.status.get_chat_member_status_object(), new_member.status.get_chat_member_status_object());
|
old_dialog_participant.status.get_chat_member_status_object(),
|
||||||
|
new_dialog_participant.status.get_chat_member_status_object());
|
||||||
}
|
}
|
||||||
case telegram_api::channelAdminLogEventActionParticipantToggleAdmin::ID: {
|
case telegram_api::channelAdminLogEventActionParticipantToggleAdmin::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleAdmin>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleAdmin>(action_ptr);
|
||||||
auto old_member =
|
DialogParticipant old_dialog_participant(std::move(action->prev_participant_));
|
||||||
td_->contacts_manager_->get_dialog_participant(channel_id, std::move(action->prev_participant_));
|
DialogParticipant new_dialog_participant(std::move(action->new_participant_));
|
||||||
auto new_member = td_->contacts_manager_->get_dialog_participant(channel_id, std::move(action->new_participant_));
|
if (old_dialog_participant.user_id != new_dialog_participant.user_id) {
|
||||||
if (old_member.user_id != new_member.user_id) {
|
LOG(ERROR) << old_dialog_participant.user_id << " VS " << new_dialog_participant.user_id;
|
||||||
LOG(ERROR) << old_member.user_id << " VS " << new_member.user_id;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!old_member.is_valid() || !new_member.is_valid()) {
|
if (!old_dialog_participant.is_valid() || !new_dialog_participant.is_valid()) {
|
||||||
LOG(ERROR) << "Wrong edit administrator: " << old_member << " -> " << new_member;
|
LOG(ERROR) << "Wrong edit administrator: " << old_dialog_participant << " -> " << new_dialog_participant;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return make_tl_object<td_api::chatEventMemberPromoted>(
|
return make_tl_object<td_api::chatEventMemberPromoted>(
|
||||||
td_->contacts_manager_->get_user_id_object(old_member.user_id, "chatEventMemberPromoted"),
|
td_->contacts_manager_->get_user_id_object(old_dialog_participant.user_id, "chatEventMemberPromoted"),
|
||||||
old_member.status.get_chat_member_status_object(), new_member.status.get_chat_member_status_object());
|
old_dialog_participant.status.get_chat_member_status_object(),
|
||||||
|
new_dialog_participant.status.get_chat_member_status_object());
|
||||||
}
|
}
|
||||||
case telegram_api::channelAdminLogEventActionChangeTitle::ID: {
|
case telegram_api::channelAdminLogEventActionChangeTitle::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeTitle>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeTitle>(action_ptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user