Add chatInviteLink.pricing.

This commit is contained in:
levlam 2024-07-23 17:03:59 +03:00
parent 1a8757aa6e
commit 7ed407ec14
5 changed files with 31 additions and 12 deletions

View File

@ -1187,13 +1187,14 @@ supergroupMembersFilterBots = SupergroupMembersFilter;
//@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
//@expiration_date Point in time (Unix timestamp) when the link will expire; 0 if never
//@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
//@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 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 pricing:starSubscriptionPricing member_limit:int32 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

@ -32,6 +32,7 @@ DialogInviteLink::DialogInviteLink(telegram_api::object_ptr<telegram_api::Export
invite_link_ = std::move(exported_invite->link_);
title_ = std::move(exported_invite->title_);
creator_user_id_ = UserId(exported_invite->admin_id_);
pricing_ = StarSubscriptionPricing(std::move(exported_invite->subscription_pricing_));
date_ = exported_invite->date_;
expire_date_ = exported_invite->expire_date_;
usage_limit_ = exported_invite->usage_limit_;
@ -105,17 +106,17 @@ 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_, usage_limit_, usage_count_, request_count_, creates_join_request_, is_permanent_,
is_revoked_);
edit_date_, expire_date_, pricing_.get_star_subscription_pricing_object(), usage_limit_, usage_count_,
request_count_, creates_join_request_, is_permanent_, is_revoked_);
}
bool operator==(const DialogInviteLink &lhs, const DialogInviteLink &rhs) {
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.creates_join_request_ == rhs.creates_join_request_ && lhs.is_permanent_ == rhs.is_permanent_ &&
lhs.is_revoked_ == rhs.is_revoked_;
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_;
}
bool operator!=(const DialogInviteLink &lhs, const DialogInviteLink &rhs) {
@ -127,8 +128,9 @@ 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_ << " and "
<< invite_link.request_count_ << " pending join requests]";
<< invite_link.usage_count_ << " with usage limit " << invite_link.usage_limit_ << ", "
<< invite_link.request_count_ << " pending join requests"
<< " and " << invite_link.pricing_ << "]";
}
} // namespace td

View File

@ -6,6 +6,7 @@
//
#pragma once
#include "td/telegram/StarSubscriptionPricing.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
@ -22,6 +23,7 @@ class DialogInviteLink {
string invite_link_;
string title_;
UserId creator_user_id_;
StarSubscriptionPricing pricing_;
int32 date_ = 0;
int32 edit_date_ = 0;
int32 expire_date_ = 0;

View File

@ -8,7 +8,8 @@
#include "td/telegram/DialogInviteLink.h"
#include "td/utils/common.h"
#include "td/telegram/StarSubscriptionPricing.hpp"
#include "td/utils/tl_helpers.h"
namespace td {
@ -22,6 +23,7 @@ void DialogInviteLink::store(StorerT &storer) const {
bool has_edit_date = edit_date_ != 0;
bool has_request_count = request_count_ != 0;
bool has_title = !title_.empty();
bool has_pricing = !pricing_.is_empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(is_revoked_);
STORE_FLAG(is_permanent_);
@ -32,6 +34,7 @@ void DialogInviteLink::store(StorerT &storer) const {
STORE_FLAG(has_request_count);
STORE_FLAG(creates_join_request_);
STORE_FLAG(has_title);
STORE_FLAG(has_pricing);
END_STORE_FLAGS();
store(invite_link_, storer);
store(creator_user_id_, storer);
@ -54,6 +57,9 @@ void DialogInviteLink::store(StorerT &storer) const {
if (has_title) {
store(title_, storer);
}
if (has_pricing) {
store(pricing_, storer);
}
}
template <class ParserT>
@ -65,6 +71,7 @@ void DialogInviteLink::parse(ParserT &parser) {
bool has_edit_date;
bool has_request_count;
bool has_title;
bool has_pricing;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_revoked_);
PARSE_FLAG(is_permanent_);
@ -75,6 +82,7 @@ void DialogInviteLink::parse(ParserT &parser) {
PARSE_FLAG(has_request_count);
PARSE_FLAG(creates_join_request_);
PARSE_FLAG(has_title);
PARSE_FLAG(has_pricing);
END_PARSE_FLAGS();
parse(invite_link_, parser);
parse(creator_user_id_, parser);
@ -97,6 +105,9 @@ void DialogInviteLink::parse(ParserT &parser) {
if (has_title) {
parse(title_, parser);
}
if (has_pricing) {
parse(pricing_, parser);
}
if (creates_join_request_) {
usage_limit_ = 0;
}

View File

@ -49,7 +49,10 @@ bool operator==(const StarSubscriptionPricing &lhs, const StarSubscriptionPricin
}
StringBuilder &operator<<(StringBuilder &string_builder, const StarSubscriptionPricing &pricing) {
return string_builder << "Subscription for " << pricing.period_ << " days for " << pricing.amount_ << " stars";
if (pricing.is_empty()) {
return string_builder << "no subscription";
}
return string_builder << "subscription for " << pricing.period_ << " days for " << pricing.amount_ << " stars";
}
} // namespace td