Skip to content

Commit

Permalink
other
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Oct 16, 2024
1 parent dfc47d3 commit 2b48cb4
Show file tree
Hide file tree
Showing 48 changed files with 1,257 additions and 111 deletions.
12 changes: 9 additions & 3 deletions Telegram/SourceFiles/history/history_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,9 @@ class HistoryItem final : public RuntimeComposer<HistoryItem> {
#if 0 // mtp
void updateReactionsUnknown();
#endif
void updateReactions(const QVector<Tdb::TLmessageReaction> &list);
void updateReactions(
const QVector<Tdb::TLmessageReaction> &list,
bool areTags);
void updateUnreadReactions(const QVector<Tdb::TLunreadReaction> &list);
[[nodiscard]] auto reactions() const
-> const std::vector<Data::MessageReaction> &;
Expand All @@ -514,6 +516,7 @@ class HistoryItem final : public RuntimeComposer<HistoryItem> {
#if 0 // mtp
[[nodiscard]] crl::time lastReactionsRefreshTime() const;
#endif
[[nodiscard]] bool selfDestructImmediate() const;

[[nodiscard]] bool reactionsAreTags() const;
[[nodiscard]] bool hasDirectLink() const;
Expand Down Expand Up @@ -688,9 +691,11 @@ class HistoryItem final : public RuntimeComposer<HistoryItem> {
void applyContent(const Tdb::TLmessageContent &content);
void setReactions(
const QVector<Tdb::TLmessageReaction> &list,
const QVector<Tdb::TLunreadReaction> &unread);
const QVector<Tdb::TLunreadReaction> &unread,
bool areTags);
[[nodiscard]] bool changeReactions(
const QVector<Tdb::TLmessageReaction> &list);
const QVector<Tdb::TLmessageReaction> &list,
bool areTags);
[[nodiscard]] bool changeUnreadReactions(
const QVector<Tdb::TLunreadReaction> &list);
void setMedia(const Tdb::TLmessageContent &content);
Expand Down Expand Up @@ -724,6 +729,7 @@ class HistoryItem final : public RuntimeComposer<HistoryItem> {
[[nodiscard]] PreparedServiceText preparePinnedText();
[[nodiscard]] PreparedServiceText prepareGameScoreText();
[[nodiscard]] PreparedServiceText preparePaymentSentText();
[[nodiscard]] PreparedServiceText preparePaymentRefundText();
[[nodiscard]] PreparedServiceText prepareStoryMentionText();
[[nodiscard]] PreparedServiceText prepareInvitedToCallText(
const std::vector<not_null<UserData*>> &users,
Expand Down
6 changes: 6 additions & 0 deletions Telegram/SourceFiles/history/history_item_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,10 @@ void ClearMediaAsExpired(not_null<HistoryItem*> item) {
return;
}
if (const auto document = media->document()) {
#if 0 // mtp
item->applyEditionToHistoryCleared();
#endif
AssertIsDebug();
auto text = (document->isVideoFile()
? tr::lng_ttl_video_expired
: document->isVoiceMessage()
Expand All @@ -1004,7 +1007,10 @@ void ClearMediaAsExpired(not_null<HistoryItem*> item) {
: tr::lng_message_empty)(tr::now, Ui::Text::WithEntities);
item->updateServiceText(PreparedServiceText{ std::move(text) });
} else if (const auto photo = media->photo()) {
#if 0 // mtp
item->applyEditionToHistoryCleared();
#endif
AssertIsDebug();
item->updateServiceText(PreparedServiceText{
tr::lng_ttl_photo_expired(tr::now, Ui::Text::WithEntities)
});
Expand Down
7 changes: 3 additions & 4 deletions Telegram/SourceFiles/history/history_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct AutocompleteQuery;
namespace Tdb {
class TLmessages;
class TLmessage;
class TLwebPage;
class TLlinkPreview;
class Error;
} // namespace Tdb

Expand Down Expand Up @@ -571,7 +571,7 @@ class HistoryWidget final

void gotPreview(
QString links,
const Tdb::TLwebPage &page,
const Tdb::TLlinkPreview &page,
mtpRequestId requestId);
void messagesReceived(
not_null<PeerData*> peer,
Expand Down Expand Up @@ -737,17 +737,16 @@ class HistoryWidget final

MsgId _delayedShowAtMsgId = -1;
TextWithEntities _delayedShowAtMsgHighlightPart;
#endif
int _delayedShowAtMsgHighlightPartOffsetHint = 0;
int _delayedShowAtRequest = 0; // Not real mtpRequestId.
#endif

Tdb::RequestId _firstLoadRequest = 0;
Tdb::RequestId _preloadRequest = 0;
Tdb::RequestId _preloadDownRequest = 0;

MsgId _delayedShowAtMsgId = -1;
TextWithEntities _delayedShowAtMsgHighlightPart;
Tdb::RequestId _delayedShowAtRequest = 0;

History *_supportPreloadHistory = nullptr;
#if 0 // mtp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void WebpageResolver::request(const QString &link, bool force) {
_resolved.fire_copy(link);
};
#endif
const auto done = [=](const TLwebPage &result) {
const auto done = [=](const TLlinkPreview &result) {
const auto page = _session->data().processWebpage(result);
if (page->pendingTill > 0
&& page->pendingTill < base::unixtime::now()) {
Expand All @@ -173,10 +173,10 @@ void WebpageResolver::request(const QString &link, bool force) {
};
_requestLink = link;

_requestId = _api.request(TLgetWebPagePreview(
_requestId = _api.request(TLgetLinkPreview(
tl_formattedText(tl_string(link), tl_vector<TLtextEntity>()),
std::nullopt
)).done([=](const TLwebPage &result, mtpRequestId requestId) {
)).done([=](const TLlinkPreview &result, mtpRequestId requestId) {
if (_requestId == requestId) {
_requestId = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1060,9 +1060,11 @@ auto BusinessBotStatus::PeerState(not_null<PeerData*> peer)
}

void BusinessBotStatus::setupState(not_null<PeerData*> peer) {
#if 0 // mtp
if (!BarCurrentlyHidden(peer)) {
peer->session().api().requestPeerSettings(peer);
}
#endif
PeerState(
peer
) | rpl::start_with_next([=](State state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For license and copyright information please follow this link:
#include "history/history.h"
#include "history/history_item.h"

#include "tdb/tdb_scheme.h"
#include "tdb/tdb_tl_scheme.h"

namespace HistoryView {
namespace {
Expand Down Expand Up @@ -61,9 +61,12 @@ PeerId GenerateUser(not_null<History*> history, const QString &name) {
null, // profile_photo_
tl_int32(Data::DecideColorIndex(peerId)),
tl_int64(0), // background_custom_emoji_id_
tl_int32(0), // profile_accent_color_id_
tl_int64(0), // profile_background_custom_emoji_id_
null, // emoji_status_
tl_bool(false), // is_contact_
tl_bool(false), // is_mutual_contact_
tl_bool(false), // is_close_friend_
tl_bool(false), // is_verified_
tl_bool(false), // is_premium_
tl_bool(false), // is_support_
Expand All @@ -72,6 +75,7 @@ PeerId GenerateUser(not_null<History*> history, const QString &name) {
tl_bool(false), // is_fake_
tl_bool(false), // has_active_stories_
tl_bool(false), // has_unread_active_stories_
tl_bool(false), // restricts_new_chats
tl_bool(true), // have_access_
tl_userTypeRegular(), // type_
TLstring(), // language_code_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ auto GenerateGiveawayStart(
not_null<Data::GiveawayStart*> data)
#endif
not_null<Data::GiveawayStart*> data,
DocumentData *sticker)
DocumentData *passedSticker)
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
return [=](Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
const auto months = data->months;
Expand All @@ -47,7 +47,7 @@ auto GenerateGiveawayStart(
.sticker = packs.lookup(months),
#endif
return Data{
.sticker = sticker,
.sticker = passedSticker,
.size = st::msgServiceGiftBoxStickerSize,
.singleTimePlayback = true,
};
Expand Down Expand Up @@ -180,15 +180,11 @@ auto GenerateGiveawayResults(

using Data = StickerWithBadgePart::Data;
const auto sticker = [=] {
#if 0 // mtp
const auto &session = parent->history()->session();
auto &packs = session.diceStickersPacks();
const auto &emoji = Stickers::DicePacks::kPartyPopper;
return Data{
.sticker = packs.lookup(emoji, 0),
#endif
return Data{
.sticker = sticker,
.skipTop = st::chatGiveawayWinnersTopSkip,
.singleTimePlayback = true,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ class MediaGenericPart;
not_null<Data::GiveawayStart*> data)
#endif
not_null<Data::GiveawayStart*> data,
DocumentData *sticker)
DocumentData *passedSticker)
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)>;

[[nodiscard]] auto GenerateGiveawayResults(
not_null<Element*> parent,
#if 0 // mtp
not_null<Data::GiveawayResults*> data)
#endif
not_null<Data::GiveawayResults*> data,
DocumentData *sticker)
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)>;

} // namespace HistoryView
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ ClickHandlerPtr MakePaidMediaLink(not_null<HistoryItem*> item) {
if (result != Result::Paid) {
return;
} else if (const auto item = session->data().message(itemId)) {
#if 0 // mtp
session->api().views().pollExtendedMedia(item, true);
#endif
if (const auto strong = weak.get()) {
ShowPaidMediaUnlockedToast(strong, item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ For license and copyright information please follow this link:
#include "window/themes/window_theme.h"
#include "styles/style_chat.h"

#include "tdb/tdb_sender.h"
#include "tdb/tdb_tl_scheme.h"

namespace HistoryView {
namespace {

using namespace Tdb;

[[nodiscard]] bool WallPaperRevertable(
not_null<PeerData*> peer,
const Data::WallPaper &paper) {
Expand Down Expand Up @@ -545,6 +550,7 @@ ClickHandlerPtr ThemeDocumentBox::createViewLink() {
&& !view->data()->out()
&& WallPaperRevertable(view->data())) {
const auto reset = crl::guard(weak, [=](Fn<void()> close) {
#if 0 // mtp
const auto api = &controller->session().api();
api->request(MTPmessages_SetChatWallPaper(
MTP_flags(MTPmessages_SetChatWallPaper::Flag::f_revert),
Expand All @@ -555,6 +561,12 @@ ClickHandlerPtr ThemeDocumentBox::createViewLink() {
)).done([=](const MTPUpdates &result) {
api->applyUpdates(result);
}).send();
#endif
controller->session().sender().request(
TLdeleteChatBackground(
peerToTdbChat(view->data()->history()->peer->id),
tl_bool(true))
).send();
close();
});
controller->show(Ui::MakeConfirmBox({
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/info/bot/earn/info_bot_earn_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ void InnerWidget::load() {
_loaded.fire(true);
fill();

AssertIsDebug();
#if 0 // mtp
_peer->session().account().mtpUpdates(
) | rpl::start_with_next([=](const MTPUpdates &updates) {
using TL = MTPDupdateStarsRevenueStatus;
Expand All @@ -110,6 +112,7 @@ void InnerWidget::load() {
}
});
}, lifetime());
#endif
});
}, lifetime());
}
Expand Down
22 changes: 16 additions & 6 deletions Telegram/SourceFiles/info/profile/info_profile_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ base::options::toggle ShowPeerIdBelowAbout({
" Add contact IDs to exported data.",
});

[[nodiscard]] rpl::producer<QString> PeerOrTopicLinkValue(
[[nodiscard]] rpl::producer<LinkWithUrl> PeerOrTopicLinkValue(
not_null<PeerData*> peer,
MsgId topicRootId) {
if (!topicRootId) {
Expand All @@ -109,18 +109,22 @@ base::options::toggle ShowPeerIdBelowAbout({
sender->request(*requestId).cancel();
delete requestId;
});
LinkValue(peer, true) | rpl::start_with_next([=](QString link) {
if (link.isEmpty()) {
consumer.put_next(QString());
LinkValue(peer, true) | rpl::start_with_next([=](LinkWithUrl link) {
if (link.url.isEmpty()) {
consumer.put_next({});
}
sender->request(*requestId).cancel();
*requestId = sender->request(TLgetForumTopicLink(
peerToTdbChat(peer->id),
tl_int53(topicRootId.bare)
)).done([=](const TLDmessageLink &result) {
consumer.put_next_copy(result.vlink().v);
const auto url = result.vlink().v;
consumer.put_next({
.text = url,
.url = url,
});
}).fail([=] {
consumer.put_next(QString());
consumer.put_next({});
}).send();
}, lifetime);

Expand Down Expand Up @@ -913,10 +917,16 @@ void ReportReactionBox(
ChatRestrictionsInfo());
}
}
#if 0 // mtp
data.group->session().api().request(MTPmessages_ReportReaction(
data.group->input,
MTP_int(data.messageId.bare),
participant->input
#endif
data.group->session().sender().request(TLreportMessageReactions(
peerToTdbChat(data.group->id),
tl_int53(data.messageId.bare),
peerToSender(participant->id)
)).done(crl::guard(controller, [=] {
controller->showToast(tr::lng_report_thanks(tr::now));
})).send();
Expand Down
12 changes: 7 additions & 5 deletions Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ constexpr auto kRefreshBotsTimeout = 60 * 60 * crl::time(1000);

[[nodiscard]] Ui::LocationPickerConfig ResolveMapsConfig(
not_null<Main::Session*> session) {
return {};
#if 0 // tdlib todo
const auto &appConfig = session->appConfig();
auto map = appConfig.get<base::flat_map<QString, QString>>(
u"tdesktop_config_map"_q,
Expand All @@ -222,6 +224,7 @@ constexpr auto kRefreshBotsTimeout = 60 * 60 * crl::time(1000);
.mapsToken = map[u"maps"_q],
.geoToken = map[u"geo"_q],
};
#endif
}

[[nodiscard]] Window::SessionController *WindowForThread(
Expand Down Expand Up @@ -785,7 +788,6 @@ void WebViewInstance::resolveApp(
_requestId = 0;
_app = std::make_unique<BotAppData>(&_session->data(), BotAppId());
_app->apply(_bot->id, data.vweb_app());
_app->hasSettings = data.vsupports_settings().v;
const auto firstTime = !data.vskip_confirmation().v;
const auto confirm = firstTime || forceConfirmation;
const auto writeAccess = data.vrequest_write_access().v;
Expand Down Expand Up @@ -1000,7 +1002,7 @@ void WebViewInstance::requestApp(bool allowWrite) {
peerToTdbChat(_context.action->history->peer->id),
tl_int53(peerToUser(_app->botId).bare),
tl_string(_app->shortName),
tl_string(_appStartCommand),
tl_string(_appStartParam),
Window::Theme::WebViewTheme(),
tl_string("tdesktop"),
tl_bool(allowWrite)
Expand Down Expand Up @@ -1807,15 +1809,15 @@ void AttachWebView::resolveUsername(
#endif
_session->sender().request(base::take(_requestId)).cancel();
_requestId = _session->sender().request(TLsearchPublicChat(
tl_string(username)
tl_string(_botUsername)
)).done([=](const TLchat &result) {
_requestId = 0;
done(_session->data().processPeer(result));
}).fail([=](const Error &error) {
_requestId = 0;
if (error.code == 400) {
showToast(
tr::lng_username_not_found(tr::now, lt_user, username));
show->showToast(
tr::lng_username_not_found(tr::now, lt_user, _botUsername));
}
}).send();
}
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/inline_bots/inline_bot_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ std::unique_ptr<Result> Result::Create(
if (!point) {
return;
}
const auto scale = 1 + (cScale() * cIntRetinaFactor()) / 200;
const auto scale = 1 + (cScale() * style::DevicePixelRatio()) / 200;
const auto zoom = 15 + (scale - 1);
const auto w = st::inlineThumbSize / scale;
const auto h = st::inlineThumbSize / scale;
Expand Down
Loading

0 comments on commit 2b48cb4

Please sign in to comment.