Add DialogFilterInviteLink::is_valid_invite_link.

This commit is contained in:
levlam 2023-03-31 12:57:58 +03:00
parent 6e139200eb
commit 725c7ba5d1
2 changed files with 8 additions and 0 deletions

View File

@ -6,6 +6,7 @@
//
#include "td/telegram/DialogFilterInviteLink.h"
#include "td/telegram/LinkManager.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h"
@ -14,6 +15,7 @@ namespace td {
DialogFilterInviteLink::DialogFilterInviteLink(
Td *td, telegram_api::object_ptr<telegram_api::exportedChatlistInvite> exported_invite) {
CHECK(exported_invite != nullptr);
LOG_IF(ERROR, !is_valid_invite_link(exported_invite->url_)) << "Unsupported " << to_string(exported_invite);
invite_link_ = std::move(exported_invite->url_);
title_ = std::move(exported_invite->title_);
for (const auto &peer : exported_invite->peers_) {
@ -30,6 +32,10 @@ td_api::object_ptr<td_api::chatFilterInviteLink> DialogFilterInviteLink::get_cha
invite_link_, title_, transform(dialog_ids_, [](DialogId dialog_id) { return dialog_id.get(); }));
}
bool DialogFilterInviteLink::is_valid_invite_link(Slice invite_link) {
return !LinkManager::get_dialog_filter_invite_link_slug(invite_link).empty();
}
bool operator==(const DialogFilterInviteLink &lhs, const DialogFilterInviteLink &rhs) {
return lhs.invite_link_ == rhs.invite_link_ && lhs.title_ == rhs.title_ && lhs.dialog_ids_ == rhs.dialog_ids_;
}

View File

@ -38,6 +38,8 @@ class DialogFilterInviteLink {
bool is_valid() const {
return !invite_link_.empty();
}
static bool is_valid_invite_link(Slice invite_link);
};
bool operator==(const DialogFilterInviteLink &lhs, const DialogFilterInviteLink &rhs);