Disallow member_limit for links requiring administrator approval.
This commit is contained in:
parent
5a596fcc48
commit
d732789cac
@ -569,10 +569,10 @@ 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
|
||||
//@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_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
|
||||
//@requires_approval True, if users joining the chat by the link need to be approved by chat administrators
|
||||
//@requires_approval True, if users joining the chat by the link need to be approved by chat administrators. If true, total number of joining members will be unlimited
|
||||
//@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 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;
|
||||
@ -4933,7 +4933,7 @@ replacePrimaryChatInviteLink chat_id:int53 = ChatInviteLink;
|
||||
//@title Invite link title; 0-32 characters
|
||||
//@expire_date Point in time (Unix timestamp) when the link will expire; pass 0 if never
|
||||
//@member_limit The maximum number of chat members that can join the chat by the link simultaneously; 0-99999; pass 0 if not limited
|
||||
//@requires_approval True, if users joining the chat by the link need to be approved by chat administrators
|
||||
//@requires_approval True, if users joining the chat by the link need to be approved by chat administrators. If true, member_limit must not be specified
|
||||
createChatInviteLink chat_id:int53 title:string expire_date:int32 member_limit:int32 requires_approval:Bool = ChatInviteLink;
|
||||
|
||||
//@description Edits a non-primary invite link for a chat. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links
|
||||
@ -4942,7 +4942,7 @@ createChatInviteLink chat_id:int53 title:string expire_date:int32 member_limit:i
|
||||
//@title Invite link title; 0-32 characters
|
||||
//@expire_date Point in time (Unix timestamp) when the link will expire; pass 0 if never
|
||||
//@member_limit The maximum number of chat members that can join the chat by the link simultaneously; 0-99999; pass 0 if not limited
|
||||
//@requires_approval True, if users joining the chat by the link need to be approved by chat administrators
|
||||
//@requires_approval True, if users joining the chat by the link need to be approved by chat administrators. If true, member_limit must not be specified
|
||||
editChatInviteLink chat_id:int53 invite_link:string title:string expire_date:int32 member_limit:int32 requires_approval:Bool = ChatInviteLink;
|
||||
|
||||
//@description Returns information about an invite link. Requires administrator privileges and can_invite_users right in the chat to get own links and owner privileges to get other links
|
||||
|
@ -7459,6 +7459,10 @@ void ContactsManager::export_dialog_invite_link_impl(DialogId dialog_id, string
|
||||
Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id));
|
||||
if (requires_approval && usage_limit > 0) {
|
||||
return promise.set_error(
|
||||
Status::Error(400, "Member limit can't be specified for links requiring administrator approval"));
|
||||
}
|
||||
|
||||
auto new_title = clean_name(std::move(title), MAX_INVITE_LINK_TITLE_LENGTH);
|
||||
td_->create_handler<ExportChatInviteQuery>(std::move(promise))
|
||||
@ -7469,6 +7473,10 @@ void ContactsManager::edit_dialog_invite_link(DialogId dialog_id, const string &
|
||||
int32 expire_date, int32 usage_limit, bool requires_approval,
|
||||
Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id));
|
||||
if (requires_approval && usage_limit > 0) {
|
||||
return promise.set_error(
|
||||
Status::Error(400, "Member limit can't be specified for links requiring administrator approval"));
|
||||
}
|
||||
|
||||
if (invite_link.empty()) {
|
||||
return promise.set_error(Status::Error(400, "Invite link must be non-empty"));
|
||||
|
@ -71,6 +71,10 @@ DialogInviteLink::DialogInviteLink(tl_object_ptr<telegram_api::chatInviteExporte
|
||||
request_count_ = 0;
|
||||
requires_approval_ = false;
|
||||
}
|
||||
if (requires_approval_ && usage_limit_ > 0) {
|
||||
LOG(ERROR) << "Receive wrong permanent " << *this;
|
||||
usage_limit_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool DialogInviteLink::is_valid_invite_link(Slice invite_link) {
|
||||
|
@ -146,6 +146,9 @@ class DialogInviteLink {
|
||||
if (has_title) {
|
||||
parse(title_, parser);
|
||||
}
|
||||
if (requires_approval_) {
|
||||
usage_limit_ = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user