Update API scheme on layer 145.

This commit is contained in:
John Preston 2022-08-29 10:10:15 +04:00
parent da6d580348
commit d9a6d5f508
6 changed files with 68 additions and 34 deletions

View file

@ -3010,6 +3010,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_admin_log_messages_ttl_removed" = "{from} disabled messages auto-deletion after {duration}";
"lng_admin_log_reactions_disabled" = "{from} disabled reactions";
"lng_admin_log_reactions_updated" = "{from} updated the list of allowed reactions to: {emoji}";
"lng_admin_log_reactions_allowed_all" = "{from} allowed all reactions";
"lng_admin_log_reactions_allowed_official" = "{from} allowed all official reactions";
"lng_admin_log_edited_invite_link" = "edited invite link {link}";
"lng_admin_log_invite_link_expire_date" = "Expire date: {previous} -> {limit}";
"lng_admin_log_invite_link_usage_limit" = "Usage limit: {previous} -> {limit}";

View file

@ -584,6 +584,7 @@ inputStickerSetAnimatedEmoji#28703c8 = InputStickerSet;
inputStickerSetDice#e67f520e emoticon:string = InputStickerSet;
inputStickerSetAnimatedEmojiAnimations#cde3739 = InputStickerSet;
inputStickerSetPremiumGifts#c88b3b02 = InputStickerSet;
inputStickerSetEmojiGenericAnimations#4c4d4ce = InputStickerSet;
stickerSet#2dd14edc flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true videos:flags.6?true emojis:flags.7?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector<PhotoSize> thumb_dc_id:flags.4?int thumb_version:flags.4?int thumb_document_id:flags.8?long count:int hash:int = StickerSet;
@ -947,7 +948,7 @@ channelAdminLogEventActionChangeHistoryTTL#6e941a38 prev_value:int new_value:int
channelAdminLogEventActionParticipantJoinByRequest#afb6144a invite:ExportedChatInvite approved_by:long = ChannelAdminLogEventAction;
channelAdminLogEventActionToggleNoForwards#cb2ac766 new_value:Bool = ChannelAdminLogEventAction;
channelAdminLogEventActionSendMessage#278f2868 message:Message = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeAvailableReactions#9cf7f76a prev_value:Vector<string> new_value:Vector<string> = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 prev_value:ChatReactions new_value:ChatReactions = ChannelAdminLogEventAction;
channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent;
@ -1436,7 +1437,7 @@ emailVerificationApple#96d074fd token:string = EmailVerification;
account.emailVerified#2b96cd1b email:string = account.EmailVerified;
account.emailVerifiedLogin#e1bb0d61 email:string sent_code:auth.SentCode = account.EmailVerified;
premiumSubscriptionOption#b6f11ebe flags:# months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumSubscriptionOption;
premiumSubscriptionOption#b6f11ebe flags:# current:flags.0?true can_purchase_upgrade:flags.1?true months:int currency:string amount:long bot_url:string store_product:flags.0?string = PremiumSubscriptionOption;
---functions---
@ -1737,9 +1738,9 @@ messages.searchSentMedia#107e31a0 q:string filter:MessagesFilter limit:int = mes
messages.getAttachMenuBots#16fcc2cb hash:long = AttachMenuBots;
messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot;
messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool;
messages.requestWebView#91b15831 flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = WebViewResult;
messages.requestWebView#fc87a53c flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = WebViewResult;
messages.prolongWebView#ea5fbcce flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = Bool;
messages.requestSimpleWebView#6abb2f73 flags:# bot:InputUser url:string theme_params:flags.0?DataJSON = SimpleWebViewResult;
messages.requestSimpleWebView#299bec8e flags:# bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult;
messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent;
messages.sendWebViewData#dc0242c8 bot:InputUser random_id:long button_text:string data:string = Updates;
messages.transcribeAudio#269e9a49 peer:InputPeer msg_id:int = messages.TranscribedAudio;

