Added auto-unblocking of bot when it is auto-submitted.

This commit is contained in:
23rd 2022-07-18 02:58:24 +03:00 committed by John Preston
parent 2055fbc164
commit 57ecd918f1
3 changed files with 18 additions and 4 deletions

View File

@ -98,8 +98,11 @@ void BlockedPeers::block(not_null<PeerData*> peer) {
}
}
void BlockedPeers::unblock(not_null<PeerData*> peer, Fn<void()> onDone) {
if (!peer->isBlocked()) {
void BlockedPeers::unblock(
not_null<PeerData*> peer,
Fn<void()> onDone,
bool force) {
if (!force && !peer->isBlocked()) {
_session->changes().peerUpdated(
peer,
Data::PeerUpdate::Flag::IsBlocked);

View File

@ -42,7 +42,10 @@ public:
void request(int offset, Fn<void(Slice)> onDone);
void block(not_null<PeerData*> peer);
void unblock(not_null<PeerData*> peer, Fn<void()> onDone = nullptr);
void unblock(
not_null<PeerData*> peer,
Fn<void()> onDone = nullptr,
bool force = false);
private:
const not_null<Main::Session*> _session;

View File

@ -73,6 +73,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "api/api_chat_invite.h"
#include "api/api_global_privacy.h"
#include "api/api_blocked_peers.h"
#include "support/support_helper.h"
#include "storage/file_upload.h"
#include "facades.h"
@ -186,7 +187,14 @@ void SessionNavigation::showPeerByLink(const PeerByLinkInfo &info) {
});
} else if (const auto name = std::get_if<QString>(&info.usernameOrId)) {
resolveUsername(*name, [=](not_null<PeerData*> peer) {
showPeerByLinkResolved(peer, info);
if (info.startAutoSubmit) {
peer->session().api().blockedPeers().unblock(
peer,
[=] { showPeerByLinkResolved(peer, info); },
true);
} else {
showPeerByLinkResolved(peer, info);
}
});
} else if (const auto id = std::get_if<ChannelId>(&info.usernameOrId)) {
resolveChannelById(*id, [=](not_null<ChannelData*> channel) {