Add chatInviteLink.title.
This commit is contained in:
parent
97243b53e4
commit
c63fa2e743
@ -562,7 +562,10 @@ supergroupMembersFilterMention query:string message_thread_id:int53 = Supergroup
|
||||
supergroupMembersFilterBots = SupergroupMembersFilter;
|
||||
|
||||
|
||||
//@description Contains a chat invite link @invite_link Chat invite link @creator_user_id User identifier of an administrator created the link
|
||||
//@description Contains a chat invite link
|
||||
//@invite_link Chat invite link
|
||||
//@title Title of the chat invite link
|
||||
//@creator_user_id User identifier of an administrator created the link
|
||||
//@date Point in time (Unix timestamp) when the link was created
|
||||
//@edit_date Point in time (Unix timestamp) when the link was last edited; 0 if never or unknown
|
||||
//@expire_date Point in time (Unix timestamp) when the link will expire; 0 if never
|
||||
@ -570,9 +573,9 @@ supergroupMembersFilterBots = SupergroupMembersFilter;
|
||||
//@member_count Number of chat members, which joined the chat using the link
|
||||
//@pending_join_request_count Number of pending join requests, created using this link
|
||||
//@requires_approval True, if users joining the chat by the link need to be approved by chat administrators
|
||||
//@is_primary True, if the link is primary. Primary invite link can't have expire date or usage limit. There is exactly one primary invite link for each administrator with can_invite_users right at a given time
|
||||
//@is_primary True, if the link is primary. Primary invite link can't have title, expire date or usage limit. There is exactly one primary invite link for each administrator with can_invite_users right at a given time
|
||||
//@is_revoked True, if the link was revoked
|
||||
chatInviteLink invite_link:string creator_user_id:int53 date:int32 edit_date:int32 expire_date:int32 member_limit:int32 member_count:int32 pending_join_request_count:int32 requires_approval:Bool is_primary:Bool is_revoked:Bool = ChatInviteLink;
|
||||
chatInviteLink invite_link:string title:string creator_user_id:int53 date:int32 edit_date:int32 expire_date:int32 member_limit:int32 member_count:int32 pending_join_request_count:int32 requires_approval:Bool is_primary:Bool is_revoked:Bool = ChatInviteLink;
|
||||
|
||||
//@description Contains a list of chat invite links @total_count Approximate total count of chat invite links found @invite_links List of invite links
|
||||
chatInviteLinks total_count:int32 invite_links:vector<chatInviteLink> = ChatInviteLinks;
|
||||
|
@ -19,59 +19,52 @@ DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::chatInviteExporte
|
||||
}
|
||||
|
||||
invite_link_ = std::move(exported_invite->link_);
|
||||
LOG_IF(ERROR, !is_valid_invite_link(invite_link_)) << "Unsupported invite link " << invite_link_;
|
||||
title_ = std::move(exported_invite->title_);
|
||||
creator_user_id_ = UserId(exported_invite->admin_id_);
|
||||
if (!creator_user_id_.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << creator_user_id_ << " as creator of a link " << invite_link_;
|
||||
creator_user_id_ = UserId();
|
||||
}
|
||||
date_ = exported_invite->date_;
|
||||
if (date_ < 1000000000) {
|
||||
LOG(ERROR) << "Receive wrong date " << date_ << " as a creation date of a link " << invite_link_;
|
||||
date_ = 0;
|
||||
}
|
||||
if ((exported_invite->flags_ & telegram_api::chatInviteExported::EXPIRE_DATE_MASK) != 0) {
|
||||
expire_date_ = exported_invite->expire_date_;
|
||||
if (expire_date_ < 1000000000) {
|
||||
LOG(ERROR) << "Receive wrong date " << expire_date_ << " as an 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;
|
||||
}
|
||||
}
|
||||
if ((exported_invite->flags_ & telegram_api::chatInviteExported::START_DATE_MASK) != 0) {
|
||||
edit_date_ = exported_invite->start_date_;
|
||||
if (edit_date_ < 1000000000) {
|
||||
LOG(ERROR) << "Receive wrong date " << edit_date_ << " as an edit date of a link " << invite_link_;
|
||||
edit_date_ = 0;
|
||||
}
|
||||
}
|
||||
if ((exported_invite->flags_ & telegram_api::chatInviteExported::REQUESTED_MASK) != 0) {
|
||||
request_count_ = exported_invite->requested_;
|
||||
if (request_count_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong pending join request count " << request_count_ << " for a link " << invite_link_;
|
||||
request_count_ = 0;
|
||||
}
|
||||
}
|
||||
expire_date_ = exported_invite->expire_date_;
|
||||
usage_limit_ = exported_invite->usage_limit_;
|
||||
usage_count_ = exported_invite->usage_;
|
||||
edit_date_ = exported_invite->start_date_;
|
||||
request_count_ = exported_invite->requested_;
|
||||
requires_approval_ = exported_invite->request_needed_;
|
||||
is_revoked_ = exported_invite->revoked_;
|
||||
is_permanent_ = exported_invite->permanent_;
|
||||
|
||||
if (is_permanent_ &&
|
||||
(usage_limit_ > 0 || expire_date_ > 0 || edit_date_ > 0 || request_count_ > 0 || requires_approval_)) {
|
||||
LOG_IF(ERROR, !is_valid_invite_link(invite_link_)) << "Unsupported invite link " << invite_link_;
|
||||
if (!creator_user_id_.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << creator_user_id_ << " as creator of a link " << invite_link_;
|
||||
creator_user_id_ = UserId();
|
||||
}
|
||||
if (date_ < 1000000000) {
|
||||
LOG(ERROR) << "Receive wrong date " << date_ << " as a creation date of a link " << invite_link_;
|
||||
date_ = 0;
|
||||
}
|
||||
if (expire_date_ < 1000000000) {
|
||||
LOG(ERROR) << "Receive wrong date " << expire_date_ << " as an expire date of a link " << invite_link_;
|
||||
expire_date_ = 0;
|
||||
}
|
||||
if (usage_limit_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong usage limit " << usage_limit_ << " for a link " << invite_link_;
|
||||
usage_limit_ = 0;
|
||||
}
|
||||
if (usage_count_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong usage count " << usage_count_ << " for a link " << invite_link_;
|
||||
usage_count_ = 0;
|
||||
}
|
||||
if (edit_date_ < 1000000000) {
|
||||
LOG(ERROR) << "Receive wrong date " << edit_date_ << " as an edit date of a link " << invite_link_;
|
||||
edit_date_ = 0;
|
||||
}
|
||||
if (request_count_ < 0) {
|
||||
LOG(ERROR) << "Receive wrong pending join request count " << request_count_ << " for a link " << invite_link_;
|
||||
request_count_ = 0;
|
||||
}
|
||||
|
||||
if (is_permanent_ && (!title_.empty() || expire_date_ > 0 || usage_limit_ > 0 || edit_date_ > 0 ||
|
||||
request_count_ > 0 || requires_approval_)) {
|
||||
LOG(ERROR) << "Receive wrong permanent " << *this;
|
||||
title_.clear();
|
||||
expire_date_ = 0;
|
||||
usage_limit_ = 0;
|
||||
edit_date_ = 0;
|
||||
@ -92,17 +85,18 @@ td_api::object_ptr<td_api::chatInviteLink> DialogInviteLink::get_chat_invite_lin
|
||||
}
|
||||
|
||||
return td_api::make_object<td_api::chatInviteLink>(
|
||||
invite_link_, contacts_manager->get_user_id_object(creator_user_id_, "get_chat_invite_link_object"), date_,
|
||||
edit_date_, expire_date_, usage_limit_, usage_count_, request_count_, requires_approval_, is_permanent_,
|
||||
invite_link_, title_, contacts_manager->get_user_id_object(creator_user_id_, "get_chat_invite_link_object"),
|
||||
date_, edit_date_, expire_date_, usage_limit_, usage_count_, request_count_, requires_approval_, is_permanent_,
|
||||
is_revoked_);
|
||||
}
|
||||
|
||||
bool operator==(const DialogInviteLink &lhs, const DialogInviteLink &rhs) {
|
||||
return lhs.invite_link_ == rhs.invite_link_ && lhs.creator_user_id_ == rhs.creator_user_id_ &&
|
||||
lhs.date_ == rhs.date_ && lhs.edit_date_ == rhs.edit_date_ && lhs.expire_date_ == rhs.expire_date_ &&
|
||||
lhs.usage_limit_ == rhs.usage_limit_ && lhs.usage_count_ == rhs.usage_count_ &&
|
||||
lhs.request_count_ == rhs.request_count_ && lhs.requires_approval_ == rhs.requires_approval_ &&
|
||||
lhs.is_permanent_ == rhs.is_permanent_ && lhs.is_revoked_ == rhs.is_revoked_;
|
||||
return lhs.invite_link_ == rhs.invite_link_ && lhs.title_ == rhs.title_ &&
|
||||
lhs.creator_user_id_ == rhs.creator_user_id_ && lhs.date_ == rhs.date_ && lhs.edit_date_ == rhs.edit_date_ &&
|
||||
lhs.expire_date_ == rhs.expire_date_ && lhs.usage_limit_ == rhs.usage_limit_ &&
|
||||
lhs.usage_count_ == rhs.usage_count_ && lhs.request_count_ == rhs.request_count_ &&
|
||||
lhs.requires_approval_ == rhs.requires_approval_ && lhs.is_permanent_ == rhs.is_permanent_ &&
|
||||
lhs.is_revoked_ == rhs.is_revoked_;
|
||||
}
|
||||
|
||||
bool operator!=(const DialogInviteLink &lhs, const DialogInviteLink &rhs) {
|
||||
@ -110,7 +104,7 @@ bool operator!=(const DialogInviteLink &lhs, const DialogInviteLink &rhs) {
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const DialogInviteLink &invite_link) {
|
||||
return string_builder << "ChatInviteLink[" << invite_link.invite_link_
|
||||
return string_builder << "ChatInviteLink[" << invite_link.invite_link_ << '(' << invite_link.title_ << ')'
|
||||
<< (invite_link.requires_approval_ ? " requiring approval" : "") << " by "
|
||||
<< invite_link.creator_user_id_ << " created at " << invite_link.date_ << " edited at "
|
||||
<< invite_link.edit_date_ << " expiring at " << invite_link.expire_date_ << " used by "
|
||||
|
@ -21,6 +21,7 @@ class ContactsManager;
|
||||
|
||||
class DialogInviteLink {
|
||||
string invite_link_;
|
||||
string title_;
|
||||
UserId creator_user_id_;
|
||||
int32 date_ = 0;
|
||||
int32 edit_date_ = 0;
|
||||
@ -69,6 +70,7 @@ class DialogInviteLink {
|
||||
bool has_usage_count = usage_count_ != 0;
|
||||
bool has_edit_date = edit_date_ != 0;
|
||||
bool has_request_count = request_count_ != 0;
|
||||
bool has_title = !title_.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(is_revoked_);
|
||||
STORE_FLAG(is_permanent_);
|
||||
@ -78,6 +80,7 @@ class DialogInviteLink {
|
||||
STORE_FLAG(has_edit_date);
|
||||
STORE_FLAG(has_request_count);
|
||||
STORE_FLAG(requires_approval_);
|
||||
STORE_FLAG(has_title);
|
||||
END_STORE_FLAGS();
|
||||
store(invite_link_, storer);
|
||||
store(creator_user_id_, storer);
|
||||
@ -97,6 +100,9 @@ class DialogInviteLink {
|
||||
if (has_request_count) {
|
||||
store(request_count_, storer);
|
||||
}
|
||||
if (has_title) {
|
||||
store(title_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
@ -107,6 +113,7 @@ class DialogInviteLink {
|
||||
bool has_usage_count;
|
||||
bool has_edit_date;
|
||||
bool has_request_count;
|
||||
bool has_title;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(is_revoked_);
|
||||
PARSE_FLAG(is_permanent_);
|
||||
@ -116,6 +123,7 @@ class DialogInviteLink {
|
||||
PARSE_FLAG(has_edit_date);
|
||||
PARSE_FLAG(has_request_count);
|
||||
PARSE_FLAG(requires_approval_);
|
||||
PARSE_FLAG(has_title);
|
||||
END_PARSE_FLAGS();
|
||||
parse(invite_link_, parser);
|
||||
parse(creator_user_id_, parser);
|
||||
@ -135,6 +143,9 @@ class DialogInviteLink {
|
||||
if (has_request_count) {
|
||||
parse(request_count_, parser);
|
||||
}
|
||||
if (has_title) {
|
||||
parse(title_, parser);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user