Files
tdesktop/Telegram/SourceFiles/api/api_chat_links.h
allhaileris afb81b8278
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
init
2026-02-16 15:50:16 +03:00

65 lines
1.3 KiB
C++

/*
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
class ApiWrap;
namespace Api {
struct ChatLink {
QString link;
QString title;
TextWithEntities message;
int clicks = 0;
};
struct ChatLinkUpdate {
QString was;
std::optional<ChatLink> now;
};
class ChatLinks final {
public:
explicit ChatLinks(not_null<ApiWrap*> api);
using Link = ChatLink;
using Update = ChatLinkUpdate;
void create(
const QString &title,
const TextWithEntities &message,
Fn<void(Link)> done = nullptr);
void edit(
const QString &link,
const QString &title,
const TextWithEntities &message,
Fn<void(Link)> done = nullptr);
void destroy(
const QString &link,
Fn<void()> done = nullptr);
void preload();
[[nodiscard]] const std::vector<ChatLink> &list() const;
[[nodiscard]] bool loaded() const;
[[nodiscard]] rpl::producer<> loadedUpdates() const;
[[nodiscard]] rpl::producer<Update> updates() const;
private:
const not_null<ApiWrap*> _api;
std::vector<Link> _list;
rpl::event_stream<> _loadedUpdates;
mtpRequestId _requestId = 0;
bool _loaded = false;
rpl::event_stream<Update> _updates;
};
} // namespace Api