Merge remote-tracking branch 'td/master'

This commit is contained in:
Andrea Cavalli 2021-10-29 14:56:39 +02:00
commit 9f3e26dea6
10 changed files with 142 additions and 139 deletions

View File

@ -3004,13 +3004,13 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler {
administrators.reserve(participants->participants_.size());
for (auto &participant : participants->participants_) {
DialogParticipant dialog_participant(std::move(participant));
if (!dialog_participant.is_valid() || !dialog_participant.status.is_administrator() ||
dialog_participant.dialog_id.get_type() != DialogType::User) {
if (!dialog_participant.is_valid() || !dialog_participant.status_.is_administrator() ||
dialog_participant.dialog_id_.get_type() != DialogType::User) {
LOG(ERROR) << "Receive " << dialog_participant << " as an administrator of " << channel_id_;
continue;
}
administrators.emplace_back(dialog_participant.dialog_id.get_user_id(), dialog_participant.status.get_rank(),
dialog_participant.status.is_creator());
administrators.emplace_back(dialog_participant.dialog_id_.get_user_id(),
dialog_participant.status_.get_rank(), dialog_participant.status_.is_creator());
}
td->contacts_manager_->on_update_channel_administrator_count(channel_id_,
@ -6915,7 +6915,7 @@ void ContactsManager::set_channel_participant_status(ChannelId channel_id, Dialo
}
send_closure(actor_id, &ContactsManager::set_channel_participant_status_impl, channel_id, participant_dialog_id,
std::move(status), r_dialog_participant.ok().status, std::move(promise));
std::move(status), r_dialog_participant.ok().status_, std::move(promise));
});
td_->create_handler<GetChannelParticipantQuery>(std::move(on_result_promise))
@ -7436,17 +7436,17 @@ void ContactsManager::delete_chat_participant(ChatId chat_id, UserId user_id, bo
TODO
if (c->everyone_is_administrator) {
// if all are administrators, only invited by me participants can be deleted
if (participant->inviter_user_id != my_id) {
if (participant->inviter_user_id_ != my_id) {
return promise.set_error(Status::Error(400, "Need to be inviter of a user to kick it from a basic group"));
}
} else {
// otherwise, only creator can kick administrators
if (participant->status.is_administrator()) {
if (participant->status_.is_administrator()) {
return promise.set_error(
Status::Error(400, "Only the creator of a basic group can kick group administrators"));
}
// regular users can be kicked by administrators and their inviters
if (!my_status.is_administrator() && participant->inviter_user_id != my_id) {
if (!my_status.is_administrator() && participant->inviter_user_id_ != my_id) {
return promise.set_error(Status::Error(400, "Need to be inviter of a user to kick it from a basic group"));
}
}
@ -9447,8 +9447,8 @@ void ContactsManager::on_load_chat_full_from_database(ChatId chat_id, string val
dependencies.chat_ids.insert(chat_id);
dependencies.user_ids.insert(chat_full->creator_user_id);
for (auto &participant : chat_full->participants) {
add_message_sender_dependencies(dependencies, participant.dialog_id);
dependencies.user_ids.insert(participant.inviter_user_id);
add_message_sender_dependencies(dependencies, participant.dialog_id_);
dependencies.user_ids.insert(participant.inviter_user_id_);
}
dependencies.user_ids.insert(chat_full->invite_link.get_creator_user_id());
if (!resolve_dependencies_force(td_, dependencies, "on_load_chat_full_from_database")) {
@ -10011,12 +10011,12 @@ void ContactsManager::update_chat_full(ChatFull *chat_full, ChatId chat_id, cons
vector<DialogAdministrator> administrators;
vector<UserId> bot_user_ids;
for (const auto &participant : chat_full->participants) {
if (participant.status.is_administrator() && participant.dialog_id.get_type() == DialogType::User) {
administrators.emplace_back(participant.dialog_id.get_user_id(), participant.status.get_rank(),
participant.status.is_creator());
if (participant.status_.is_administrator() && participant.dialog_id_.get_type() == DialogType::User) {
administrators.emplace_back(participant.dialog_id_.get_user_id(), participant.status_.get_rank(),
participant.status_.is_creator());
}
if (participant.dialog_id.get_type() == DialogType::User) {
auto user_id = participant.dialog_id.get_user_id();
if (participant.dialog_id_.get_type() == DialogType::User) {
auto user_id = participant.dialog_id_.get_user_id();
if (is_user_bot(user_id)) {
bot_user_ids.push_back(user_id);
}
@ -10361,7 +10361,7 @@ vector<BotCommands> ContactsManager::get_bot_commands(vector<tl_object_ptr<teleg
if (participants != nullptr) {
bool is_participant = false;
for (auto &participant : *participants) {
if (participant.dialog_id == DialogId(user_id)) {
if (participant.dialog_id_ == DialogId(user_id)) {
is_participant = true;
break;
}
@ -11479,10 +11479,10 @@ void ContactsManager::update_dialog_online_member_count(const vector<DialogParti
int32 online_member_count = 0;
int32 time = G()->unix_time();
for (const auto &participant : participants) {
if (participant.dialog_id.get_type() != DialogType::User) {
if (participant.dialog_id_.get_type() != DialogType::User) {
continue;
}
auto user_id = participant.dialog_id.get_user_id();
auto user_id = participant.dialog_id_.get_user_id();
auto u = get_user(user_id);
if (u != nullptr && !u->is_deleted && !u->is_bot) {
if (get_user_was_online(u, user_id) > time) {
@ -11548,18 +11548,18 @@ void ContactsManager::on_get_chat_participants(tl_object_ptr<telegram_api::ChatP
continue;
}
LOG_IF(ERROR, !td_->messages_manager_->have_dialog_info(dialog_participant.dialog_id))
<< "Have no information about " << dialog_participant.dialog_id << " as a member of " << chat_id;
LOG_IF(ERROR, !have_user(dialog_participant.inviter_user_id))
<< "Have no information about " << dialog_participant.inviter_user_id << " as a member of " << chat_id;
if (dialog_participant.joined_date < c->date) {
LOG_IF(ERROR, dialog_participant.joined_date < c->date - 30 && c->date >= 1486000000)
<< "Wrong join date = " << dialog_participant.joined_date << " for " << dialog_participant.dialog_id
LOG_IF(ERROR, !td_->messages_manager_->have_dialog_info(dialog_participant.dialog_id_))
<< "Have no information about " << dialog_participant.dialog_id_ << " as a member of " << chat_id;
LOG_IF(ERROR, !have_user(dialog_participant.inviter_user_id_))
<< "Have no information about " << dialog_participant.inviter_user_id_ << " as a member of " << chat_id;
if (dialog_participant.joined_date_ < c->date) {
LOG_IF(ERROR, dialog_participant.joined_date_ < c->date - 30 && c->date >= 1486000000)
<< "Wrong join date = " << dialog_participant.joined_date_ << " for " << dialog_participant.dialog_id_
<< ", " << chat_id << " was created at " << c->date;
dialog_participant.joined_date = c->date;
dialog_participant.joined_date_ = c->date;
}
if (dialog_participant.status.is_creator() && dialog_participant.dialog_id.get_type() == DialogType::User) {
new_creator_user_id = dialog_participant.dialog_id.get_user_id();
if (dialog_participant.status_.is_creator() && dialog_participant.dialog_id_.get_type() == DialogType::User) {
new_creator_user_id = dialog_participant.dialog_id_.get_user_id();
}
new_participants.push_back(std::move(dialog_participant));
}
@ -11595,7 +11595,7 @@ const DialogParticipant *ContactsManager::get_chat_participant(ChatId chat_id, U
const DialogParticipant *ContactsManager::get_chat_full_participant(const ChatFull *chat_full, DialogId dialog_id) {
for (const auto &dialog_participant : chat_full->participants) {
if (dialog_participant.dialog_id == dialog_id) {
if (dialog_participant.dialog_id_ == dialog_id) {
return &dialog_participant;
}
}
@ -11604,7 +11604,7 @@ const DialogParticipant *ContactsManager::get_chat_full_participant(const ChatFu
tl_object_ptr<td_api::chatMember> ContactsManager::get_chat_member_object(
const DialogParticipant &dialog_participant) const {
DialogId dialog_id = dialog_participant.dialog_id;
DialogId dialog_id = dialog_participant.dialog_id_;
UserId participant_user_id;
if (dialog_id.get_type() == DialogType::User) {
participant_user_id = dialog_id.get_user_id();
@ -11613,8 +11613,8 @@ tl_object_ptr<td_api::chatMember> ContactsManager::get_chat_member_object(
}
return td_api::make_object<td_api::chatMember>(
td_->messages_manager_->get_message_sender_object_const(dialog_id, "get_chat_member_object"),
get_user_id_object(dialog_participant.inviter_user_id, "chatMember.inviter_user_id"),
dialog_participant.joined_date, dialog_participant.status.get_chat_member_status_object());
get_user_id_object(dialog_participant.inviter_user_id_, "chatMember.inviter_user_id"),
dialog_participant.joined_date_, dialog_participant.status_.get_chat_member_status_object());
}
bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &status, const string &source) {
@ -11710,15 +11710,15 @@ void ContactsManager::on_get_channel_participants(
result.emplace_back(std::move(participant_ptr));
const auto &participant = result.back();
UserId participant_user_id;
if (participant.dialog_id.get_type() == DialogType::User) {
participant_user_id = participant.dialog_id.get_user_id();
if (participant.dialog_id_.get_type() == DialogType::User) {
participant_user_id = participant.dialog_id_.get_user_id();
}
if (!participant.is_valid() || (filter.is_bots() && !is_user_bot(participant_user_id)) ||
(filter.is_administrators() && !participant.status.is_administrator()) ||
((filter.is_recent() || filter.is_contacts() || filter.is_search()) && !participant.status.is_member()) ||
(filter.is_administrators() && !participant.status_.is_administrator()) ||
((filter.is_recent() || filter.is_contacts() || filter.is_search()) && !participant.status_.is_member()) ||
(filter.is_contacts() && !is_user_contact(participant_user_id)) ||
(filter.is_restricted() && !participant.status.is_restricted()) ||
(filter.is_banned() && !participant.status.is_banned())) {
(filter.is_restricted() && !participant.status_.is_restricted()) ||
(filter.is_banned() && !participant.status_.is_banned())) {
bool skip_error = ((filter.is_administrators() || filter.is_bots()) && is_user_deleted(participant_user_id)) ||
(filter.is_contacts() && participant_user_id == get_my_id());
if (!skip_error) {
@ -11750,11 +11750,11 @@ void ContactsManager::on_get_channel_participants(
{
if (filter.is_recent()) {
for (const auto &participant : result) {
if (participant.dialog_id.get_type() == DialogType::User) {
auto participant_user_id = participant.dialog_id.get_user_id();
if (participant.status.is_administrator()) {
administrators.emplace_back(participant_user_id, participant.status.get_rank(),
participant.status.is_creator());
if (participant.dialog_id_.get_type() == DialogType::User) {
auto participant_user_id = participant.dialog_id_.get_user_id();
if (participant.status_.is_administrator()) {
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);
@ -11769,15 +11769,15 @@ void ContactsManager::on_get_channel_participants(
}
} else if (filter.is_administrators()) {
for (const auto &participant : result) {
if (participant.dialog_id.get_type() == DialogType::User) {
administrators.emplace_back(participant.dialog_id.get_user_id(), participant.status.get_rank(),
participant.status.is_creator());
if (participant.dialog_id_.get_type() == DialogType::User) {
administrators.emplace_back(participant.dialog_id_.get_user_id(), participant.status_.get_rank(),
participant.status_.is_creator());
}
}
} else if (filter.is_bots()) {
bot_user_ids = transform(result, [](const DialogParticipant &participant) {
CHECK(participant.dialog_id.get_type() == DialogType::User);
return participant.dialog_id.get_user_id();
CHECK(participant.dialog_id_.get_type() == DialogType::User);
return participant.dialog_id_.get_user_id();
});
}
}
@ -11827,7 +11827,7 @@ void ContactsManager::on_get_channel_participants(
}
if (!additional_query.empty()) {
auto dialog_ids = transform(result, [](const DialogParticipant &participant) { return participant.dialog_id; });
auto dialog_ids = transform(result, [](const DialogParticipant &participant) { return participant.dialog_id_; });
std::pair<int32, vector<DialogId>> result_dialog_ids =
search_among_dialogs(dialog_ids, additional_query, additional_limit);
@ -11837,8 +11837,8 @@ void ContactsManager::on_get_channel_participants(
auto all_participants = std::move(result);
result.clear();
for (auto &participant : all_participants) {
if (result_dialog_ids_set.count(participant.dialog_id)) {
result_dialog_ids_set.erase(participant.dialog_id);
if (result_dialog_ids_set.count(participant.dialog_id_)) {
result_dialog_ids_set.erase(participant.dialog_id_);
result.push_back(std::move(participant));
}
}
@ -11862,7 +11862,7 @@ void ContactsManager::add_channel_participant_to_cache(ChannelId channel_id,
if (participants.participants_.empty()) {
channel_participant_cache_timeout_.set_timeout_in(channel_id.get(), CHANNEL_PARTICIPANT_CACHE_TIME);
}
auto &participant_info = participants.participants_[dialog_participant.dialog_id];
auto &participant_info = participants.participants_[dialog_participant.dialog_id_];
if (participant_info.last_access_date_ > 0 && !allow_replace) {
return;
}
@ -11881,7 +11881,7 @@ const DialogParticipant *ContactsManager::get_channel_participant_from_cache(Cha
CHECK(!participants.empty());
auto it = participants.find(participant_dialog_id);
if (it != participants.end()) {
it->second.participant_.status.update_restrictions();
it->second.participant_.status_.update_restrictions();
it->second.last_access_date_ = G()->unix_time();
return &it->second.participant_;
}
@ -11919,7 +11919,7 @@ void ContactsManager::speculative_add_channel_participants(ChannelId channel_id,
auto &participants = it->second;
bool is_found = false;
for (auto &participant : participants) {
if (participant.dialog_id == DialogId(user_id)) {
if (participant.dialog_id_ == DialogId(user_id)) {
is_found = true;
break;
}
@ -11961,7 +11961,7 @@ void ContactsManager::speculative_delete_channel_participant(ChannelId channel_i
if (it != cached_channel_participants_.end()) {
auto &participants = it->second;
for (size_t i = 0; i < participants.size(); i++) {
if (participants[i].dialog_id == DialogId(deleted_user_id)) {
if (participants[i].dialog_id_ == DialogId(deleted_user_id)) {
participants.erase(participants.begin() + i);
update_channel_online_member_count(channel_id, false);
break;
@ -12076,12 +12076,12 @@ void ContactsManager::speculative_add_channel_user(ChannelId channel_id, UserId
auto &participants = it->second;
bool is_found = false;
for (size_t i = 0; i < participants.size(); i++) {
if (participants[i].dialog_id == DialogId(user_id)) {
if (participants[i].dialog_id_ == DialogId(user_id)) {
if (!new_status.is_member()) {
participants.erase(participants.begin() + i);
update_channel_online_member_count(channel_id, false);
} else {
participants[i].status = new_status;
participants[i].status_ = new_status;
}
is_found = true;
break;
@ -12658,12 +12658,12 @@ void ContactsManager::on_update_chat_add_user(ChatId chat_id, UserId inviter_use
}
if (on_update_chat_full_participants_short(chat_full, chat_id, version)) {
for (auto &participant : chat_full->participants) {
if (participant.dialog_id == DialogId(user_id)) {
if (participant.inviter_user_id != inviter_user_id) {
if (participant.dialog_id_ == DialogId(user_id)) {
if (participant.inviter_user_id_ != inviter_user_id) {
LOG(ERROR) << user_id << " was readded to " << chat_id << " by " << inviter_user_id
<< ", previously invited by " << participant.inviter_user_id;
participant.inviter_user_id = inviter_user_id;
participant.joined_date = date;
<< ", previously invited by " << participant.inviter_user_id_;
participant.inviter_user_id_ = inviter_user_id;
participant.joined_date_ = date;
repair_chat_participants(chat_id);
} else {
// Possible if update comes twice
@ -12747,8 +12747,8 @@ void ContactsManager::on_update_chat_edit_administrator(ChatId chat_id, UserId u
if (chat_full != nullptr) {
if (chat_full->version + 1 == version) {
for (auto &participant : chat_full->participants) {
if (participant.dialog_id == DialogId(user_id)) {
participant.status = std::move(status);
if (participant.dialog_id_ == DialogId(user_id)) {
participant.status_ = std::move(status);
chat_full->is_changed = true;
update_chat_full(chat_full, chat_id, "on_update_chat_edit_administrator");
return;
@ -12798,7 +12798,7 @@ void ContactsManager::on_update_chat_delete_user(ChatId chat_id, UserId user_id,
}
if (on_update_chat_full_participants_short(chat_full, chat_id, version)) {
for (size_t i = 0; i < chat_full->participants.size(); i++) {
if (chat_full->participants[i].dialog_id == DialogId(user_id)) {
if (chat_full->participants[i].dialog_id_ == DialogId(user_id)) {
chat_full->participants[i] = chat_full->participants.back();
chat_full->participants.resize(chat_full->participants.size() - 1);
chat_full->is_changed = true;
@ -13428,7 +13428,7 @@ void ContactsManager::on_update_bot_stopped(UserId user_id, int32 date, bool is_
DialogParticipant old_dialog_participant(DialogId(get_my_id()), user_id, date, DialogParticipantStatus::Banned(0));
DialogParticipant new_dialog_participant(DialogId(get_my_id()), user_id, date, DialogParticipantStatus::Member());
if (is_stopped) {
std::swap(old_dialog_participant.status, new_dialog_participant.status);
std::swap(old_dialog_participant.status_, new_dialog_participant.status_);
}
send_update_chat_member(DialogId(user_id), user_id, date, DialogInviteLink(), old_dialog_participant,
@ -13461,21 +13461,21 @@ void ContactsManager::on_update_chat_participant(ChatId chat_id, UserId user_id,
if (old_participant != nullptr) {
old_dialog_participant = DialogParticipant(std::move(old_participant), c->date, c->status.is_creator());
if (new_participant == nullptr) {
new_dialog_participant = DialogParticipant::left(old_dialog_participant.dialog_id);
new_dialog_participant = DialogParticipant::left(old_dialog_participant.dialog_id_);
} else {
new_dialog_participant = DialogParticipant(std::move(new_participant), c->date, c->status.is_creator());
}
} else {
new_dialog_participant = DialogParticipant(std::move(new_participant), c->date, c->status.is_creator());
old_dialog_participant = DialogParticipant::left(new_dialog_participant.dialog_id);
old_dialog_participant = DialogParticipant::left(new_dialog_participant.dialog_id_);
}
if (old_dialog_participant.dialog_id != new_dialog_participant.dialog_id || !old_dialog_participant.is_valid() ||
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_ || !old_dialog_participant.is_valid() ||
!new_dialog_participant.is_valid()) {
LOG(ERROR) << "Receive wrong updateChatParticipant: " << old_dialog_participant << " -> " << new_dialog_participant;
return;
}
if (new_dialog_participant.dialog_id == DialogId(get_my_id()) &&
new_dialog_participant.status != get_chat_status(chat_id) && false) {
if (new_dialog_participant.dialog_id_ == DialogId(get_my_id()) &&
new_dialog_participant.status_ != get_chat_status(chat_id) && false) {
LOG(ERROR) << "Have status " << get_chat_status(chat_id) << " after receiving updateChatParticipant in " << chat_id
<< " by " << user_id << " at " << date << " from " << old_dialog_participant << " to "
<< new_dialog_participant;
@ -13505,29 +13505,29 @@ void ContactsManager::on_update_channel_participant(ChannelId channel_id, UserId
if (old_participant != nullptr) {
old_dialog_participant = DialogParticipant(std::move(old_participant));
if (new_participant == nullptr) {
new_dialog_participant = DialogParticipant::left(old_dialog_participant.dialog_id);
new_dialog_participant = DialogParticipant::left(old_dialog_participant.dialog_id_);
} else {
new_dialog_participant = DialogParticipant(std::move(new_participant));
}
} else {
new_dialog_participant = DialogParticipant(std::move(new_participant));
old_dialog_participant = DialogParticipant::left(new_dialog_participant.dialog_id);
old_dialog_participant = DialogParticipant::left(new_dialog_participant.dialog_id_);
}
if (old_dialog_participant.dialog_id != new_dialog_participant.dialog_id || !old_dialog_participant.is_valid() ||
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_ || !old_dialog_participant.is_valid() ||
!new_dialog_participant.is_valid()) {
LOG(ERROR) << "Receive wrong updateChannelParticipant: " << old_dialog_participant << " -> "
<< new_dialog_participant;
return;
}
if (old_dialog_participant.dialog_id == DialogId(get_my_id()) && old_dialog_participant.status.is_administrator() &&
!new_dialog_participant.status.is_administrator()) {
if (old_dialog_participant.dialog_id_ == DialogId(get_my_id()) && old_dialog_participant.status_.is_administrator() &&
!new_dialog_participant.status_.is_administrator()) {
channel_participants_.erase(channel_id);
} else if (have_channel_participant_cache(channel_id)) {
add_channel_participant_to_cache(channel_id, new_dialog_participant, true);
}
if (new_dialog_participant.dialog_id == DialogId(get_my_id()) &&
new_dialog_participant.status != get_channel_status(channel_id) && false) {
if (new_dialog_participant.dialog_id_ == DialogId(get_my_id()) &&
new_dialog_participant.status_ != get_channel_status(channel_id) && false) {
LOG(ERROR) << "Have status " << get_channel_status(channel_id) << " after receiving updateChannelParticipant in "
<< channel_id << " by " << user_id << " at " << date << " from " << old_dialog_participant << " to "
<< new_dialog_participant;
@ -14757,7 +14757,7 @@ void ContactsManager::finish_get_dialog_participant(DialogParticipant &&dialog_p
Promise<td_api::object_ptr<td_api::chatMember>> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
auto participant_dialog_id = dialog_participant.dialog_id;
auto participant_dialog_id = dialog_participant.dialog_id_;
bool is_user = participant_dialog_id.get_type() == DialogType::User;
if ((is_user && !have_user(participant_dialog_id.get_user_id())) ||
(!is_user && !td_->messages_manager_->have_dialog(participant_dialog_id))) {
@ -14941,7 +14941,7 @@ void ContactsManager::do_search_chat_participants(ChatId chat_id, const string &
vector<DialogId> dialog_ids;
for (const auto &participant : chat_full->participants) {
if (filter.is_dialog_participant_suitable(td_, participant)) {
dialog_ids.push_back(participant.dialog_id);
dialog_ids.push_back(participant.dialog_id_);
}
}
@ -14983,9 +14983,9 @@ void ContactsManager::finish_get_channel_participant(ChannelId channel_id, Dialo
Promise<DialogParticipant> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
LOG(INFO) << "Receive a member " << dialog_participant.dialog_id << " of a channel " << channel_id;
LOG(INFO) << "Receive a member " << dialog_participant.dialog_id_ << " of a channel " << channel_id;
dialog_participant.status.update_restrictions();
dialog_participant.status_.update_restrictions();
if (have_channel_participant_cache(channel_id)) {
add_channel_participant_to_cache(channel_id, dialog_participant, false);
}

View File

@ -656,14 +656,14 @@ RestrictedRights get_restricted_rights(const td_api::object_ptr<td_api::chatPerm
DialogParticipant::DialogParticipant(DialogId dialog_id, UserId inviter_user_id, int32 joined_date,
DialogParticipantStatus status)
: dialog_id(dialog_id), inviter_user_id(inviter_user_id), joined_date(joined_date), status(std::move(status)) {
if (!inviter_user_id.is_valid() && inviter_user_id != UserId()) {
LOG(ERROR) << "Receive inviter " << inviter_user_id;
this->inviter_user_id = UserId();
: dialog_id_(dialog_id), inviter_user_id_(inviter_user_id), joined_date_(joined_date), status_(std::move(status)) {
if (!inviter_user_id_.is_valid() && inviter_user_id_ != UserId()) {
LOG(ERROR) << "Receive inviter " << inviter_user_id_;
inviter_user_id_ = UserId();
}
if (joined_date < 0) {
LOG(ERROR) << "Receive date " << joined_date;
this->joined_date = 0;
if (joined_date_ < 0) {
LOG(ERROR) << "Receive date " << joined_date_;
joined_date_ = 0;
}
}
@ -743,18 +743,18 @@ DialogParticipant::DialogParticipant(tl_object_ptr<telegram_api::ChannelParticip
}
bool DialogParticipant::is_valid() const {
if (!dialog_id.is_valid() || joined_date < 0) {
if (!dialog_id_.is_valid() || joined_date_ < 0) {
return false;
}
if (status.is_restricted() || status.is_banned() || (status.is_administrator() && !status.is_creator())) {
return inviter_user_id.is_valid();
if (status_.is_restricted() || status_.is_banned() || (status_.is_administrator() && !status_.is_creator())) {
return inviter_user_id_.is_valid();
}
return true;
}
StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant &dialog_participant) {
return string_builder << '[' << dialog_participant.dialog_id << " invited by " << dialog_participant.inviter_user_id
<< " at " << dialog_participant.joined_date << " with status " << dialog_participant.status
return string_builder << '[' << dialog_participant.dialog_id_ << " invited by " << dialog_participant.inviter_user_id_
<< " at " << dialog_participant.joined_date_ << " with status " << dialog_participant.status_
<< ']';
}
@ -979,21 +979,21 @@ bool DialogParticipantsFilter::is_dialog_participant_suitable(const Td *td,
const DialogParticipant &participant) const {
switch (type_) {
case Type::Contacts:
return participant.dialog_id.get_type() == DialogType::User &&
td->contacts_manager_->is_user_contact(participant.dialog_id.get_user_id());
return participant.dialog_id_.get_type() == DialogType::User &&
td->contacts_manager_->is_user_contact(participant.dialog_id_.get_user_id());
case Type::Administrators:
return participant.status.is_administrator();
return participant.status_.is_administrator();
case Type::Members:
return participant.status.is_member();
return participant.status_.is_member();
case Type::Restricted:
return participant.status.is_restricted();
return participant.status_.is_restricted();
case Type::Banned:
return participant.status.is_banned();
return participant.status_.is_banned();
case Type::Mention:
return true;
case Type::Bots:
return participant.dialog_id.get_type() == DialogType::User &&
td->contacts_manager_->is_user_bot(participant.dialog_id.get_user_id());
return participant.dialog_id_.get_type() == DialogType::User &&
td->contacts_manager_->is_user_bot(participant.dialog_id_.get_user_id());
default:
UNREACHABLE();
return false;

View File

@ -390,10 +390,10 @@ bool operator!=(const DialogParticipantStatus &lhs, const DialogParticipantStatu
StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipantStatus &status);
struct DialogParticipant {
DialogId dialog_id;
UserId inviter_user_id;
int32 joined_date = 0;
DialogParticipantStatus status = DialogParticipantStatus::Left();
DialogId dialog_id_;
UserId inviter_user_id_;
int32 joined_date_ = 0;
DialogParticipantStatus status_ = DialogParticipantStatus::Left();
DialogParticipant() = default;
@ -417,24 +417,24 @@ struct DialogParticipant {
template <class StorerT>
void store(StorerT &storer) const {
td::store(dialog_id, storer);
td::store(inviter_user_id, storer);
td::store(joined_date, storer);
td::store(status, storer);
td::store(dialog_id_, storer);
td::store(inviter_user_id_, storer);
td::store(joined_date_, storer);
td::store(status_, storer);
}
template <class ParserT>
void parse(ParserT &parser) {
if (parser.version() >= static_cast<int32>(Version::SupportBannedChannels)) {
td::parse(dialog_id, parser);
td::parse(dialog_id_, parser);
} else {
UserId user_id;
td::parse(user_id, parser);
dialog_id = DialogId(user_id);
dialog_id_ = DialogId(user_id);
}
td::parse(inviter_user_id, parser);
td::parse(joined_date, parser);
td::parse(status, parser);
td::parse(inviter_user_id_, parser);
td::parse(joined_date_, parser);
td::parse(status_, parser);
}
};

View File

@ -2702,9 +2702,9 @@ void GroupCallManager::finish_load_group_call_administrators(InputGroupCallId in
vector<DialogId> administrator_dialog_ids;
auto participants = result.move_as_ok();
for (auto &administrator : participants.participants_) {
if (administrator.status.can_manage_calls() &&
administrator.dialog_id != DialogId(td_->contacts_manager_->get_my_id())) {
administrator_dialog_ids.push_back(administrator.dialog_id);
if (administrator.status_.can_manage_calls() &&
administrator.dialog_id_ != DialogId(td_->contacts_manager_->get_my_id())) {
administrator_dialog_ids.push_back(administrator.dialog_id_);
}
}

View File

@ -31796,21 +31796,21 @@ tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_ob
case telegram_api::channelAdminLogEventActionParticipantInvite::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantInvite>(action_ptr);
DialogParticipant dialog_participant(std::move(action->participant_));
if (!dialog_participant.is_valid() || dialog_participant.dialog_id.get_type() != DialogType::User) {
if (!dialog_participant.is_valid() || dialog_participant.dialog_id_.get_type() != DialogType::User) {
LOG(ERROR) << "Wrong invite: " << dialog_participant;
return nullptr;
}
return make_tl_object<td_api::chatEventMemberInvited>(
td_->contacts_manager_->get_user_id_object(dialog_participant.dialog_id.get_user_id(),
td_->contacts_manager_->get_user_id_object(dialog_participant.dialog_id_.get_user_id(),
"chatEventMemberInvited"),
dialog_participant.status.get_chat_member_status_object());
dialog_participant.status_.get_chat_member_status_object());
}
case telegram_api::channelAdminLogEventActionParticipantToggleBan::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleBan>(action_ptr);
DialogParticipant old_dialog_participant(std::move(action->prev_participant_));
DialogParticipant new_dialog_participant(std::move(action->new_participant_));
if (old_dialog_participant.dialog_id != new_dialog_participant.dialog_id) {
LOG(ERROR) << old_dialog_participant.dialog_id << " VS " << new_dialog_participant.dialog_id;
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_) {
LOG(ERROR) << old_dialog_participant.dialog_id_ << " VS " << new_dialog_participant.dialog_id_;
return nullptr;
}
if (!old_dialog_participant.is_valid() || !new_dialog_participant.is_valid()) {
@ -31818,28 +31818,28 @@ tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_ob
return nullptr;
}
return make_tl_object<td_api::chatEventMemberRestricted>(
get_message_sender_object(old_dialog_participant.dialog_id, "chatEventMemberRestricted"),
old_dialog_participant.status.get_chat_member_status_object(),
new_dialog_participant.status.get_chat_member_status_object());
get_message_sender_object(old_dialog_participant.dialog_id_, "chatEventMemberRestricted"),
old_dialog_participant.status_.get_chat_member_status_object(),
new_dialog_participant.status_.get_chat_member_status_object());
}
case telegram_api::channelAdminLogEventActionParticipantToggleAdmin::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantToggleAdmin>(action_ptr);
DialogParticipant old_dialog_participant(std::move(action->prev_participant_));
DialogParticipant new_dialog_participant(std::move(action->new_participant_));
if (old_dialog_participant.dialog_id != new_dialog_participant.dialog_id) {
LOG(ERROR) << old_dialog_participant.dialog_id << " VS " << new_dialog_participant.dialog_id;
if (old_dialog_participant.dialog_id_ != new_dialog_participant.dialog_id_) {
LOG(ERROR) << old_dialog_participant.dialog_id_ << " VS " << new_dialog_participant.dialog_id_;
return nullptr;
}
if (!old_dialog_participant.is_valid() || !new_dialog_participant.is_valid() ||
old_dialog_participant.dialog_id.get_type() != DialogType::User) {
old_dialog_participant.dialog_id_.get_type() != DialogType::User) {
LOG(ERROR) << "Wrong edit administrator: " << old_dialog_participant << " -> " << new_dialog_participant;
return nullptr;
}
return make_tl_object<td_api::chatEventMemberPromoted>(
td_->contacts_manager_->get_user_id_object(old_dialog_participant.dialog_id.get_user_id(),
td_->contacts_manager_->get_user_id_object(old_dialog_participant.dialog_id_.get_user_id(),
"chatEventMemberPromoted"),
old_dialog_participant.status.get_chat_member_status_object(),
new_dialog_participant.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: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeTitle>(action_ptr);

View File

@ -96,8 +96,8 @@ void PhoneNumberManager::resend_authentication_code(uint64 query_id) {
start_net_query(NetQueryType::SendCode, G()->net_query_creator().create_unauth(r_resend_code.move_as_ok()));
}
void PhoneNumberManager::send_new_check_code_query(const telegram_api::Function &query) {
start_net_query(NetQueryType::CheckCode, G()->net_query_creator().create(query));
void PhoneNumberManager::send_new_check_code_query(const telegram_api::Function &check_code) {
start_net_query(NetQueryType::CheckCode, G()->net_query_creator().create(check_code));
}
void PhoneNumberManager::check_code(uint64 query_id, string code) {

View File

@ -56,9 +56,9 @@ class PhoneNumberManager final : public NetActor {
void start_net_query(NetQueryType net_query_type, NetQueryPtr net_query);
void send_new_send_code_query(uint64 query_id, const telegram_api::Function &query);
void send_new_send_code_query(uint64 query_id, const telegram_api::Function &send_code);
void send_new_check_code_query(const telegram_api::Function &query);
void send_new_check_code_query(const telegram_api::Function &check_code);
void process_check_code_result(Result<tl_object_ptr<telegram_api::User>> &&result);

View File

@ -135,7 +135,7 @@ class LambdaPromise : public PromiseInterface<ValueT> {
, on_fail_(use_ok_as_fail ? OnFail::Ok : OnFail::Fail)
, has_lambda_(true) {
}
template <class FromOkT>
template <class FromOkT, std::enable_if_t<!std::is_same<std::decay_t<FromOkT>, LambdaPromise>::value, int> = 0>
LambdaPromise(FromOkT &&ok) : LambdaPromise(std::forward<FromOkT>(ok), Ignore(), true) {
}
@ -307,7 +307,7 @@ class Promise {
}
Promise(SafePromise<T> &&other);
Promise &operator=(SafePromise<T> &&other);
template <class F>
template <class F, std::enable_if_t<!std::is_same<std::decay_t<F>, Promise>::value, int> = 0>
Promise(F &&f) : promise_(promise_interface_ptr<T>(std::forward<F>(f))) {
}

View File

@ -97,7 +97,7 @@ class LambdaEvent final : public CustomEvent {
LOG(FATAL) << "Not supported";
return nullptr;
}
template <class FromLambdaT>
template <class FromLambdaT, std::enable_if_t<!std::is_same<std::decay_t<FromLambdaT>, LambdaEvent>::value, int> = 0>
explicit LambdaEvent(FromLambdaT &&lambda) : f_(std::forward<FromLambdaT>(lambda)) {
}

View File

@ -31,6 +31,9 @@ class optional {
}
optional &operator=(const optional &other) {
if (this == &other) {
return *this;
}
if (other) {
impl_ = Result<T>(other.value());
} else {