mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Update API scheme on layer 166.
This commit is contained in:
parent
12fab565a4
commit
16d18b437d
7 changed files with 149 additions and 86 deletions
|
@ -158,7 +158,8 @@ void PeerClickHandler::onClick(ClickContext context) const {
|
|||
|
||||
PeerData::PeerData(not_null<Data::Session*> owner, PeerId id)
|
||||
: id(id)
|
||||
, _owner(owner) {
|
||||
, _owner(owner)
|
||||
, _colorIndex(Data::DecideColorIndex(id)) {
|
||||
}
|
||||
|
||||
Data::Session &PeerData::owner() const {
|
||||
|
@ -619,6 +620,13 @@ void PeerData::setSettings(const MTPPeerSettings &data) {
|
|||
});
|
||||
}
|
||||
|
||||
bool PeerData::changeColorIndex(
|
||||
const tl::conditional<MTPint> &cloudColorIndex) {
|
||||
return cloudColorIndex
|
||||
? changeColorIndex(cloudColorIndex->v)
|
||||
: clearColorIndex();
|
||||
}
|
||||
|
||||
void PeerData::fillNames() {
|
||||
_nameWords.clear();
|
||||
_nameFirstLetters.clear();
|
||||
|
@ -837,13 +845,23 @@ QString PeerData::userName() const {
|
|||
|
||||
bool PeerData::changeColorIndex(uint8 index) {
|
||||
index %= Ui::kColorIndexCount;
|
||||
if (_colorIndex == index) {
|
||||
if (_colorIndexCloud && _colorIndex == index) {
|
||||
return false;
|
||||
}
|
||||
_colorIndexCloud = true;
|
||||
_colorIndex = index;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PeerData::clearColorIndex() {
|
||||
if (!_colorIndexCloud) {
|
||||
return false;
|
||||
}
|
||||
_colorIndexCloud = false;
|
||||
_colorIndex = Data::DecideColorIndex(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PeerData::isSelf() const {
|
||||
if (const auto user = asUser()) {
|
||||
return (user->flags() & UserDataFlag::Self);
|
||||
|
|
|
@ -168,6 +168,7 @@ public:
|
|||
return _colorIndex;
|
||||
}
|
||||
bool changeColorIndex(uint8 index);
|
||||
bool clearColorIndex();
|
||||
|
||||
[[nodiscard]] bool isUser() const {
|
||||
return peerIsUser(id);
|
||||
|
@ -358,6 +359,7 @@ public:
|
|||
void saveTranslationDisabled(bool disabled);
|
||||
|
||||
void setSettings(const MTPPeerSettings &data);
|
||||
bool changeColorIndex(const tl::conditional<MTPint> &cloudColorIndex);
|
||||
|
||||
enum class BlockStatus : char {
|
||||
Unknown,
|
||||
|
@ -464,7 +466,8 @@ private:
|
|||
BlockStatus _blockStatus = BlockStatus::Unknown;
|
||||
LoadedStatus _loadedStatus = LoadedStatus::Not;
|
||||
TranslationFlag _translationFlag = TranslationFlag::Unknown;
|
||||
uint8 _colorIndex : 7 = 0;
|
||||
uint8 _colorIndex : 6 = 0;
|
||||
uint8 _colorIndexCloud : 1 = 0;
|
||||
uint8 _userpicHasVideo : 1 = 0;
|
||||
|
||||
QString _about;
|
||||
|
|
|
@ -705,7 +705,7 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
|||
if (canShareThisContact != result->canShareThisContactFast()) {
|
||||
flags |= UpdateFlag::CanShareContact;
|
||||
}
|
||||
if (result->changeColorIndex(uint8(data.vcolor().v))) {
|
||||
if (result->changeColorIndex(data.vcolor())) {
|
||||
flags |= UpdateFlag::Color;
|
||||
}
|
||||
});
|
||||
|
@ -982,7 +982,7 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
|||
if (wasCallNotEmpty != Data::ChannelHasActiveCall(channel)) {
|
||||
flags |= UpdateFlag::GroupCall;
|
||||
}
|
||||
if (result->changeColorIndex(uint8(data.vcolor().v))) {
|
||||
if (result->changeColorIndex(data.vcolor())) {
|
||||
flags |= UpdateFlag::Color;
|
||||
}
|
||||
}, [&](const MTPDchannelForbidden &data) {
|
||||
|
|
|
@ -766,7 +766,8 @@ ContactInfo ParseContactInfo(const MTPUser &data) {
|
|||
auto result = ContactInfo();
|
||||
data.match([&](const MTPDuser &data) {
|
||||
result.userId = data.vid().v;
|
||||
result.colorIndex = data.vcolor().v;
|
||||
result.colorIndex = data.vcolor().value_or(
|
||||
PeerColorIndex(result.userId));
|
||||
if (const auto firstName = data.vfirst_name()) {
|
||||
result.firstName = ParseString(*firstName);
|
||||
}
|
||||
|
@ -796,7 +797,8 @@ User ParseUser(const MTPUser &data) {
|
|||
result.info = ParseContactInfo(data);
|
||||
data.match([&](const MTPDuser &data) {
|
||||
result.bareId = data.vid().v;
|
||||
result.colorIndex = data.vcolor().v;
|
||||
result.colorIndex = data.vcolor().value_or(
|
||||
PeerColorIndex(result.bareId));
|
||||
if (const auto username = data.vusername()) {
|
||||
result.username = ParseString(*username);
|
||||
}
|
||||
|
@ -851,7 +853,8 @@ Chat ParseChat(const MTPChat &data) {
|
|||
result.input = MTP_inputPeerChat(MTP_long(result.bareId));
|
||||
}, [&](const MTPDchannel &data) {
|
||||
result.bareId = data.vid().v;
|
||||
result.colorIndex = data.vcolor().v;
|
||||
result.colorIndex = data.vcolor().value_or(
|
||||
PeerColorIndex(result.bareId));
|
||||
result.isBroadcast = data.is_broadcast();
|
||||
result.isSupergroup = data.is_megagroup();
|
||||
result.title = ParseString(data.vtitle());
|
||||
|
|
|
@ -262,6 +262,12 @@ std::unique_ptr<Result> Result::Create(
|
|||
result->sendData = std::make_unique<internal::SendInvoice>(
|
||||
session,
|
||||
media);
|
||||
}, [&](const MTPDbotInlineMessageMediaWebPage &data) {
|
||||
result->sendData = std::make_unique<internal::SendText>(
|
||||
session,
|
||||
qs(data.vmessage()),
|
||||
Api::EntitiesFromMTP(session, data.ventities().value_or_empty()),
|
||||
false);
|
||||
});
|
||||
|
||||
if (!result->sendData || !result->sendData->isValid()) {
|
||||
|
|
|
@ -82,7 +82,7 @@ storage.fileMp4#b3cea0e4 = storage.FileType;
|
|||
storage.fileWebp#1081464c = storage.FileType;
|
||||
|
||||
userEmpty#d3bc4b7a id:long = User;
|
||||
user#6fdee0df flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_hidden:flags2.3?true stories_unavailable:flags2.4?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus usernames:flags2.0?Vector<Username> stories_max_id:flags2.5?int color:int background_emoji_id:flags2.6?long = User;
|
||||
user#eb602f25 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_hidden:flags2.3?true stories_unavailable:flags2.4?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus usernames:flags2.0?Vector<Username> stories_max_id:flags2.5?int color:flags2.7?int background_emoji_id:flags2.6?long = User;
|
||||
|
||||
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
|
||||
userProfilePhoto#82d1f706 flags:# has_video:flags.0?true personal:flags.2?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto;
|
||||
|
@ -97,7 +97,7 @@ userStatusLastMonth#77ebc742 = UserStatus;
|
|||
chatEmpty#29562865 id:long = Chat;
|
||||
chat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5?true call_active:flags.23?true call_not_empty:flags.24?true noforwards:flags.25?true id:long title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat;
|
||||
chatForbidden#6592a1a7 id:long title:string = Chat;
|
||||
channel#2458af8c flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# stories_hidden:flags2.1?true stories_hidden_min:flags2.2?true stories_unavailable:flags2.3?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector<RestrictionReason> admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector<Username> stories_max_id:flags2.4?int color:int background_emoji_id:flags2.5?long = Chat;
|
||||
channel#1981ea7e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# stories_hidden:flags2.1?true stories_hidden_min:flags2.2?true stories_unavailable:flags2.3?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector<RestrictionReason> admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector<Username> stories_max_id:flags2.4?int color:flags2.6?int background_emoji_id:flags2.5?long = Chat;
|
||||
channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat;
|
||||
|
||||
chatFull#c9d31138 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector<long> available_reactions:flags.18?ChatReactions = ChatFull;
|
||||
|
@ -123,7 +123,7 @@ messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia;
|
|||
messageMediaContact#70322949 phone_number:string first_name:string last_name:string vcard:string user_id:long = MessageMedia;
|
||||
messageMediaUnsupported#9f84f49e = MessageMedia;
|
||||
messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia;
|
||||
messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true webpage:WebPage = MessageMedia;
|
||||
messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true safe:flags.4?true webpage:WebPage = MessageMedia;
|
||||
messageMediaVenue#2ec0533f geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string = MessageMedia;
|
||||
messageMediaGame#fdb19008 game:Game = MessageMedia;
|
||||
messageMediaInvoice#f6a548d3 flags:# shipping_address_requested:flags.1?true test:flags.3?true title:string description:string photo:flags.0?WebDocument receipt_msg_id:flags.2?int currency:string total_amount:long start_param:string extended_media:flags.4?MessageExtendedMedia = MessageMedia;
|
||||
|
@ -575,7 +575,7 @@ chatInviteExported#ab4a819 flags:# revoked:flags.0?true permanent:flags.5?true r
|
|||
chatInvitePublicJoinRequests#ed107ab7 = ExportedChatInvite;
|
||||
|
||||
chatInviteAlready#5a686d7c chat:Chat = ChatInvite;
|
||||
chatInvite#300c44c1 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true request_needed:flags.6?true verified:flags.7?true scam:flags.8?true fake:flags.9?true title:string about:flags.5?string photo:Photo participants_count:int participants:flags.4?Vector<User> = ChatInvite;
|
||||
chatInvite#3033e855 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true request_needed:flags.6?true verified:flags.7?true scam:flags.8?true fake:flags.9?true title:string about:flags.5?string photo:Photo participants_count:int participants:flags.4?Vector<User> color:flags.10?int = ChatInvite;
|
||||
chatInvitePeek#61695cb0 chat:Chat expires:int = ChatInvite;
|
||||
|
||||
inputStickerSetEmpty#ffb62b95 = InputStickerSet;
|
||||
|
@ -685,25 +685,27 @@ help.termsOfService#780a0310 flags:# popup:flags.0?true id:DataJSON text:string
|
|||
messages.savedGifsNotModified#e8025ca2 = messages.SavedGifs;
|
||||
messages.savedGifs#84a02a0d hash:long gifs:Vector<Document> = messages.SavedGifs;
|
||||
|
||||
inputBotInlineMessageMediaAuto#3380c786 flags:# message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageMediaAuto#3380c786 flags:# invert_media:flags.3?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageMediaGeo#96929a85 flags:# geo_point:InputGeoPoint heading:flags.0?int period:flags.1?int proximity_notification_radius:flags.3?int reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageMediaVenue#417bbf11 flags:# geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageMediaContact#a6edbffd flags:# phone_number:string first_name:string last_name:string vcard:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageGame#4b425864 flags:# reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageMediaInvoice#d7e78225 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageMediaWebPage#bddcc510 flags:# invert_media:flags.3?true force_large_media:flags.4?true force_small_media:flags.5?true optional:flags.6?true message:string entities:flags.1?Vector<MessageEntity> url:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
|
||||
inputBotInlineResult#88bf9319 flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?InputWebDocument content:flags.5?InputWebDocument send_message:InputBotInlineMessage = InputBotInlineResult;
|
||||
inputBotInlineResultPhoto#a8d864a7 id:string type:string photo:InputPhoto send_message:InputBotInlineMessage = InputBotInlineResult;
|
||||
inputBotInlineResultDocument#fff8fdc4 flags:# id:string type:string title:flags.1?string description:flags.2?string document:InputDocument send_message:InputBotInlineMessage = InputBotInlineResult;
|
||||
inputBotInlineResultGame#4fa417f2 id:string short_name:string send_message:InputBotInlineMessage = InputBotInlineResult;
|
||||
|
||||
botInlineMessageMediaAuto#764cf810 flags:# message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageMediaAuto#764cf810 flags:# invert_media:flags.3?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageMediaGeo#51846fd flags:# geo:GeoPoint heading:flags.0?int period:flags.1?int proximity_notification_radius:flags.3?int reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageMediaVenue#8a86659c flags:# geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageMediaContact#18d1cdc2 flags:# phone_number:string first_name:string last_name:string vcard:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageMediaInvoice#354a9b09 flags:# shipping_address_requested:flags.1?true test:flags.3?true title:string description:string photo:flags.0?WebDocument currency:string total_amount:long reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageMediaWebPage#809ad9a6 flags:# invert_media:flags.3?true force_large_media:flags.4?true force_small_media:flags.5?true manual:flags.7?true message:string entities:flags.1?Vector<MessageEntity> url:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
|
||||
botInlineResult#11965f3a flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?WebDocument content:flags.5?WebDocument send_message:BotInlineMessage = BotInlineResult;
|
||||
botInlineMediaResult#17db940b flags:# id:string type:string photo:flags.0?Photo document:flags.1?Document title:flags.2?string description:flags.3?string send_message:BotInlineMessage = BotInlineResult;
|
||||
|
@ -1573,15 +1575,6 @@ peerStories#9a35e999 flags:# peer:Peer max_read_id:flags.0?int stories:Vector<St
|
|||
|
||||
stories.peerStories#cae68768 stories:PeerStories chats:Vector<Chat> users:Vector<User> = stories.PeerStories;
|
||||
|
||||
stories.boostsStatus#71f2770d flags:# my_boost:flags.2?true level:int current_level_boosts:int boosts:int next_level_boosts:flags.0?int premium_audience:flags.1?StatsPercentValue boost_url:string prepaid_giveaways:flags.3?Vector<PrepaidGiveaway> = stories.BoostsStatus;
|
||||
|
||||
stories.canApplyBoostOk#c3173587 = stories.CanApplyBoostResult;
|
||||
stories.canApplyBoostReplace#712c4655 current_boost:Peer chats:Vector<Chat> = stories.CanApplyBoostResult;
|
||||
|
||||
booster#e9e6380 user_id:long expires:int = Booster;
|
||||
|
||||
stories.boostersList#f3dd3d1d flags:# count:int boosters:Vector<Booster> next_offset:flags.0?string users:Vector<User> = stories.BoostersList;
|
||||
|
||||
messages.webPage#fd5e12bd webpage:WebPage chats:Vector<Chat> users:Vector<User> = messages.WebPage;
|
||||
|
||||
premiumGiftCodeOption#257e962b flags:# users:int months:int store_product:flags.0?string store_quantity:flags.1?int currency:string amount:long = PremiumGiftCodeOption;
|
||||
|
@ -1593,6 +1586,16 @@ payments.giveawayInfoResults#cd5570 flags:# winner:flags.0?true refunded:flags.1
|
|||
|
||||
prepaidGiveaway#b2539d54 id:long months:int quantity:int date:int = PrepaidGiveaway;
|
||||
|
||||
boost#53c300c8 flags:# gift:flags.1?true giveaway:flags.2?true unclaimed:flags.3?true id:string user_id:flags.0?long giveaway_msg_id:flags.2?int date:int expires:int used_gift_slug:flags.4?string = Boost;
|
||||
|
||||
premium.boostsList#86f8613c flags:# count:int boosts:Vector<Boost> next_offset:flags.0?string users:Vector<User> = premium.BoostsList;
|
||||
|
||||
myBoost#c448415c flags:# slot:int peer:flags.0?Peer date:int expires:int cooldown_until_date:flags.1?int = MyBoost;
|
||||
|
||||
premium.myBoosts#9ae228e2 my_boosts:Vector<MyBoost> chats:Vector<Chat> users:Vector<User> = premium.MyBoosts;
|
||||
|
||||
premium.boostsStatus#3d5daae6 flags:# my_boost:flags.2?true level:int current_level_boosts:int boosts:int gift_boosts:flags.3?int next_level_boosts:flags.0?int premium_audience:flags.1?StatsPercentValue boost_url:string prepaid_giveaways:flags.3?Vector<PrepaidGiveaway> my_boost_slots:flags.2?Vector<int> = premium.BoostsStatus;
|
||||
|
||||
---functions---
|
||||
|
||||
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
||||
|
@ -1715,6 +1718,7 @@ account.saveAutoSaveSettings#d69b8361 flags:# users:flags.0?true chats:flags.1?t
|
|||
account.deleteAutoSaveExceptions#53bc0020 = Bool;
|
||||
account.invalidateSignInCodes#ca8ae8ba codes:Vector<string> = Bool;
|
||||
account.updateColor#a001cc43 flags:# color:int background_emoji_id:flags.0?long = Bool;
|
||||
account.getDefaultBackgroundEmojis#a60ab9ce hash:long = EmojiList;
|
||||
|
||||
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
|
||||
users.getFullUser#b60f5918 id:InputUser = users.UserFull;
|
||||
|
@ -2161,7 +2165,8 @@ stories.getAllReadPeerStories#9b5ae7f9 = Updates;
|
|||
stories.getPeerMaxIDs#535983c3 id:Vector<InputPeer> = Vector<int>;
|
||||
stories.getChatsToSend#a56a8b60 = messages.Chats;
|
||||
stories.togglePeerStoriesHidden#bd0415c4 peer:InputPeer hidden:Bool = Bool;
|
||||
stories.getBoostsStatus#4c449472 peer:InputPeer = stories.BoostsStatus;
|
||||
stories.getBoostersList#337ef980 peer:InputPeer offset:string limit:int = stories.BoostersList;
|
||||
stories.canApplyBoost#db05c1bd peer:InputPeer = stories.CanApplyBoostResult;
|
||||
stories.applyBoost#f29d7c2b peer:InputPeer = Bool;
|
||||
|
||||
premium.getBoostsList#60f67660 flags:# gifts:flags.0?true peer:InputPeer offset:string limit:int = premium.BoostsList;
|
||||
premium.getMyBoosts#be77b4a = premium.MyBoosts;
|
||||
premium.applyBoost#46b6a16b flags:# slot:flags.0?int peer:InputPeer = Bool;
|
||||
premium.getBoostsStatus#42f1f61 peer:InputPeer = premium.BoostsStatus;
|
||||
|
|
|
@ -625,9 +625,9 @@ void SessionNavigation::resolveBoostState(not_null<ChannelData*> channel) {
|
|||
return;
|
||||
}
|
||||
_boostStateResolving = channel;
|
||||
_api.request(MTPstories_GetBoostsStatus(
|
||||
_api.request(MTPpremium_GetBoostsStatus(
|
||||
channel->input
|
||||
)).done([=](const MTPstories_BoostsStatus &result) {
|
||||
)).done([=](const MTPpremium_BoostsStatus &result) {
|
||||
_boostStateResolving = nullptr;
|
||||
const auto &data = result.data();
|
||||
const auto submit = [=](Fn<void(bool)> done) {
|
||||
|
@ -653,69 +653,95 @@ void SessionNavigation::resolveBoostState(not_null<ChannelData*> channel) {
|
|||
void SessionNavigation::applyBoost(
|
||||
not_null<ChannelData*> channel,
|
||||
Fn<void(bool)> done) {
|
||||
_api.request(MTPstories_CanApplyBoost(
|
||||
channel->input
|
||||
)).done([=](const MTPstories_CanApplyBoostResult &result) {
|
||||
result.match([&](const MTPDstories_canApplyBoostOk &) {
|
||||
applyBoostChecked(channel, done);
|
||||
}, [&](const MTPDstories_canApplyBoostReplace &data) {
|
||||
_session->data().processChats(data.vchats());
|
||||
const auto peer = _session->data().peer(
|
||||
peerFromMTP(data.vcurrent_boost()));
|
||||
replaceBoostConfirm(peer, channel, done);
|
||||
});
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
const auto type = error.type();
|
||||
if (type == u"PREMIUM_ACCOUNT_REQUIRED"_q) {
|
||||
const auto jumpToPremium = [=] {
|
||||
const auto id = peerToChannel(channel->id).bare;
|
||||
Settings::ShowPremium(
|
||||
parentController(),
|
||||
"channel_boost__" + QString::number(id));
|
||||
};
|
||||
uiShow()->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_boost_error_premium_text(
|
||||
Ui::Text::RichLangValue),
|
||||
.confirmed = jumpToPremium,
|
||||
.confirmText = tr::lng_boost_error_premium_yes(),
|
||||
.title = tr::lng_boost_error_premium_title(),
|
||||
}));
|
||||
} else if (type == u"PREMIUM_GIFTED_NOT_ALLOWED"_q) {
|
||||
uiShow()->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_boost_error_gifted_text(
|
||||
Ui::Text::RichLangValue),
|
||||
.title = tr::lng_boost_error_gifted_title(),
|
||||
.inform = true,
|
||||
}));
|
||||
} else if (type == u"BOOST_NOT_MODIFIED"_q) {
|
||||
_api.request(MTPpremium_GetMyBoosts(
|
||||
)).done([=](const MTPpremium_MyBoosts &result) {
|
||||
const auto &data = result.data();
|
||||
_session->data().processUsers(data.vusers());
|
||||
_session->data().processChats(data.vchats());
|
||||
const auto &list = data.vmy_boosts().v;
|
||||
if (list.isEmpty()) {
|
||||
if (!_session->premium()) {
|
||||
const auto jumpToPremium = [=] {
|
||||
const auto id = peerToChannel(channel->id).bare;
|
||||
Settings::ShowPremium(
|
||||
parentController(),
|
||||
"channel_boost__" + QString::number(id));
|
||||
};
|
||||
uiShow()->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_boost_error_premium_text(
|
||||
Ui::Text::RichLangValue),
|
||||
.confirmed = jumpToPremium,
|
||||
.confirmText = tr::lng_boost_error_premium_yes(),
|
||||
.title = tr::lng_boost_error_premium_title(),
|
||||
}));
|
||||
} else {
|
||||
uiShow()->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_boost_error_gifted_text(
|
||||
Ui::Text::RichLangValue),
|
||||
.title = tr::lng_boost_error_gifted_title(),
|
||||
.inform = true,
|
||||
}));
|
||||
}
|
||||
done(false);
|
||||
return;
|
||||
}
|
||||
auto already = false;
|
||||
auto different = PeerId();
|
||||
auto earliest = TimeId(-1);
|
||||
const auto now = base::unixtime::now();
|
||||
for (const auto &my : list) {
|
||||
const auto &data = my.data();
|
||||
const auto cooldown = data.vcooldown_until_date().value_or(0);
|
||||
const auto peerId = data.vpeer()
|
||||
? peerFromMTP(*data.vpeer())
|
||||
: PeerId();
|
||||
if (!peerId && cooldown <= now) {
|
||||
applyBoostChecked(channel, done);
|
||||
return;
|
||||
} else if (peerId != channel->id) {
|
||||
different = peerId;
|
||||
if (earliest < 0 || cooldown < earliest) {
|
||||
earliest = cooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (different) {
|
||||
if (earliest > now) {
|
||||
const auto seconds = earliest - now;
|
||||
const auto days = seconds / 86400;
|
||||
const auto hours = seconds / 3600;
|
||||
const auto minutes = seconds / 60;
|
||||
uiShow()->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_boost_error_flood_text(
|
||||
lt_left,
|
||||
rpl::single(Ui::Text::Bold((days > 1)
|
||||
? tr::lng_days(tr::now, lt_count, days)
|
||||
: (hours > 1)
|
||||
? tr::lng_hours(tr::now, lt_count, hours)
|
||||
: (minutes > 1)
|
||||
? tr::lng_minutes(tr::now, lt_count, minutes)
|
||||
: tr::lng_seconds(tr::now, lt_count, seconds))),
|
||||
Ui::Text::RichLangValue),
|
||||
.title = tr::lng_boost_error_flood_title(),
|
||||
.inform = true,
|
||||
}));
|
||||
done(false);
|
||||
} else {
|
||||
const auto peer = _session->data().peer(different);
|
||||
replaceBoostConfirm(peer, channel, done);
|
||||
}
|
||||
} else {
|
||||
uiShow()->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_boost_error_already_text(
|
||||
Ui::Text::RichLangValue),
|
||||
.title = tr::lng_boost_error_already_title(),
|
||||
.inform = true,
|
||||
}));
|
||||
} else if (type.startsWith(u"FLOOD_WAIT_"_q)) {
|
||||
const auto seconds = type.mid(u"FLOOD_WAIT_"_q.size()).toInt();
|
||||
const auto days = seconds / 86400;
|
||||
const auto hours = seconds / 3600;
|
||||
const auto minutes = seconds / 60;
|
||||
uiShow()->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_boost_error_flood_text(
|
||||
lt_left,
|
||||
rpl::single(Ui::Text::Bold((days > 1)
|
||||
? tr::lng_days(tr::now, lt_count, days)
|
||||
: (hours > 1)
|
||||
? tr::lng_hours(tr::now, lt_count, hours)
|
||||
: (minutes > 1)
|
||||
? tr::lng_minutes(tr::now, lt_count, minutes)
|
||||
: tr::lng_seconds(tr::now, lt_count, seconds))),
|
||||
Ui::Text::RichLangValue),
|
||||
.title = tr::lng_boost_error_flood_title(),
|
||||
.inform = true,
|
||||
}));
|
||||
} else {
|
||||
showToast(u"Error: "_q + type);
|
||||
done(false);
|
||||
}
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
const auto type = error.type();
|
||||
showToast(u"Error: "_q + type);
|
||||
done(false);
|
||||
}).handleFloodErrors().send();
|
||||
}
|
||||
|
@ -757,7 +783,9 @@ void SessionNavigation::replaceBoostConfirm(
|
|||
void SessionNavigation::applyBoostChecked(
|
||||
not_null<ChannelData*> channel,
|
||||
Fn<void(bool)> done) {
|
||||
_api.request(MTPstories_ApplyBoost(
|
||||
_api.request(MTPpremium_ApplyBoost(
|
||||
MTP_flags(0),
|
||||
MTPint(), // slot
|
||||
channel->input
|
||||
)).done([=](const MTPBool &result) {
|
||||
done(true);
|
||||
|
|
Loading…
Add table
Reference in a new issue