Add chatInviteLink.requires_approval/pending_join_request_count.

This commit is contained in:
levlam 2021-10-09 12:52:25 +03:00
parent 16f1e16107
commit 884232d935
3 changed files with 38 additions and 7 deletions

View File

@ -562,9 +562,11 @@ supergroupMembersFilterBots = SupergroupMembersFilter;
//@expire_date Point in time (Unix timestamp) when the link will expire; 0 if never
//@member_limit The maximum number of members, which can join the chat using the link simultaneously; 0 if not limited
//@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_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 is_primary:Bool is_revoked:Bool = ChatInviteLink;
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;
//@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;

View File

@ -58,14 +58,25 @@ DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::chatInviteExporte
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;
}
}
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)) {
if (is_permanent_ &&
(usage_limit_ > 0 || expire_date_ > 0 || edit_date_ > 0 || request_count_ > 0 || requires_approval_)) {
LOG(ERROR) << "Receive wrong permanent " << *this;
expire_date_ = 0;
usage_limit_ = 0;
edit_date_ = 0;
request_count_ = 0;
requires_approval_ = false;
}
}
@ -82,13 +93,15 @@ 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_, is_permanent_, is_revoked_);
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_;
}
@ -97,10 +110,12 @@ 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_ << " 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 " << invite_link.usage_count_
<< " with usage limit " << invite_link.usage_limit_ << "]";
return string_builder << "ChatInviteLink[" << invite_link.invite_link_
<< (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 "
<< invite_link.usage_count_ << " with usage limit " << invite_link.usage_limit_ << " and "
<< invite_link.request_count_ << "pending join requests]";
}
} // namespace td

View File

@ -27,6 +27,8 @@ class DialogInviteLink {
int32 expire_date_ = 0;
int32 usage_limit_ = 0;
int32 usage_count_ = 0;
int32 request_count_ = 0;
bool requires_approval_ = false;
bool is_revoked_ = false;
bool is_permanent_ = false;
@ -66,6 +68,7 @@ class DialogInviteLink {
bool has_usage_limit = usage_limit_ != 0;
bool has_usage_count = usage_count_ != 0;
bool has_edit_date = edit_date_ != 0;
bool has_request_count = request_count_ != 0;
BEGIN_STORE_FLAGS();
STORE_FLAG(is_revoked_);
STORE_FLAG(is_permanent_);
@ -73,6 +76,8 @@ class DialogInviteLink {
STORE_FLAG(has_usage_limit);
STORE_FLAG(has_usage_count);
STORE_FLAG(has_edit_date);
STORE_FLAG(has_request_count);
STORE_FLAG(requires_approval_);
END_STORE_FLAGS();
store(invite_link_, storer);
store(creator_user_id_, storer);
@ -89,6 +94,9 @@ class DialogInviteLink {
if (has_edit_date) {
store(edit_date_, storer);
}
if (has_request_count) {
store(request_count_, storer);
}
}
template <class ParserT>
@ -98,6 +106,7 @@ class DialogInviteLink {
bool has_usage_limit;
bool has_usage_count;
bool has_edit_date;
bool has_request_count;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_revoked_);
PARSE_FLAG(is_permanent_);
@ -105,6 +114,8 @@ class DialogInviteLink {
PARSE_FLAG(has_usage_limit);
PARSE_FLAG(has_usage_count);
PARSE_FLAG(has_edit_date);
PARSE_FLAG(has_request_count);
PARSE_FLAG(requires_approval_);
END_PARSE_FLAGS();
parse(invite_link_, parser);
parse(creator_user_id_, parser);
@ -121,6 +132,9 @@ class DialogInviteLink {
if (has_edit_date) {
parse(edit_date_, parser);
}
if (has_request_count) {
parse(request_count_, parser);
}
}
};