Update API scheme on layer 186.

This commit is contained in:
John Preston 2024-08-12 09:58:07 +02:00
parent d34d3a796d
commit 56959398e2
6 changed files with 39 additions and 17 deletions

View file

@ -140,10 +140,10 @@ constexpr auto kPaidAccumulatePeriod = 5 * crl::time(1000) + 500;
[[nodiscard]] bool IsMyTop(
const MTPDmessageReactor &data,
not_null<PeerData*> peer,
PeerData *peer,
const std::vector<MessageReactionsTopPaid> &top,
bool min) {
if (peer->isSelf()) {
if (peer && peer->isSelf()) {
return true;
} else if (!min) {
return data.is_my();
@ -1720,6 +1720,7 @@ void Reactions::sendPaidRequest(not_null<HistoryItem*> item, int count) {
const auto randomId = base::unixtime::mtproto_msg_id();
auto &api = _owner->session().api();
const auto requestId = api.request(MTPmessages_SendPaidReaction(
MTP_flags(0),
item->history()->peer->input,
MTP_int(id.msg),
MTP_int(count),
@ -2048,7 +2049,10 @@ bool MessageReactions::change(
const auto &paindTopNow = _paid ? _paid->top : std::vector<TopPaid>();
for (const auto &reactor : top) {
const auto &data = reactor.data();
const auto peer = owner.peer(peerFromMTP(data.vpeer_id()));
const auto peerId = (data.is_anonymous() || !data.vpeer_id())
? PeerId()
: peerFromMTP(*data.vpeer_id());
const auto peer = peerId ? owner.peer(peerId).get() : nullptr;
paidTop.push_back({
.peer = peer,
.count = uint32(data.vcount().v),

View file

@ -359,7 +359,7 @@ struct RecentReaction {
};
struct MessageReactionsTopPaid {
not_null<PeerData*> peer;
PeerData *peer = nullptr;
uint32 count : 30 = 0;
uint32 top : 1 = 0;
uint32 my : 1 = 0;

View file

@ -74,6 +74,14 @@ PeerId FakePeerIdForJustName(const QString &name) {
return peerFromUser(kShift + std::abs(base));
}
bool UnavailableReason::sensitive() const {
return reason == u"sensitive"_q;
}
UnavailableReason UnavailableReason::Sensitive() {
return { u"sensitive"_q };
}
bool ApplyBotMenuButton(
not_null<BotInfo*> info,
const MTPBotMenuButton *button) {
@ -505,12 +513,20 @@ QString PeerData::computeUnavailableReason() const {
auto &&filtered = ranges::views::all(
list
) | ranges::views::filter([&](const Data::UnavailableReason &reason) {
return !ranges::contains(skip, reason.reason);
return !reason.sensitive()
&& !ranges::contains(skip, reason.reason);
});
const auto first = filtered.begin();
return (first != filtered.end()) ? first->text : QString();
}
bool PeerData::isUnavailableSensitive() const {
return ranges::contains(
unavailableReasons(),
true,
&Data::UnavailableReason::sensitive);
}
// This is duplicated in CanPinMessagesValue().
bool PeerData::canPinMessages() const {
if (const auto user = asUser()) {

View file

@ -89,12 +89,12 @@ struct UnavailableReason {
QString reason;
QString text;
bool operator==(const UnavailableReason &other) const {
return (reason == other.reason) && (text == other.text);
}
bool operator!=(const UnavailableReason &other) const {
return !(*this == other);
}
friend inline bool operator==(
const UnavailableReason &,
const UnavailableReason &) = default;
[[nodiscard]] bool sensitive() const;
[[nodiscard]] static UnavailableReason Sensitive();
};
bool ApplyBotMenuButton(
@ -340,6 +340,7 @@ public:
// If this string is not empty we must not allow to open the
// conversation and we must show this string instead.
[[nodiscard]] QString computeUnavailableReason() const;
[[nodiscard]] bool isUnavailableSensitive() const;
[[nodiscard]] ClickHandlerPtr createOpenLink();
[[nodiscard]] const ClickHandlerPtr &openLink() {

View file

@ -133,7 +133,7 @@ std::vector<UnavailableReason> ExtractUnavailableReasons(
return ranges::views::all(
restrictions
) | ranges::views::filter([](const MTPRestrictionReason &restriction) {
return restriction.match([&](const MTPDrestrictionReason &data) {
return restriction.match([&](const auto &data) {
const auto platform = qs(data.vplatform());
return false
#ifdef OS_MAC_STORE

View file

@ -605,7 +605,7 @@ auth.passwordRecovery#137948a5 email_pattern:string = auth.PasswordRecovery;
receivedNotifyMessage#a384b779 id:int flags:int = ReceivedNotifyMessage;
chatInviteExported#93f2df18 flags:# revoked:flags.0?true permanent:flags.5?true request_needed:flags.6?true link:string admin_id:long date:int start_date:flags.4?int expire_date:flags.1?int usage_limit:flags.2?int usage:flags.3?int requested:flags.7?int title:flags.8?string subscription_pricing:flags.9?StarsSubscriptionPricing = ExportedChatInvite;
chatInviteExported#a22cbd96 flags:# revoked:flags.0?true permanent:flags.5?true request_needed:flags.6?true link:string admin_id:long date:int start_date:flags.4?int expire_date:flags.1?int usage_limit:flags.2?int usage:flags.3?int requested:flags.7?int subscription_expired:flags.10?int title:flags.8?string subscription_pricing:flags.9?StarsSubscriptionPricing = ExportedChatInvite;
chatInvitePublicJoinRequests#ed107ab7 = ExportedChatInvite;
chatInviteAlready#5a686d7c chat:Chat = ChatInvite;
@ -631,7 +631,7 @@ messages.stickerSetNotModified#d3f924eb = messages.StickerSet;
botCommand#c27ac8c7 command:string description:string = BotCommand;
botInfo#8f300b57 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector<BotCommand> menu_button:flags.3?BotMenuButton = BotInfo;
botInfo#82437e74 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector<BotCommand> menu_button:flags.3?BotMenuButton privacy_policy_url:flags.7?string = BotInfo;
keyboardButton#a2fa4880 text:string = KeyboardButton;
keyboardButtonUrl#258aff05 text:string url:string = KeyboardButton;
@ -1846,7 +1846,7 @@ starsSubscriptionPricing#5416d58 period:int amount:long = StarsSubscriptionPrici
starsSubscription#538ecf18 flags:# canceled:flags.0?true can_refulfill:flags.1?true missing_balance:flags.2?true id:string peer:Peer until_date:int pricing:StarsSubscriptionPricing chat_invite_hash:flags.3?string = StarsSubscription;
messageReactor#ef00d448 flags:# top:flags.0?true my:flags.1?true peer_id:Peer count:int = MessageReactor;
messageReactor#4ba3a95a flags:# top:flags.0?true my:flags.1?true anonymous:flags.2?true peer_id:flags.3?Peer count:int = MessageReactor;
---functions---
@ -2167,7 +2167,7 @@ messages.editExportedChatInvite#bdca2f75 flags:# revoked:flags.2?true peer:Input
messages.deleteRevokedExportedChatInvites#56987bd5 peer:InputPeer admin_id:InputUser = Bool;
messages.deleteExportedChatInvite#d464a42b peer:InputPeer link:string = Bool;
messages.getAdminsWithInvites#3920e6ef peer:InputPeer = messages.ChatAdminsWithInvites;
messages.getChatInviteImporters#df04dd4e flags:# requested:flags.0?true peer:InputPeer link:flags.1?string q:flags.2?string offset_date:int offset_user:InputUser limit:int = messages.ChatInviteImporters;
messages.getChatInviteImporters#df04dd4e flags:# requested:flags.0?true subscription_expired:flags.3?true peer:InputPeer link:flags.1?string q:flags.2?string offset_date:int offset_user:InputUser limit:int = messages.ChatInviteImporters;
messages.setHistoryTTL#b80e5fe4 peer:InputPeer period:int = Updates;
messages.checkHistoryImportPeer#5dc60f03 peer:InputPeer = messages.CheckedHistoryImportPeer;
messages.setChatTheme#e63be13f peer:InputPeer emoticon:string = Updates;
@ -2244,7 +2244,8 @@ messages.editFactCheck#589ee75 peer:InputPeer msg_id:int text:TextWithEntities =
messages.deleteFactCheck#d1da940c peer:InputPeer msg_id:int = Updates;
messages.getFactCheck#b9cdc5ee peer:InputPeer msg_id:Vector<int> = Vector<FactCheck>;
messages.requestMainWebView#c9e01e7b flags:# compact:flags.7?true peer:InputPeer bot:InputUser start_param:flags.1?string theme_params:flags.0?DataJSON platform:string = WebViewResult;
messages.sendPaidReaction#1e55d333 peer:InputPeer msg_id:int count:int random_id:long = Updates;
messages.sendPaidReaction#25c8fe3e flags:# private:flags.0?true peer:InputPeer msg_id:int count:int random_id:long = Updates;
messages.togglePaidReactionPrivacy#849ad397 peer:InputPeer msg_id:int private:Bool = Bool;
updates.getState#edd4882a = updates.State;
updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference;