Add chatInviteLink.expired_member_count.

This commit is contained in:
levlam 2024-08-12 19:28:28 +03:00
parent c51648459e
commit 3e4aa8e98e
4 changed files with 24 additions and 6 deletions

View File

@ -1225,11 +1225,12 @@ supergroupMembersFilterBots = SupergroupMembersFilter;
//@subscription_pricing Information about subscription plan that is applied to the users joining the chat by the link; may be null if the link doesn't require subscription
//@member_limit The maximum number of members, which can join the chat using the link simultaneously; 0 if not limited. Always 0 if the link requires approval
//@member_count Number of chat members, which joined the chat using the link
//@expired_member_count Number of chat members, which joined the chat using the link, but have already left because of expired subscription; for subscription links only
//@pending_join_request_count Number of pending join requests created using this link
//@creates_join_request True, if the link only creates join request. If true, total number of joining members will be unlimited
//@is_primary True, if the link is primary. Primary invite link can't have name, expiration 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 name:string creator_user_id:int53 date:int32 edit_date:int32 expiration_date:int32 subscription_pricing:starSubscriptionPricing member_limit:int32 member_count:int32 pending_join_request_count:int32 creates_join_request:Bool is_primary:Bool is_revoked:Bool = ChatInviteLink;
chatInviteLink invite_link:string name:string creator_user_id:int53 date:int32 edit_date:int32 expiration_date:int32 subscription_pricing:starSubscriptionPricing member_limit:int32 member_count:int32 expired_member_count:int32 pending_join_request_count:int32 creates_join_request:Bool is_primary:Bool is_revoked:Bool = ChatInviteLink;
//@description Contains a list of chat invite links @total_count Approximate total number of chat invite links found @invite_links List of invite links
chatInviteLinks total_count:int32 invite_links:vector<chatInviteLink> = ChatInviteLinks;

View File

@ -37,6 +37,7 @@ DialogInviteLink::DialogInviteLink(telegram_api::object_ptr<telegram_api::Export
expire_date_ = exported_invite->expire_date_;
usage_limit_ = exported_invite->usage_limit_;
usage_count_ = exported_invite->usage_;
expired_usage_count_ = exported_invite->subscription_expired_;
edit_date_ = exported_invite->start_date_;
request_count_ = exported_invite->requested_;
creates_join_request_ = exported_invite->request_needed_;
@ -65,6 +66,10 @@ DialogInviteLink::DialogInviteLink(telegram_api::object_ptr<telegram_api::Export
LOG(ERROR) << "Receive wrong usage count " << usage_count_ << " for " << full_source;
usage_count_ = 0;
}
if (expired_usage_count_ < 0) {
LOG(ERROR) << "Receive wrong expired usage count " << expired_usage_count_ << " for " << full_source;
expired_usage_count_ = 0;
}
if (edit_date_ != 0 && edit_date_ < 1000000000) {
LOG(ERROR) << "Receive wrong date " << edit_date_ << " as an edit date of " << full_source;
edit_date_ = 0;
@ -107,7 +112,7 @@ td_api::object_ptr<td_api::chatInviteLink> DialogInviteLink::get_chat_invite_lin
return td_api::make_object<td_api::chatInviteLink>(
invite_link_, title_, user_manager->get_user_id_object(creator_user_id_, "get_chat_invite_link_object"), date_,
edit_date_, expire_date_, pricing_.get_star_subscription_pricing_object(), usage_limit_, usage_count_,
request_count_, creates_join_request_, is_permanent_, is_revoked_);
expired_usage_count_, request_count_, creates_join_request_, is_permanent_, is_revoked_);
}
bool operator==(const DialogInviteLink &lhs, const DialogInviteLink &rhs) {
@ -115,8 +120,9 @@ bool operator==(const DialogInviteLink &lhs, const DialogInviteLink &rhs) {
lhs.creator_user_id_ == rhs.creator_user_id_ && lhs.pricing_ == rhs.pricing_ && 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.creates_join_request_ == rhs.creates_join_request_ &&
lhs.is_permanent_ == rhs.is_permanent_ && lhs.is_revoked_ == rhs.is_revoked_;
lhs.expired_usage_count_ == rhs.expired_usage_count_ && lhs.request_count_ == rhs.request_count_ &&
lhs.creates_join_request_ == rhs.creates_join_request_ && lhs.is_permanent_ == rhs.is_permanent_ &&
lhs.is_revoked_ == rhs.is_revoked_;
}
bool operator!=(const DialogInviteLink &lhs, const DialogInviteLink &rhs) {
@ -128,8 +134,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const DialogInviteLink
<< (invite_link.creates_join_request_ ? " creating join request" : "") << " 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_ << ", "
<< invite_link.request_count_ << " pending join requests"
<< invite_link.usage_count_ << " + " << invite_link.expired_usage_count_ << " with usage limit "
<< invite_link.usage_limit_ << ", " << invite_link.request_count_ << " pending join requests"
<< " and " << invite_link.pricing_ << "]";
}

View File

@ -29,6 +29,7 @@ class DialogInviteLink {
int32 expire_date_ = 0;
int32 usage_limit_ = 0;
int32 usage_count_ = 0;
int32 expired_usage_count_ = 0;
int32 request_count_ = 0;
bool creates_join_request_ = false;
bool is_revoked_ = false;

View File

@ -24,6 +24,7 @@ void DialogInviteLink::store(StorerT &storer) const {
bool has_request_count = request_count_ != 0;
bool has_title = !title_.empty();
bool has_pricing = !pricing_.is_empty();
bool has_expired_usage_count = expired_usage_count_ != 0;
BEGIN_STORE_FLAGS();
STORE_FLAG(is_revoked_);
STORE_FLAG(is_permanent_);
@ -35,6 +36,7 @@ void DialogInviteLink::store(StorerT &storer) const {
STORE_FLAG(creates_join_request_);
STORE_FLAG(has_title);
STORE_FLAG(has_pricing);
STORE_FLAG(has_expired_usage_count);
END_STORE_FLAGS();
store(invite_link_, storer);
store(creator_user_id_, storer);
@ -60,6 +62,9 @@ void DialogInviteLink::store(StorerT &storer) const {
if (has_pricing) {
store(pricing_, storer);
}
if (has_expired_usage_count) {
store(expired_usage_count_, storer);
}
}
template <class ParserT>
@ -72,6 +77,7 @@ void DialogInviteLink::parse(ParserT &parser) {
bool has_request_count;
bool has_title;
bool has_pricing;
bool has_expired_usage_count;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_revoked_);
PARSE_FLAG(is_permanent_);
@ -83,6 +89,7 @@ void DialogInviteLink::parse(ParserT &parser) {
PARSE_FLAG(creates_join_request_);
PARSE_FLAG(has_title);
PARSE_FLAG(has_pricing);
PARSE_FLAG(has_expired_usage_count);
END_PARSE_FLAGS();
parse(invite_link_, parser);
parse(creator_user_id_, parser);
@ -108,6 +115,9 @@ void DialogInviteLink::parse(ParserT &parser) {
if (has_pricing) {
parse(pricing_, parser);
}
if (has_expired_usage_count) {
parse(expired_usage_count_, parser);
}
if (creates_join_request_) {
usage_limit_ = 0;
}