Check invite link validness.
This commit is contained in:
parent
b5cd03365d
commit
3df10dc103
|
@ -1572,6 +1572,12 @@ class ExportChatInviteLinkQuery : public Td::ResultHandler {
|
|||
LOG(INFO) << "Receive result for ExportChatInviteQuery: " << to_string(ptr);
|
||||
|
||||
DialogInviteLink invite_link(std::move(ptr));
|
||||
if (!invite_link.is_valid()) {
|
||||
return on_error(id, Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
if (invite_link.get_administrator_user_id() != td->contacts_manager_->get_my_id()) {
|
||||
return on_error(id, Status::Error(500, "Receive invalid invite link creator"));
|
||||
}
|
||||
promise_.set_value(invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
}
|
||||
|
||||
|
@ -1623,6 +1629,9 @@ class EditChatInviteLinkQuery : public Td::ResultHandler {
|
|||
td->contacts_manager_->on_get_users(std::move(result->users_), "EditChatInviteLinkQuery");
|
||||
|
||||
DialogInviteLink invite_link(std::move(result->invite_));
|
||||
if (!invite_link.is_valid()) {
|
||||
return on_error(id, Status::Error(500, "Receive invalid invite link"));
|
||||
}
|
||||
promise_.set_value(invite_link.get_chat_invite_link_object(td->contacts_manager_.get()));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,24 @@ DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::chatInviteExporte
|
|||
}
|
||||
if ((exported_invite->flags_ & telegram_api::chatInviteExported::EXPIRE_DATE_MASK) != 0) {
|
||||
expire_date_ = exported_invite->expire_date_;
|
||||
if (expire_date_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong date " << expire_date_ << " as expire date of a link " << invite_link_;
|
||||
expire_date_ = 0;
|
||||
}
|
||||
}
|
||||
if ((exported_invite->flags_ & telegram_api::chatInviteExported::USAGE_LIMIT_MASK) != 0) {
|
||||
usage_limit_ = exported_invite->usage_limit_;
|
||||
if (usage_limit_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong usage limit " << usage_limit_ << " for a link " << invite_link_;
|
||||
usage_limit_ = 0;
|
||||
}
|
||||
}
|
||||
if ((exported_invite->flags_ & telegram_api::chatInviteExported::USAGE_MASK) != 0) {
|
||||
usage_count_ = exported_invite->usage_;
|
||||
if (usage_count_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong usage count " << usage_count_ << " for a link " << invite_link_;
|
||||
usage_count_ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user