Moved MTP blocked peers from ApiWrap to Api::BlockedPeers.

This commit is contained in:
23rd 2021-08-02 01:57:36 +03:00 committed by John Preston
parent 221ded6d54
commit 0ae260c6e1
11 changed files with 283 additions and 221 deletions

View File

@ -91,6 +91,8 @@ PRIVATE
api/api_attached_stickers.h
api/api_authorizations.cpp
api/api_authorizations.h
api/api_blocked_peers.cpp
api/api_blocked_peers.h
api/api_bot.cpp
api/api_bot.h
api/api_chat_filters.cpp

View File

@ -0,0 +1,173 @@
/*
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
*/
#include "api/api_blocked_peers.h"
#include "apiwrap.h"
#include "base/unixtime.h"
#include "data/data_changes.h"
#include "data/data_peer.h"
#include "data/data_peer_id.h"
#include "data/data_session.h"
#include "main/main_session.h"
namespace Api {
namespace {
constexpr auto kBlockedFirstSlice = 16;
constexpr auto kBlockedPerPage = 40;
BlockedPeers::Slice TLToSlice(
const MTPcontacts_Blocked &blocked,
Data::Session &owner) {
const auto create = [&](int count, const QVector<MTPPeerBlocked> &list) {
auto slice = BlockedPeers::Slice();
slice.total = std::max(count, list.size());
slice.list.reserve(list.size());
for (const auto &contact : list) {
contact.match([&](const MTPDpeerBlocked &data) {
slice.list.push_back({
.id = peerFromMTP(data.vpeer_id()),
.date = data.vdate().v,
});
});
}
return slice;
};
return blocked.match([&](const MTPDcontacts_blockedSlice &data) {
owner.processUsers(data.vusers());
owner.processChats(data.vchats());
return create(data.vcount().v, data.vblocked().v);
}, [&](const MTPDcontacts_blocked &data) {
owner.processUsers(data.vusers());
owner.processChats(data.vchats());
return create(0, data.vblocked().v);
});
}
} // namespace
BlockedPeers::BlockedPeers(not_null<ApiWrap*> api)
: _session(&api->session())
, _api(&api->instance()) {
}
bool BlockedPeers::Slice::Item::operator==(const Item &other) const {
return (id == other.id) && (date == other.date);
}
bool BlockedPeers::Slice::Item::operator!=(const Item &other) const {
return !(*this == other);
}
bool BlockedPeers::Slice::operator==(const BlockedPeers::Slice &other) const {
return (total == other.total) && (list == other.list);
}
bool BlockedPeers::Slice::operator!=(const BlockedPeers::Slice &other) const {
return !(*this == other);
}
void BlockedPeers::block(not_null<PeerData*> peer) {
if (peer->isBlocked()) {
_session->changes().peerUpdated(
peer,
Data::PeerUpdate::Flag::IsBlocked);
} else if (_blockRequests.find(peer) == end(_blockRequests)) {
const auto requestId = _api.request(MTPcontacts_Block(
peer->input
)).done([=](const MTPBool &result) {
_blockRequests.erase(peer);
peer->setIsBlocked(true);
if (_slice) {
_slice->list.insert(
_slice->list.begin(),
{ peer->id, base::unixtime::now() });
++_slice->total;
_changes.fire_copy(*_slice);
}
}).fail([=](const MTP::Error &error) {
_blockRequests.erase(peer);
}).send();
_blockRequests.emplace(peer, requestId);
}
}
void BlockedPeers::unblock(not_null<PeerData*> peer, Fn<void()> onDone) {
if (!peer->isBlocked()) {
_session->changes().peerUpdated(
peer,
Data::PeerUpdate::Flag::IsBlocked);
return;
} else if (_blockRequests.find(peer) != end(_blockRequests)) {
return;
}
const auto requestId = _api.request(MTPcontacts_Unblock(
peer->input
)).done([=](const MTPBool &result) {
_blockRequests.erase(peer);
peer->setIsBlocked(false);
if (_slice) {
auto &list = _slice->list;
for (auto i = list.begin(); i != list.end(); ++i) {
if (i->id == peer->id) {
list.erase(i);
break;
}
}
if (_slice->total > list.size()) {
--_slice->total;
}
_changes.fire_copy(*_slice);
}
if (onDone) {
onDone();
}
}).fail([=](const MTP::Error &error) {
_blockRequests.erase(peer);
}).send();
_blockRequests.emplace(peer, requestId);
}
void BlockedPeers::reload() {
if (_requestId) {
return;
}
request(0, [=](Slice &&slice) {
if (!_slice || *_slice != slice) {
_slice = slice;
_changes.fire(std::move(slice));
}
});
}
auto BlockedPeers::slice() -> rpl::producer<BlockedPeers::Slice> {
if (!_slice) {
reload();
}
return _slice
? _changes.events_starting_with_copy(*_slice)
: (_changes.events() | rpl::type_erased());
}
void BlockedPeers::request(int offset, Fn<void(BlockedPeers::Slice)> onDone) {
if (_requestId) {
return;
}
_requestId = _api.request(MTPcontacts_GetBlocked(
MTP_int(offset),
MTP_int(offset ? kBlockedPerPage : kBlockedFirstSlice)
)).done([=](const MTPcontacts_Blocked &result) {
_requestId = 0;
onDone(TLToSlice(result, _session->data()));
}).fail([=](const MTP::Error &error) {
_requestId = 0;
}).send();
}
} // namespace Api

