Add source to DialogInviteLink constructor.
This commit is contained in:
parent
f443cec9bc
commit
59e926350e
@ -1420,7 +1420,7 @@ class ExportChatInviteQuery final : public Td::ResultHandler {
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for ExportChatInviteQuery: " << to_string(ptr);
|
||||
|
||||
DialogInviteLink invite_link(std::move(ptr));
|
||||
DialogInviteLink invite_link(std::move(ptr), "ExportChatInviteQuery");
|
||||
if (!invite_link.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
@ -1482,7 +1482,7 @@ class EditChatInviteLinkQuery final : public Td::ResultHandler {
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(invite->users_), "EditChatInviteLinkQuery");
|
||||
|
||||
DialogInviteLink invite_link(std::move(invite->invite_));
|
||||
DialogInviteLink invite_link(std::move(invite->invite_), "EditChatInviteLinkQuery");
|
||||
if (!invite_link.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
@ -1531,7 +1531,7 @@ class GetExportedChatInviteQuery final : public Td::ResultHandler {
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetExportedChatInviteQuery");
|
||||
|
||||
DialogInviteLink invite_link(std::move(result->invite_));
|
||||
DialogInviteLink invite_link(std::move(result->invite_), "GetExportedChatInviteQuery");
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid invite link in " << dialog_id_;
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
@ -1593,7 +1593,7 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler {
|
||||
}
|
||||
vector<td_api::object_ptr<td_api::chatInviteLink>> invite_links;
|
||||
for (auto &invite : result->invites_) {
|
||||
DialogInviteLink invite_link(std::move(invite));
|
||||
DialogInviteLink invite_link(std::move(invite), "GetExportedChatInvitesQuery");
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid invite link in " << dialog_id_;
|
||||
total_count--;
|
||||
@ -1934,7 +1934,7 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery");
|
||||
|
||||
DialogInviteLink invite_link(std::move(invite->invite_));
|
||||
DialogInviteLink invite_link(std::move(invite->invite_), "RevokeChatInviteLinkQuery");
|
||||
if (!invite_link.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
@ -1946,8 +1946,8 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery replaced");
|
||||
|
||||
DialogInviteLink invite_link(std::move(invite->invite_));
|
||||
DialogInviteLink new_invite_link(std::move(invite->new_invite_));
|
||||
DialogInviteLink invite_link(std::move(invite->invite_), "RevokeChatInviteLinkQuery replaced");
|
||||
DialogInviteLink new_invite_link(std::move(invite->new_invite_), "RevokeChatInviteLinkQuery new replaced");
|
||||
if (!invite_link.is_valid() || !new_invite_link.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
@ -12945,7 +12945,7 @@ void ContactsManager::on_get_permanent_dialog_invite_link(DialogId dialog_id, co
|
||||
void ContactsManager::on_update_chat_full_invite_link(ChatFull *chat_full,
|
||||
tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link) {
|
||||
CHECK(chat_full != nullptr);
|
||||
if (update_permanent_invite_link(chat_full->invite_link, DialogInviteLink(std::move(invite_link)))) {
|
||||
if (update_permanent_invite_link(chat_full->invite_link, DialogInviteLink(std::move(invite_link), "ChatFull"))) {
|
||||
chat_full->is_changed = true;
|
||||
}
|
||||
}
|
||||
@ -12953,7 +12953,8 @@ void ContactsManager::on_update_chat_full_invite_link(ChatFull *chat_full,
|
||||
void ContactsManager::on_update_channel_full_invite_link(
|
||||
ChannelFull *channel_full, tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link) {
|
||||
CHECK(channel_full != nullptr);
|
||||
if (update_permanent_invite_link(channel_full->invite_link, DialogInviteLink(std::move(invite_link)))) {
|
||||
if (update_permanent_invite_link(channel_full->invite_link,
|
||||
DialogInviteLink(std::move(invite_link), "ChannelFull"))) {
|
||||
channel_full->is_changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
return td_api::make_object<td_api::chatEventMemberJoined>();
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoinByInvite::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByInvite>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
DialogInviteLink invite_link(std::move(action->invite_), "channelAdminLogEventActionParticipantJoinByInvite");
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong invite link: " << invite_link;
|
||||
return nullptr;
|
||||
@ -49,7 +49,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionParticipantJoinByRequest::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByRequest>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
DialogInviteLink invite_link(std::move(action->invite_), "channelAdminLogEventActionParticipantJoinByRequest");
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong invite link: " << invite_link;
|
||||
return nullptr;
|
||||
@ -257,8 +257,8 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteEdit::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteEdit>(action_ptr);
|
||||
DialogInviteLink old_invite_link(std::move(action->prev_invite_));
|
||||
DialogInviteLink new_invite_link(std::move(action->new_invite_));
|
||||
DialogInviteLink old_invite_link(std::move(action->prev_invite_), "channelAdminLogEventActionExportedInviteEdit");
|
||||
DialogInviteLink new_invite_link(std::move(action->new_invite_), "channelAdminLogEventActionExportedInviteEdit");
|
||||
if (!old_invite_link.is_valid() || !new_invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong edited invite link: " << old_invite_link << " -> " << new_invite_link;
|
||||
return nullptr;
|
||||
@ -269,7 +269,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteRevoke::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteRevoke>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
DialogInviteLink invite_link(std::move(action->invite_), "channelAdminLogEventActionExportedInviteRevoke");
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong revoked invite link: " << invite_link;
|
||||
return nullptr;
|
||||
@ -279,7 +279,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionExportedInviteDelete::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteDelete>(action_ptr);
|
||||
DialogInviteLink invite_link(std::move(action->invite_));
|
||||
DialogInviteLink invite_link(std::move(action->invite_), "channelAdminLogEventActionExportedInviteDelete");
|
||||
if (!invite_link.is_valid()) {
|
||||
LOG(ERROR) << "Wrong deleted invite link: " << invite_link;
|
||||
return nullptr;
|
||||
|
@ -13,12 +13,13 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvite> exported_invite_ptr) {
|
||||
DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvite> exported_invite_ptr,
|
||||
const char *source) {
|
||||
if (exported_invite_ptr == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (exported_invite_ptr->get_id() != telegram_api::chatInviteExported::ID) {
|
||||
LOG(ERROR) << "Receive " << to_string(exported_invite_ptr);
|
||||
LOG(ERROR) << "Receive from " << source << ' ' << to_string(exported_invite_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -36,39 +37,40 @@ DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvit
|
||||
is_revoked_ = exported_invite->revoked_;
|
||||
is_permanent_ = exported_invite->permanent_;
|
||||
|
||||
LOG_IF(ERROR, !is_valid_invite_link(invite_link_)) << "Unsupported invite link " << invite_link_;
|
||||
string full_source = PSTRING() << "invite link " << invite_link_ << " from " << source;
|
||||
LOG_IF(ERROR, !is_valid_invite_link(invite_link_)) << "Unsupported " << full_source;
|
||||
if (!creator_user_id_.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << creator_user_id_ << " as creator of a link " << invite_link_;
|
||||
LOG(ERROR) << "Receive invalid " << creator_user_id_ << " as creator of " << full_source;
|
||||
creator_user_id_ = UserId();
|
||||
}
|
||||
if (date_ != 0 && date_ < 1000000000) {
|
||||
LOG(ERROR) << "Receive wrong date " << date_ << " as a creation date of a link " << invite_link_;
|
||||
LOG(ERROR) << "Receive wrong date " << date_ << " as a creation date of " << full_source;
|
||||
date_ = 0;
|
||||
}
|
||||
if (expire_date_ != 0 && expire_date_ < 1000000000) {
|
||||
LOG(ERROR) << "Receive wrong date " << expire_date_ << " as an expire date of a link " << invite_link_;
|
||||
LOG(ERROR) << "Receive wrong date " << expire_date_ << " as an expire date of " << full_source;
|
||||
expire_date_ = 0;
|
||||
}
|
||||
if (usage_limit_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong usage limit " << usage_limit_ << " for a link " << invite_link_;
|
||||
LOG(ERROR) << "Receive wrong usage limit " << usage_limit_ << " for " << full_source;
|
||||
usage_limit_ = 0;
|
||||
}
|
||||
if (usage_count_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong usage count " << usage_count_ << " for a link " << invite_link_;
|
||||
LOG(ERROR) << "Receive wrong usage count " << usage_count_ << " for " << full_source;
|
||||
usage_count_ = 0;
|
||||
}
|
||||
if (edit_date_ != 0 && edit_date_ < 1000000000) {
|
||||
LOG(ERROR) << "Receive wrong date " << edit_date_ << " as an edit date of a link " << invite_link_;
|
||||
LOG(ERROR) << "Receive wrong date " << edit_date_ << " as an edit date of " << full_source;
|
||||
edit_date_ = 0;
|
||||
}
|
||||
if (request_count_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong pending join request count " << request_count_ << " for a link " << invite_link_;
|
||||
LOG(ERROR) << "Receive wrong pending join request count " << request_count_ << " for " << full_source;
|
||||
request_count_ = 0;
|
||||
}
|
||||
|
||||
if (is_permanent_ && (!title_.empty() || expire_date_ > 0 || usage_limit_ > 0 || edit_date_ > 0 ||
|
||||
request_count_ > 0 || creates_join_request_)) {
|
||||
LOG(ERROR) << "Receive wrong permanent " << *this;
|
||||
LOG(ERROR) << "Receive wrong permanent " << full_source << ' ' << *this;
|
||||
title_.clear();
|
||||
expire_date_ = 0;
|
||||
usage_limit_ = 0;
|
||||
@ -77,7 +79,7 @@ DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvit
|
||||
creates_join_request_ = false;
|
||||
}
|
||||
if (creates_join_request_ && usage_limit_ > 0) {
|
||||
LOG(ERROR) << "Receive wrong permanent " << *this;
|
||||
LOG(ERROR) << "Receive wrong permanent " << full_source << ' ' << *this;
|
||||
usage_limit_ = 0;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class DialogInviteLink {
|
||||
public:
|
||||
DialogInviteLink() = default;
|
||||
|
||||
explicit DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvite> exported_invite_ptr);
|
||||
DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvite> exported_invite_ptr, const char *source);
|
||||
|
||||
static bool is_valid_invite_link(Slice invite_link);
|
||||
|
||||
|
@ -2282,27 +2282,27 @@ void UpdatesManager::process_qts_update(tl_object_ptr<telegram_api::Update> &&up
|
||||
}
|
||||
case telegram_api::updateChatParticipant::ID: {
|
||||
auto update = move_tl_object_as<telegram_api::updateChatParticipant>(update_ptr);
|
||||
td_->contacts_manager_->on_update_chat_participant(ChatId(update->chat_id_), UserId(update->actor_id_),
|
||||
update->date_, DialogInviteLink(std::move(update->invite_)),
|
||||
std::move(update->prev_participant_),
|
||||
std::move(update->new_participant_));
|
||||
td_->contacts_manager_->on_update_chat_participant(
|
||||
ChatId(update->chat_id_), UserId(update->actor_id_), update->date_,
|
||||
DialogInviteLink(std::move(update->invite_), "updateChatParticipant"), std::move(update->prev_participant_),
|
||||
std::move(update->new_participant_));
|
||||
add_qts(qts).set_value(Unit());
|
||||
break;
|
||||
}
|
||||
case telegram_api::updateChannelParticipant::ID: {
|
||||
auto update = move_tl_object_as<telegram_api::updateChannelParticipant>(update_ptr);
|
||||
td_->contacts_manager_->on_update_channel_participant(ChannelId(update->channel_id_), UserId(update->actor_id_),
|
||||
update->date_, DialogInviteLink(std::move(update->invite_)),
|
||||
std::move(update->prev_participant_),
|
||||
std::move(update->new_participant_));
|
||||
td_->contacts_manager_->on_update_channel_participant(
|
||||
ChannelId(update->channel_id_), UserId(update->actor_id_), update->date_,
|
||||
DialogInviteLink(std::move(update->invite_), "updateChannelParticipant"),
|
||||
std::move(update->prev_participant_), std::move(update->new_participant_));
|
||||
add_qts(qts).set_value(Unit());
|
||||
break;
|
||||
}
|
||||
case telegram_api::updateBotChatInviteRequester::ID: {
|
||||
auto update = move_tl_object_as<telegram_api::updateBotChatInviteRequester>(update_ptr);
|
||||
td_->contacts_manager_->on_update_chat_invite_requester(DialogId(update->peer_), UserId(update->user_id_),
|
||||
std::move(update->about_), update->date_,
|
||||
DialogInviteLink(std::move(update->invite_)));
|
||||
td_->contacts_manager_->on_update_chat_invite_requester(
|
||||
DialogId(update->peer_), UserId(update->user_id_), std::move(update->about_), update->date_,
|
||||
DialogInviteLink(std::move(update->invite_), "updateBotChatInviteRequester"));
|
||||
add_qts(qts).set_value(Unit());
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user