View file

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_file_origin.h"
#include "data/data_user.h"
#include "data/data_session.h"
#include "data/data_message_reaction_id.h"
#include "lang/lang_keys.h"
#include "ui/text/format_values.h"
#include "ui/text/text_utilities.h"
@ -28,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "core/click_handler_types.h"
#include "main/main_session.h"
#include "window/notifications_manager.h"
#include "window/window_session_controller.h"
#include "facades.h"
@ -1474,23 +1476,40 @@ void GenerateItems(
const auto createChangeAvailableReactions = [&](
const LogEventActionChangeAvailableReactions &data) {
auto list = QStringList();
for (const auto &emoji : data.vnew_value().v) {
list.append(qs(emoji));
}
const auto text = list.isEmpty()
? tr::lng_admin_log_reactions_disabled(
const auto text = data.vnew_value().match([&](
const MTPDchatReactionsNone&) {
return tr::lng_admin_log_reactions_disabled(
tr::now,
lt_from,
fromLinkText,
Ui::Text::WithEntities)
: tr::lng_admin_log_reactions_updated(
Ui::Text::WithEntities);
}, [&](const MTPDchatReactionsSome &data) {
using namespace Window::Notifications;
auto list = TextWithEntities();
for (const auto &one : data.vreactions().v) {
if (!list.empty()) {
list.append(", ");
}
list.append(Manager::ComposeReactionEmoji(
session,
Data::ReactionFromMTP(one)));
}
return tr::lng_admin_log_reactions_updated(
tr::now,
lt_from,
fromLinkText,
lt_emoji,
{ .text = list.join(", ") },
list,
Ui::Text::WithEntities);
}, [&](const MTPDchatReactionsAll &data) {
return (data.is_allow_custom()
? tr::lng_admin_log_reactions_allowed_all
: tr::lng_admin_log_reactions_allowed_official)(
tr::now,
lt_from,
fromLinkText,
Ui::Text::WithEntities);
});
addSimpleServiceMessage(text);
};

View file

@ -463,6 +463,7 @@ void AttachWebView::request(const WebViewButton &button) {
MTP_bytes(button.url),
MTP_string(_startCommand),
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams().json)),
MTP_string("tdesktop"),
MTPint(), // reply_to_msg_id
MTPInputPeer() // send_as
)).done([=](const MTPWebViewResult &result) {
@ -678,7 +679,8 @@ void AttachWebView::requestSimple(const WebViewButton &button) {
MTP_flags(Flag::f_theme_params),
_bot->inputUser,
MTP_bytes(button.url),
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams().json))
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams().json)),
MTP_string("tdesktop")
)).done([=](const MTPSimpleWebViewResult &result) {
_requestId = 0;
result.match([&](const MTPDsimpleWebViewResultUrl &data) {
@ -709,6 +711,7 @@ void AttachWebView::requestMenu(
MTP_string(url),
MTPstring(), // url
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams().json)),
MTP_string("tdesktop"),
MTPint(), // reply_to_msg_id
MTPInputPeer() // send_as
)).done([=](const MTPWebViewResult &result) {

View file

@ -780,30 +780,36 @@ Manager::DisplayOptions Manager::getNotificationOptions(
return result;
}
TextWithEntities Manager::ComposeReactionEmoji(
not_null<Main::Session*> session,
const Data::ReactionId &reaction) {
if (const auto emoji = std::get_if<QString>(&reaction.data)) {
return TextWithEntities{ *emoji };
}
const auto id = v::get<DocumentId>(reaction.data);
auto entities = EntitiesInText();
const auto document = session->data().document(id);
const auto sticker = document->sticker();
const auto text = sticker ? sticker->alt : PlaceholderReactionText();
return TextWithEntities{
text,
{
EntityInText(
EntityType::CustomEmoji,
0,
text.size(),
Data::SerializeCustomEmojiId(Data::CustomEmojiId{ id }))
}
};
}
TextWithEntities Manager::ComposeReactionNotification(
not_null<HistoryItem*> item,
const Data::ReactionId &reaction,
bool hideContent) {
const auto reactionWithEntities = [&] {
if (const auto emoji = std::get_if<QString>(&reaction.data)) {
return TextWithEntities{ *emoji };
}
const auto id = v::get<DocumentId>(reaction.data);
auto entities = EntitiesInText();
const auto document = item->history()->owner().document(id);
const auto sticker = document->sticker();
const auto text = sticker ? sticker->alt : PlaceholderReactionText();
return TextWithEntities{
text,
{
EntityInText(
EntityType::CustomEmoji,
0,
text.size(),
Data::SerializeCustomEmojiId(Data::CustomEmojiId{ id }))
}
};
}();
const auto reactionWithEntities = ComposeReactionEmoji(
&item->history()->session(),
reaction);
const auto simple = [&](const auto &phrase) {
return phrase(
tr::now,

View file

@ -267,6 +267,9 @@ public:
[[nodiscard]] DisplayOptions getNotificationOptions(
HistoryItem *item,
ItemNotificationType type) const;
[[nodiscard]] static TextWithEntities ComposeReactionEmoji(
not_null<Main::Session*> session,
const Data::ReactionId &reaction);
[[nodiscard]] static TextWithEntities ComposeReactionNotification(
not_null<HistoryItem*> item,
const Data::ReactionId &reaction,