init
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
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
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
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
74
Telegram/SourceFiles/api/api_blocked_peers.h
Normal file
74
Telegram/SourceFiles/api/api_blocked_peers.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
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
|
||||
|
||||
#include "mtproto/sender.h"
|
||||
|
||||
class ApiWrap;
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Api {
|
||||
|
||||
class BlockedPeers final {
|
||||
public:
|
||||
struct Slice {
|
||||
struct Item {
|
||||
PeerId id;
|
||||
TimeId date = 0;
|
||||
|
||||
bool operator==(const Item &other) const;
|
||||
bool operator!=(const Item &other) const;
|
||||
};
|
||||
|
||||
QVector<Item> list;
|
||||
int total = 0;
|
||||
|
||||
bool operator==(const Slice &other) const;
|
||||
bool operator!=(const Slice &other) const;
|
||||
};
|
||||
|
||||
explicit BlockedPeers(not_null<ApiWrap*> api);
|
||||
|
||||
void reload();
|
||||
rpl::producer<Slice> slice();
|
||||
void request(int offset, Fn<void(Slice)> done);
|
||||
|
||||
void block(not_null<PeerData*> peer);
|
||||
void unblock(
|
||||
not_null<PeerData*> peer,
|
||||
Fn<void(bool success)> done = nullptr,
|
||||
bool force = false);
|
||||
|
||||
private:
|
||||
struct Request {
|
||||
std::vector<Fn<void(bool success)>> callbacks;
|
||||
mtpRequestId requestId = 0;
|
||||
bool blocking = false;
|
||||
};
|
||||
|
||||
[[nodiscard]] bool blockAlreadySent(
|
||||
not_null<PeerData*> peer,
|
||||
bool blocking,
|
||||
Fn<void(bool success)> done = nullptr);
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
|
||||
MTP::Sender _api;
|
||||
|
||||
base::flat_map<not_null<PeerData*>, Request> _blockRequests;
|
||||
mtpRequestId _requestId = 0;
|
||||
std::optional<Slice> _slice;
|
||||
rpl::event_stream<Slice> _changes;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace Api
|
||||
Reference in New Issue
Block a user