View File

@ -0,0 +1,60 @@
/*
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)> onDone);
void block(not_null<PeerData*> peer);
void unblock(not_null<PeerData*> peer, Fn<void()> onDone = nullptr);
private:
const not_null<Main::Session*> _session;
MTP::Sender _api;
base::flat_map<not_null<PeerData*>, mtpRequestId> _blockRequests;
mtpRequestId _requestId = 0;
std::optional<Slice> _slice;
rpl::event_stream<Slice> _changes;
};
} // namespace Api

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_authorizations.h"
#include "api/api_attached_stickers.h"
#include "api/api_blocked_peers.h"
#include "api/api_hash.h"
#include "api/api_invite_links.h"
#include "api/api_media.h"
@ -109,7 +110,6 @@ constexpr auto kStickersByEmojiInvalidateTimeout = crl::time(60 * 60 * 1000);
constexpr auto kNotifySettingSaveTimeout = crl::time(1000);
constexpr auto kDialogsFirstLoad = 20;
constexpr auto kDialogsPerPage = 500;
constexpr auto kBlockedFirstSlice = 16;
using PhotoFileLocationId = Data::PhotoFileLocationId;
using DocumentFileLocationId = Data::DocumentFileLocationId;
@ -121,22 +121,6 @@ using UpdatedFileReferences = Data::UpdatedFileReferences;
} // namespace
bool ApiWrap::BlockedPeersSlice::Item::operator==(const Item &other) const {
return (peer == other.peer) && (date == other.date);
}
bool ApiWrap::BlockedPeersSlice::Item::operator!=(const Item &other) const {
return !(*this == other);
}
bool ApiWrap::BlockedPeersSlice::operator==(const BlockedPeersSlice &other) const {
return (total == other.total) && (list == other.list);
}
bool ApiWrap::BlockedPeersSlice::operator!=(const BlockedPeersSlice &other) const {
return !(*this == other);
}
ApiWrap::ApiWrap(not_null<Main::Session*> session)
: MTP::Sender(&session->account().mtp())
, _session(session)
@ -150,6 +134,7 @@ ApiWrap::ApiWrap(not_null<Main::Session*> session)
, _updateNotifySettingsTimer([=] { sendNotifySettingsUpdates(); })
, _authorizations(std::make_unique<Api::Authorizations>(this))
, _attachedStickers(std::make_unique<Api::AttachedStickers>(this))
, _blockedPeers(std::make_unique<Api::BlockedPeers>(this))
, _selfDestruct(std::make_unique<Api::SelfDestruct>(this))
, _sensitiveContent(std::make_unique<Api::SensitiveContent>(this))
, _globalPrivacy(std::make_unique<Api::GlobalPrivacy>(this))
@ -2134,68 +2119,6 @@ void ApiWrap::leaveChannel(not_null<ChannelData*> channel) {
}
}
void ApiWrap::blockPeer(not_null<PeerData*> peer) {
if (peer->isBlocked()) {
session().changes().peerUpdated(
peer,
Data::PeerUpdate::Flag::IsBlocked);
} else if (_blockRequests.find(peer) == end(_blockRequests)) {
const auto requestId = request(MTPcontacts_Block(
peer->input
)).done([=](const MTPBool &result) {
_blockRequests.erase(peer);
peer->setIsBlocked(true);
if (_blockedPeersSlice) {
_blockedPeersSlice->list.insert(
_blockedPeersSlice->list.begin(),
{ peer, base::unixtime::now() });
++_blockedPeersSlice->total;
_blockedPeersChanges.fire_copy(*_blockedPeersSlice);
}
}).fail([=](const MTP::Error &error) {
_blockRequests.erase(peer);
}).send();
_blockRequests.emplace(peer, requestId);
}
}
void ApiWrap::unblockPeer(not_null<PeerData*> peer, Fn<void()> onDone) {
if (!peer->isBlocked()) {
session().changes().peerUpdated(
peer,
Data::PeerUpdate::Flag::IsBlocked);
return;
} else if (_blockRequests.find(peer) != end(_blockRequests)) {
return;
}
const auto requestId = request(MTPcontacts_Unblock(
peer->input
)).done([=](const MTPBool &result) {
_blockRequests.erase(peer);
peer->setIsBlocked(false);
if (_blockedPeersSlice) {
auto &list = _blockedPeersSlice->list;
for (auto i = list.begin(); i != list.end(); ++i) {
if (i->peer == peer) {
list.erase(i);
break;
}
}
if (_blockedPeersSlice->total > list.size()) {
--_blockedPeersSlice->total;
}
_blockedPeersChanges.fire_copy(*_blockedPeersSlice);
}
if (onDone) {
onDone();
}
}).fail([=](const MTP::Error &error) {
_blockRequests.erase(peer);
}).send();
_blockRequests.emplace(peer, requestId);
}
void ApiWrap::requestNotifySettings(const MTPInputNotifyPeer &peer) {
const auto key = [&] {
switch (peer.type()) {
@ -4799,57 +4722,6 @@ void ApiWrap::saveSelfBio(const QString &text, FnMut<void()> done) {
}).send();
}
void ApiWrap::reloadBlockedPeers() {
if (_blockedPeersRequestId) {
return;
}
_blockedPeersRequestId = request(MTPcontacts_GetBlocked(
MTP_int(0),
MTP_int(kBlockedFirstSlice)
)).done([=](const MTPcontacts_Blocked &result) {
_blockedPeersRequestId = 0;
const auto push = [&](
int count,
const QVector<MTPPeerBlocked> &list) {
auto slice = BlockedPeersSlice();
slice.total = std::max(count, list.size());
slice.list.reserve(list.size());
for (const auto &contact : list) {
contact.match([&](const MTPDpeerBlocked &data) {
const auto peer = _session->data().peerLoaded(
peerFromMTP(data.vpeer_id()));
if (peer) {
peer->setIsBlocked(true);
slice.list.push_back({ peer, data.vdate().v });
}
});
}
if (!_blockedPeersSlice || *_blockedPeersSlice != slice) {
_blockedPeersSlice = slice;
_blockedPeersChanges.fire(std::move(slice));
}
};
result.match([&](const MTPDcontacts_blockedSlice &data) {
_session->data().processUsers(data.vusers());
push(data.vcount().v, data.vblocked().v);
}, [&](const MTPDcontacts_blocked &data) {
_session->data().processUsers(data.vusers());
push(0, data.vblocked().v);
});
}).fail([=](const MTP::Error &error) {
_blockedPeersRequestId = 0;
}).send();
}
auto ApiWrap::blockedPeersSlice() -> rpl::producer<BlockedPeersSlice> {
if (!_blockedPeersSlice) {
reloadBlockedPeers();
}
return _blockedPeersSlice
? _blockedPeersChanges.events_starting_with_copy(*_blockedPeersSlice)
: (_blockedPeersChanges.events() | rpl::type_erased());
}
Api::Authorizations &ApiWrap::authorizations() {
return *_authorizations;
}
@ -4858,6 +4730,10 @@ Api::AttachedStickers &ApiWrap::attachedStickers() {
return *_attachedStickers;
}
Api::BlockedPeers &ApiWrap::blockedPeers() {
return *_blockedPeers;
}
Api::SelfDestruct &ApiWrap::selfDestruct() {
return *_selfDestruct;
}

View File

@ -58,6 +58,7 @@ namespace Api {
class Updates;
class Authorizations;
class AttachedStickers;
class BlockedPeers;
class SelfDestruct;
class SensitiveContent;
class GlobalPrivacy;
@ -114,22 +115,6 @@ public:
using SendAction = Api::SendAction;
using MessageToSend = Api::MessageToSend;
struct BlockedPeersSlice {
struct Item {
PeerData *peer = nullptr;
TimeId date = 0;
bool operator==(const Item &other) const;
bool operator!=(const Item &other) const;
};
QVector<Item> list;
int total = 0;
bool operator==(const BlockedPeersSlice &other) const;
bool operator!=(const BlockedPeersSlice &other) const;
};
explicit ApiWrap(not_null<Main::Session*> session);
~ApiWrap();
@ -272,9 +257,6 @@ public:
void joinChannel(not_null<ChannelData*> channel);
void leaveChannel(not_null<ChannelData*> channel);
void blockPeer(not_null<PeerData*> peer);
void unblockPeer(not_null<PeerData*> peer, Fn<void()> onDone = nullptr);
void requestNotifySettings(const MTPInputNotifyPeer &peer);
void updateNotifySettingsDelayed(not_null<const PeerData*> peer);
void saveDraftToCloudDelayed(not_null<History*> history);
@ -417,11 +399,9 @@ public:
void saveSelfBio(const QString &text, FnMut<void()> done);
void reloadBlockedPeers();
rpl::producer<BlockedPeersSlice> blockedPeersSlice();
[[nodiscard]] Api::Authorizations &authorizations();
[[nodiscard]] Api::AttachedStickers &attachedStickers();
[[nodiscard]] Api::BlockedPeers &blockedPeers();
[[nodiscard]] Api::SelfDestruct &selfDestruct();
[[nodiscard]] Api::SensitiveContent &sensitiveContent();
[[nodiscard]] Api::GlobalPrivacy &globalPrivacy();
@ -641,7 +621,6 @@ private:
QMap<uint64, QPair<uint64, mtpRequestId> > _stickerSetRequests;
QMap<ChannelData*, mtpRequestId> _channelAmInRequests;
base::flat_map<not_null<PeerData*>, mtpRequestId> _blockRequests;
base::flat_map<PeerId, mtpRequestId> _notifySettingRequests;
base::flat_map<not_null<History*>, mtpRequestId> _draftsSaveRequestIds;
base::Timer _draftsSaveTimer;
@ -736,12 +715,9 @@ private:
FnMut<void()> _saveBioDone;
QString _saveBioText;
mtpRequestId _blockedPeersRequestId = 0;
std::optional<BlockedPeersSlice> _blockedPeersSlice;
rpl::event_stream<BlockedPeersSlice> _blockedPeersChanges;
const std::unique_ptr<Api::Authorizations> _authorizations;
const std::unique_ptr<Api::AttachedStickers> _attachedStickers;
const std::unique_ptr<Api::BlockedPeers> _blockedPeers;
const std::unique_ptr<Api::SelfDestruct> _selfDestruct;
const std::unique_ptr<Api::SensitiveContent> _sensitiveContent;
const std::unique_ptr<Api::GlobalPrivacy> _globalPrivacy;

View File

@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_controller.h"
#include "window/window_session_controller.h"
#include "apiwrap.h"
#include "api/api_blocked_peers.h"
#include "main/main_session.h"
#include "boxes/confirm_box.h"
#include "boxes/peers/edit_contact_box.h"
@ -393,7 +394,7 @@ void ContactStatus::setupReportHandler(not_null<PeerData*> peer) {
_controller->showBackFromStack();
});
if (const auto user = peer->asUser()) {
peer->session().api().blockPeer(user);
peer->session().api().blockedPeers().block(user);
}
const auto text = ((peer->isChat() || peer->isMegagroup())
? tr::lng_report_spam_sure_group

View File

@ -48,6 +48,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "core/click_handler_types.h"
#include "apiwrap.h"
#include "api/api_blocked_peers.h"
#include "facades.h"
#include "styles/style_info.h"
#include "styles/style_boxes.h"
@ -647,7 +648,7 @@ void ActionsFiller::addBlockAction(not_null<UserData*> user) {
Ui::showPeerHistory(user, ShowAtUnreadMsgId);
}
} else if (user->isBot()) {
user->session().api().blockPeer(user);
user->session().api().blockedPeers().block(user);
} else {
window->show(Box(
Window::PeerMenuBlockUserBox,

View File

@ -48,8 +48,6 @@ namespace {
using UserPrivacy = Api::UserPrivacy;
using PrivacyRule = Api::UserPrivacy::Rule;
constexpr auto kBlockedPerPage = 40;
class BlockPeerBoxController final : public ChatsListBoxController {
public:
explicit BlockPeerBoxController(not_null<Main::Session*> session);
@ -180,8 +178,7 @@ AdminLog::OwnedItem GenerateForwardedItem(
BlockedBoxController::BlockedBoxController(
not_null<Window::SessionController*> window)
: _window(window)
, _api(&_window->session().mtp()) {
: _window(window) {
}
Main::Session &BlockedBoxController::session() const {
@ -199,52 +196,26 @@ void BlockedBoxController::prepare() {
handleBlockedEvent(update.peer);
}, lifetime());
_loadRequestId = -1;
_window->session().api().blockedPeersSlice(
session().api().blockedPeers().slice(
) | rpl::take(
1
) | rpl::start_with_next([=](const ApiWrap::BlockedPeersSlice &result) {
) | rpl::start_with_next([=](const Api::BlockedPeers::Slice &result) {
setDescriptionText(tr::lng_blocked_list_about(tr::now));
_loadRequestId = 0;
_offset = result.list.size();
_allLoaded = (_offset >= result.total);
for (const auto item : result.list) {
appendRow(item.peer);
};
delegate()->peerListRefreshRows();
applySlice(result);
loadMoreRows();
}, lifetime());
}
void BlockedBoxController::loadMoreRows() {
if (_loadRequestId || _allLoaded) {
if (_allLoaded) {
return;
}
_loadRequestId = _api.request(MTPcontacts_GetBlocked(
MTP_int(_offset),
MTP_int(kBlockedPerPage)
)).done([=](const MTPcontacts_Blocked &result) {
_loadRequestId = 0;
auto handleContactsBlocked = [&](auto &list) {
_window->session().data().processUsers(list.vusers());
_window->session().data().processChats(list.vchats());
return list.vblocked().v;
};
switch (result.type()) {
case mtpc_contacts_blockedSlice: {
receivedPeers(handleContactsBlocked(result.c_contacts_blockedSlice()));
} break;
case mtpc_contacts_blocked: {
_allLoaded = true;
receivedPeers(handleContactsBlocked(result.c_contacts_blocked()));
} break;
default: Unexpected("Bad type() in MTPcontacts_GetBlocked() result.");
}
}).fail([this](const MTP::Error &error) {
_loadRequestId = 0;
}).send();
session().api().blockedPeers().request(
_offset,
crl::guard(&_guard, [=](const Api::BlockedPeers::Slice &slice) {
applySlice(slice);
}));
}
void BlockedBoxController::rowClicked(not_null<PeerListRow*> row) {
@ -255,23 +226,23 @@ void BlockedBoxController::rowClicked(not_null<PeerListRow*> row) {
}
void BlockedBoxController::rowActionClicked(not_null<PeerListRow*> row) {
_window->session().api().unblockPeer(row->peer());
session().api().blockedPeers().unblock(row->peer());
}
void BlockedBoxController::receivedPeers(
const QVector<MTPPeerBlocked> &result) {
if (result.empty()) {
void BlockedBoxController::applySlice(const Api::BlockedPeers::Slice &slice) {
if (slice.list.empty()) {
_allLoaded = true;
}
_offset += result.size();
for (const auto &item : result) {
item.match([&](const MTPDpeerBlocked &data) {
if (const auto peer = _window->session().data().peerLoaded(peerFromMTP(data.vpeer_id()))) {
appendRow(peer);
peer->setIsBlocked(true);
}
});
_offset += slice.list.size();
for (const auto &item : slice.list) {
if (const auto peer = session().data().peerLoaded(item.id)) {
appendRow(peer);
peer->setIsBlocked(true);
}
}
if (_offset >= slice.total) {
_allLoaded = true;
}
delegate()->peerListRefreshRows();
}
@ -295,7 +266,7 @@ void BlockedBoxController::BlockNewPeer(
auto initBox = [=, controller = controller.get()](
not_null<PeerListBox*> box) {
controller->setBlockPeerCallback([=](not_null<PeerData*> peer) {
window->session().api().blockPeer(peer);
window->session().api().blockedPeers().block(peer);
box->closeBox();
});
box->addButton(tr::lng_cancel(), [box] { box->closeBox(); });

View File

@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peer_list_box.h"
#include "boxes/edit_privacy_box.h"
#include "history/view/history_view_element.h"
#include "mtproto/sender.h"
#include "api/api_blocked_peers.h"
namespace Window {
class SessionController;
@ -32,7 +32,7 @@ public:
static void BlockNewPeer(not_null<Window::SessionController*> window);
private:
void receivedPeers(const QVector<MTPPeerBlocked> &result);
void applySlice(const Api::BlockedPeers::Slice &slice);
void handleBlockedEvent(not_null<PeerData*> peer);
bool appendRow(not_null<PeerData*> peer);
@ -40,12 +40,12 @@ private:
std::unique_ptr<PeerListRow> createRow(not_null<PeerData*> peer) const;
const not_null<Window::SessionController*> _window;
MTP::Sender _api;
int _offset = 0;
mtpRequestId _loadRequestId = 0;
bool _allLoaded = false;
base::has_weak_ptr _guard;
};
class PhoneNumberPrivacyController : public EditPrivacyController {

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_privacy_security.h"
#include "api/api_authorizations.h"
#include "api/api_blocked_peers.h"
#include "api/api_self_destruct.h"
#include "api/api_sensitive_content.h"
#include "api/api_global_privacy.h"
@ -107,8 +108,8 @@ rpl::producer<QString> PrivacyString(
}
rpl::producer<int> BlockedPeersCount(not_null<::Main::Session*> session) {
return session->api().blockedPeersSlice(
) | rpl::map([=](const ApiWrap::BlockedPeersSlice &data) {
return session->api().blockedPeers().slice(
) | rpl::map([](const Api::BlockedPeers::Slice &data) {
return data.total;
});
}
@ -148,7 +149,7 @@ void SetupPrivacy(
std::move(
updateTrigger
) | rpl::start_with_next([=] {
session->api().reloadBlockedPeers();
session->api().blockedPeers().reload();
}, blockedPeers->lifetime());
using Key = Privacy::Key;

View File

@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "api/api_blocked_peers.h"
#include "api/api_chat_filters.h"
#include "api/api_updates.h"
#include "mtproto/mtproto_config.h"
@ -428,7 +429,7 @@ void Filler::addBlockUser(not_null<UserData*> user) {
if (user->isBlocked()) {
PeerMenuUnblockUserWithBotRestart(user);
} else if (user->isBot()) {
user->session().api().blockPeer(user);
user->session().api().blockedPeers().block(user);
} else {
window->show(Box(
PeerMenuBlockUserBox,
@ -914,7 +915,7 @@ void PeerMenuBlockUserBox(
peer->session().updates().applyUpdates(result);
}).send();
} else {
peer->session().api().blockPeer(peer);
peer->session().api().blockedPeers().block(peer);
if (reportChecked) {
peer->session().api().request(MTPmessages_ReportSpam(
peer->input
@ -938,7 +939,7 @@ void PeerMenuBlockUserBox(
}
void PeerMenuUnblockUserWithBotRestart(not_null<UserData*> user) {
user->session().api().unblockPeer(user, [=] {
user->session().api().blockedPeers().unblock(user, [=] {
if (user->isBot() && !user->isSupport()) {
user->session().api().sendBotStart(user);
}