mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added initial api support to create invite links with subscription.
This commit is contained in:
parent
75b26b1a85
commit
ba6bbf54e6
4 changed files with 37 additions and 8 deletions
|
@ -8,12 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "api/api_invite_links.h"
|
||||
|
||||
#include "api/api_chat_participants.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "main/main_session.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "apiwrap.h"
|
||||
|
@ -88,6 +88,7 @@ void InviteLinks::performCreate(
|
|||
callbacks.push_back(std::move(args.done));
|
||||
}
|
||||
|
||||
const auto requestApproval = !args.subscription && args.requestApproval;
|
||||
using Flag = MTPmessages_ExportChatInvite::Flag;
|
||||
_api->request(MTPmessages_ExportChatInvite(
|
||||
MTP_flags((revokeLegacyPermanent
|
||||
|
@ -95,15 +96,18 @@ void InviteLinks::performCreate(
|
|||
: Flag(0))
|
||||
| (!args.label.isEmpty() ? Flag::f_title : Flag(0))
|
||||
| (args.expireDate ? Flag::f_expire_date : Flag(0))
|
||||
| ((!args.requestApproval && args.usageLimit)
|
||||
| ((!requestApproval && args.usageLimit)
|
||||
? Flag::f_usage_limit
|
||||
: Flag(0))
|
||||
| (args.requestApproval ? Flag::f_request_needed : Flag(0))),
|
||||
| (requestApproval ? Flag::f_request_needed : Flag(0))
|
||||
| (args.subscription ? Flag::f_subscription_pricing : Flag(0))),
|
||||
args.peer->input,
|
||||
MTP_int(args.expireDate),
|
||||
MTP_int(args.usageLimit),
|
||||
MTP_string(args.label),
|
||||
MTPStarsSubscriptionPricing()
|
||||
MTP_starsSubscriptionPricing(
|
||||
MTP_int(args.subscription.period),
|
||||
MTP_long(args.subscription.credits))
|
||||
)).done([=, peer = args.peer](const MTPExportedChatInvite &result) {
|
||||
const auto callbacks = _createCallbacks.take(peer);
|
||||
const auto link = prepend(peer, peer->session().user(), result);
|
||||
|
|
|
@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
class ApiWrap;
|
||||
|
||||
#include "data/data_subscriptions.h"
|
||||
|
||||
namespace Api {
|
||||
|
||||
struct InviteLink {
|
||||
|
@ -60,6 +62,7 @@ struct CreateInviteLinkArgs {
|
|||
TimeId expireDate = 0;
|
||||
int usageLimit = 0;
|
||||
bool requestApproval = false;
|
||||
Data::PeerSubscription subscription;
|
||||
};
|
||||
|
||||
class InviteLinks final {
|
||||
|
|
21
Telegram/SourceFiles/data/data_subscriptions.h
Normal file
21
Telegram/SourceFiles/data/data_subscriptions.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Data {
|
||||
|
||||
struct PeerSubscription final {
|
||||
uint64 credits = 0;
|
||||
int period = 0;
|
||||
|
||||
explicit operator bool() const {
|
||||
return credits > 0 && period > 0;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Data
|
|
@ -90,6 +90,7 @@ PRIVATE
|
|||
data/data_premium_subscription_option.h
|
||||
data/data_statistics_chart.cpp
|
||||
data/data_statistics_chart.h
|
||||
data/data_subscriptions.h
|
||||
|
||||
dialogs/dialogs_three_state_icon.h
|
||||
dialogs/ui/chat_search_empty.cpp
|
||||
|
|
Loading…
Add table
Reference in a new issue