Allow truncated links in updates and event log.
This commit is contained in:
parent
3dce19ca2b
commit
dff135fa6c
@ -1972,7 +1972,7 @@ class ExportChatInviteQuery final : public Td::ResultHandler {
|
|||||||
auto ptr = result_ptr.move_as_ok();
|
auto ptr = result_ptr.move_as_ok();
|
||||||
LOG(INFO) << "Receive result for ExportChatInviteQuery: " << to_string(ptr);
|
LOG(INFO) << "Receive result for ExportChatInviteQuery: " << to_string(ptr);
|
||||||
|
|
||||||
DialogInviteLink invite_link(std::move(ptr), "ExportChatInviteQuery");
|
DialogInviteLink invite_link(std::move(ptr), false, "ExportChatInviteQuery");
|
||||||
if (!invite_link.is_valid()) {
|
if (!invite_link.is_valid()) {
|
||||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||||
}
|
}
|
||||||
@ -2034,7 +2034,7 @@ class EditChatInviteLinkQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
td_->contacts_manager_->on_get_users(std::move(invite->users_), "EditChatInviteLinkQuery");
|
td_->contacts_manager_->on_get_users(std::move(invite->users_), "EditChatInviteLinkQuery");
|
||||||
|
|
||||||
DialogInviteLink invite_link(std::move(invite->invite_), "EditChatInviteLinkQuery");
|
DialogInviteLink invite_link(std::move(invite->invite_), false, "EditChatInviteLinkQuery");
|
||||||
if (!invite_link.is_valid()) {
|
if (!invite_link.is_valid()) {
|
||||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||||
}
|
}
|
||||||
@ -2083,7 +2083,7 @@ class GetExportedChatInviteQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetExportedChatInviteQuery");
|
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetExportedChatInviteQuery");
|
||||||
|
|
||||||
DialogInviteLink invite_link(std::move(result->invite_), "GetExportedChatInviteQuery");
|
DialogInviteLink invite_link(std::move(result->invite_), false, "GetExportedChatInviteQuery");
|
||||||
if (!invite_link.is_valid()) {
|
if (!invite_link.is_valid()) {
|
||||||
LOG(ERROR) << "Receive invalid invite link in " << dialog_id_;
|
LOG(ERROR) << "Receive invalid invite link in " << dialog_id_;
|
||||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||||
@ -2145,7 +2145,7 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
vector<td_api::object_ptr<td_api::chatInviteLink>> invite_links;
|
vector<td_api::object_ptr<td_api::chatInviteLink>> invite_links;
|
||||||
for (auto &invite : result->invites_) {
|
for (auto &invite : result->invites_) {
|
||||||
DialogInviteLink invite_link(std::move(invite), "GetExportedChatInvitesQuery");
|
DialogInviteLink invite_link(std::move(invite), false, "GetExportedChatInvitesQuery");
|
||||||
if (!invite_link.is_valid()) {
|
if (!invite_link.is_valid()) {
|
||||||
LOG(ERROR) << "Receive invalid invite link in " << dialog_id_;
|
LOG(ERROR) << "Receive invalid invite link in " << dialog_id_;
|
||||||
total_count--;
|
total_count--;
|
||||||
@ -2486,7 +2486,7 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery");
|
td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery");
|
||||||
|
|
||||||
DialogInviteLink invite_link(std::move(invite->invite_), "RevokeChatInviteLinkQuery");
|
DialogInviteLink invite_link(std::move(invite->invite_), false, "RevokeChatInviteLinkQuery");
|
||||||
if (!invite_link.is_valid()) {
|
if (!invite_link.is_valid()) {
|
||||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||||
}
|
}
|
||||||
@ -2498,8 +2498,9 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery replaced");
|
td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery replaced");
|
||||||
|
|
||||||
DialogInviteLink invite_link(std::move(invite->invite_), "RevokeChatInviteLinkQuery replaced");
|
DialogInviteLink invite_link(std::move(invite->invite_), false, "RevokeChatInviteLinkQuery replaced");
|
||||||
DialogInviteLink new_invite_link(std::move(invite->new_invite_), "RevokeChatInviteLinkQuery new replaced");
|
DialogInviteLink new_invite_link(std::move(invite->new_invite_), false,
|
||||||
|
"RevokeChatInviteLinkQuery new replaced");
|
||||||
if (!invite_link.is_valid() || !new_invite_link.is_valid()) {
|
if (!invite_link.is_valid() || !new_invite_link.is_valid()) {
|
||||||
return on_error(Status::Error(500, "Receive invalid invite link"));
|
return on_error(Status::Error(500, "Receive invalid invite link"));
|
||||||
}
|
}
|
||||||
@ -14304,7 +14305,8 @@ void ContactsManager::on_get_permanent_dialog_invite_link(DialogId dialog_id, co
|
|||||||
void ContactsManager::on_update_chat_full_invite_link(ChatFull *chat_full,
|
void ContactsManager::on_update_chat_full_invite_link(ChatFull *chat_full,
|
||||||
tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link) {
|
tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link) {
|
||||||
CHECK(chat_full != nullptr);
|
CHECK(chat_full != nullptr);
|
||||||
if (update_permanent_invite_link(chat_full->invite_link, DialogInviteLink(std::move(invite_link), "ChatFull"))) {
|
if (update_permanent_invite_link(chat_full->invite_link,
|
||||||
|
DialogInviteLink(std::move(invite_link), false, "ChatFull"))) {
|
||||||
chat_full->is_changed = true;
|
chat_full->is_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14313,7 +14315,7 @@ void ContactsManager::on_update_channel_full_invite_link(
|
|||||||
ChannelFull *channel_full, tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link) {
|
ChannelFull *channel_full, tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link) {
|
||||||
CHECK(channel_full != nullptr);
|
CHECK(channel_full != nullptr);
|
||||||
if (update_permanent_invite_link(channel_full->invite_link,
|
if (update_permanent_invite_link(channel_full->invite_link,
|
||||||
DialogInviteLink(std::move(invite_link), "ChannelFull"))) {
|
DialogInviteLink(std::move(invite_link), false, "ChannelFull"))) {
|
||||||
channel_full->is_changed = true;
|
channel_full->is_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,8 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
|||||||
return td_api::make_object<td_api::chatEventMemberJoined>();
|
return td_api::make_object<td_api::chatEventMemberJoined>();
|
||||||
case telegram_api::channelAdminLogEventActionParticipantJoinByInvite::ID: {
|
case telegram_api::channelAdminLogEventActionParticipantJoinByInvite::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByInvite>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByInvite>(action_ptr);
|
||||||
DialogInviteLink invite_link(std::move(action->invite_), "channelAdminLogEventActionParticipantJoinByInvite");
|
DialogInviteLink invite_link(std::move(action->invite_), true,
|
||||||
|
"channelAdminLogEventActionParticipantJoinByInvite");
|
||||||
if (!invite_link.is_valid()) {
|
if (!invite_link.is_valid()) {
|
||||||
LOG(ERROR) << "Wrong invite link: " << invite_link;
|
LOG(ERROR) << "Wrong invite link: " << invite_link;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -51,7 +52,8 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
|||||||
}
|
}
|
||||||
case telegram_api::channelAdminLogEventActionParticipantJoinByRequest::ID: {
|
case telegram_api::channelAdminLogEventActionParticipantJoinByRequest::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByRequest>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionParticipantJoinByRequest>(action_ptr);
|
||||||
DialogInviteLink invite_link(std::move(action->invite_), "channelAdminLogEventActionParticipantJoinByRequest");
|
DialogInviteLink invite_link(std::move(action->invite_), true,
|
||||||
|
"channelAdminLogEventActionParticipantJoinByRequest");
|
||||||
UserId approver_user_id(action->approved_by_);
|
UserId approver_user_id(action->approved_by_);
|
||||||
if (!approver_user_id.is_valid()) {
|
if (!approver_user_id.is_valid()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -259,8 +261,10 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
|||||||
}
|
}
|
||||||
case telegram_api::channelAdminLogEventActionExportedInviteEdit::ID: {
|
case telegram_api::channelAdminLogEventActionExportedInviteEdit::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteEdit>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteEdit>(action_ptr);
|
||||||
DialogInviteLink old_invite_link(std::move(action->prev_invite_), "channelAdminLogEventActionExportedInviteEdit");
|
DialogInviteLink old_invite_link(std::move(action->prev_invite_), true,
|
||||||
DialogInviteLink new_invite_link(std::move(action->new_invite_), "channelAdminLogEventActionExportedInviteEdit");
|
"channelAdminLogEventActionExportedInviteEdit");
|
||||||
|
DialogInviteLink new_invite_link(std::move(action->new_invite_), true,
|
||||||
|
"channelAdminLogEventActionExportedInviteEdit");
|
||||||
if (!old_invite_link.is_valid() || !new_invite_link.is_valid()) {
|
if (!old_invite_link.is_valid() || !new_invite_link.is_valid()) {
|
||||||
LOG(ERROR) << "Wrong edited invite link: " << old_invite_link << " -> " << new_invite_link;
|
LOG(ERROR) << "Wrong edited invite link: " << old_invite_link << " -> " << new_invite_link;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -271,7 +275,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
|||||||
}
|
}
|
||||||
case telegram_api::channelAdminLogEventActionExportedInviteRevoke::ID: {
|
case telegram_api::channelAdminLogEventActionExportedInviteRevoke::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteRevoke>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteRevoke>(action_ptr);
|
||||||
DialogInviteLink invite_link(std::move(action->invite_), "channelAdminLogEventActionExportedInviteRevoke");
|
DialogInviteLink invite_link(std::move(action->invite_), true, "channelAdminLogEventActionExportedInviteRevoke");
|
||||||
if (!invite_link.is_valid()) {
|
if (!invite_link.is_valid()) {
|
||||||
LOG(ERROR) << "Wrong revoked invite link: " << invite_link;
|
LOG(ERROR) << "Wrong revoked invite link: " << invite_link;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -281,7 +285,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
|||||||
}
|
}
|
||||||
case telegram_api::channelAdminLogEventActionExportedInviteDelete::ID: {
|
case telegram_api::channelAdminLogEventActionExportedInviteDelete::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteDelete>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionExportedInviteDelete>(action_ptr);
|
||||||
DialogInviteLink invite_link(std::move(action->invite_), "channelAdminLogEventActionExportedInviteDelete");
|
DialogInviteLink invite_link(std::move(action->invite_), true, "channelAdminLogEventActionExportedInviteDelete");
|
||||||
if (!invite_link.is_valid()) {
|
if (!invite_link.is_valid()) {
|
||||||
LOG(ERROR) << "Wrong deleted invite link: " << invite_link;
|
LOG(ERROR) << "Wrong deleted invite link: " << invite_link;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
namespace td {
|
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) {
|
bool allow_truncated, const char *source) {
|
||||||
if (exported_invite_ptr == nullptr) {
|
if (exported_invite_ptr == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvit
|
|||||||
is_permanent_ = exported_invite->permanent_;
|
is_permanent_ = exported_invite->permanent_;
|
||||||
|
|
||||||
string full_source = PSTRING() << "invite link " << invite_link_ << " from " << source;
|
string full_source = PSTRING() << "invite link " << invite_link_ << " from " << source;
|
||||||
LOG_IF(ERROR, !is_valid_invite_link(invite_link_)) << "Unsupported " << full_source;
|
LOG_IF(ERROR, !is_valid_invite_link(invite_link_, allow_truncated)) << "Unsupported " << full_source;
|
||||||
if (!creator_user_id_.is_valid()) {
|
if (!creator_user_id_.is_valid()) {
|
||||||
LOG(ERROR) << "Receive invalid " << creator_user_id_ << " as creator of " << full_source;
|
LOG(ERROR) << "Receive invalid " << creator_user_id_ << " as creator of " << full_source;
|
||||||
creator_user_id_ = UserId();
|
creator_user_id_ = UserId();
|
||||||
@ -90,7 +90,10 @@ DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogInviteLink::is_valid_invite_link(Slice invite_link) {
|
bool DialogInviteLink::is_valid_invite_link(Slice invite_link, bool allow_truncated) {
|
||||||
|
if (allow_truncated && ends_with(invite_link, "...")) {
|
||||||
|
invite_link.remove_suffix(3);
|
||||||
|
}
|
||||||
return !LinkManager::get_dialog_invite_link_hash(invite_link).empty();
|
return !LinkManager::get_dialog_invite_link_hash(invite_link).empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,10 @@ class DialogInviteLink {
|
|||||||
public:
|
public:
|
||||||
DialogInviteLink() = default;
|
DialogInviteLink() = default;
|
||||||
|
|
||||||
DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvite> exported_invite_ptr, const char *source);
|
DialogInviteLink(tl_object_ptr<telegram_api::ExportedChatInvite> exported_invite_ptr, bool allow_truncated,
|
||||||
|
const char *source);
|
||||||
|
|
||||||
static bool is_valid_invite_link(Slice invite_link);
|
static bool is_valid_invite_link(Slice invite_link, bool allow_truncated = false);
|
||||||
|
|
||||||
td_api::object_ptr<td_api::chatInviteLink> get_chat_invite_link_object(const ContactsManager *contacts_manager) const;
|
td_api::object_ptr<td_api::chatInviteLink> get_chat_invite_link_object(const ContactsManager *contacts_manager) const;
|
||||||
|
|
||||||
|
@ -1824,7 +1824,7 @@ Result<string> LinkManager::get_internal_link_impl(const td_api::InternalLinkTyp
|
|||||||
return "tg://settings/change_number";
|
return "tg://settings/change_number";
|
||||||
case td_api::internalLinkTypeChatInvite::ID: {
|
case td_api::internalLinkTypeChatInvite::ID: {
|
||||||
auto link = static_cast<const td_api::internalLinkTypeChatInvite *>(type_ptr);
|
auto link = static_cast<const td_api::internalLinkTypeChatInvite *>(type_ptr);
|
||||||
auto invite_hash = url_encode(get_dialog_invite_link_hash(link->invite_link_));
|
auto invite_hash = get_dialog_invite_link_hash(link->invite_link_);
|
||||||
if (invite_hash.empty()) {
|
if (invite_hash.empty()) {
|
||||||
return Status::Error(400, "Invalid invite link specified");
|
return Status::Error(400, "Invalid invite link specified");
|
||||||
}
|
}
|
||||||
|
@ -2639,8 +2639,8 @@ void UpdatesManager::process_qts_update(tl_object_ptr<telegram_api::Update> &&up
|
|||||||
auto update = move_tl_object_as<telegram_api::updateChatParticipant>(update_ptr);
|
auto update = move_tl_object_as<telegram_api::updateChatParticipant>(update_ptr);
|
||||||
td_->contacts_manager_->on_update_chat_participant(
|
td_->contacts_manager_->on_update_chat_participant(
|
||||||
ChatId(update->chat_id_), UserId(update->actor_id_), update->date_,
|
ChatId(update->chat_id_), UserId(update->actor_id_), update->date_,
|
||||||
DialogInviteLink(std::move(update->invite_), "updateChatParticipant"), std::move(update->prev_participant_),
|
DialogInviteLink(std::move(update->invite_), true, "updateChatParticipant"),
|
||||||
std::move(update->new_participant_));
|
std::move(update->prev_participant_), std::move(update->new_participant_));
|
||||||
add_qts(qts).set_value(Unit());
|
add_qts(qts).set_value(Unit());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2648,7 +2648,7 @@ void UpdatesManager::process_qts_update(tl_object_ptr<telegram_api::Update> &&up
|
|||||||
auto update = move_tl_object_as<telegram_api::updateChannelParticipant>(update_ptr);
|
auto update = move_tl_object_as<telegram_api::updateChannelParticipant>(update_ptr);
|
||||||
td_->contacts_manager_->on_update_channel_participant(
|
td_->contacts_manager_->on_update_channel_participant(
|
||||||
ChannelId(update->channel_id_), UserId(update->actor_id_), update->date_,
|
ChannelId(update->channel_id_), UserId(update->actor_id_), update->date_,
|
||||||
DialogInviteLink(std::move(update->invite_), "updateChannelParticipant"),
|
DialogInviteLink(std::move(update->invite_), true, "updateChannelParticipant"),
|
||||||
std::move(update->prev_participant_), std::move(update->new_participant_));
|
std::move(update->prev_participant_), std::move(update->new_participant_));
|
||||||
add_qts(qts).set_value(Unit());
|
add_qts(qts).set_value(Unit());
|
||||||
break;
|
break;
|
||||||
@ -2657,7 +2657,7 @@ void UpdatesManager::process_qts_update(tl_object_ptr<telegram_api::Update> &&up
|
|||||||
auto update = move_tl_object_as<telegram_api::updateBotChatInviteRequester>(update_ptr);
|
auto update = move_tl_object_as<telegram_api::updateBotChatInviteRequester>(update_ptr);
|
||||||
td_->contacts_manager_->on_update_chat_invite_requester(
|
td_->contacts_manager_->on_update_chat_invite_requester(
|
||||||
DialogId(update->peer_), UserId(update->user_id_), std::move(update->about_), update->date_,
|
DialogId(update->peer_), UserId(update->user_id_), std::move(update->about_), update->date_,
|
||||||
DialogInviteLink(std::move(update->invite_), "updateBotChatInviteRequester"));
|
DialogInviteLink(std::move(update->invite_), true, "updateBotChatInviteRequester"));
|
||||||
add_qts(qts).set_value(Unit());
|
add_qts(qts).set_value(Unit());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user