mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 22:55:11 +00:00
Suggest inviting by link if privacy disallows adding.
This commit is contained in:
@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "boxes/add_contact_box.h" // ShowAddParticipantsError
|
||||
#include "boxes/peers/add_participants_box.h" // ChatInviteForbidden
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_channel_admins.h"
|
||||
@@ -463,6 +464,7 @@ void ChatParticipants::requestCountDelayed(
|
||||
void ChatParticipants::add(
|
||||
not_null<PeerData*> peer,
|
||||
const std::vector<not_null<UserData*>> &users,
|
||||
std::shared_ptr<Ui::Show> show,
|
||||
bool passGroupHistory,
|
||||
Fn<void(bool)> done) {
|
||||
if (const auto chat = peer->asChat()) {
|
||||
@@ -475,14 +477,15 @@ void ChatParticipants::add(
|
||||
chat->session().api().applyUpdates(result);
|
||||
if (done) done(true);
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
ShowAddParticipantsError(error.type(), peer, { 1, user });
|
||||
const auto type = error.type();
|
||||
ShowAddParticipantsError(type, peer, { 1, user }, show);
|
||||
if (done) done(false);
|
||||
}).afterDelay(kSmallDelayMs).send();
|
||||
}
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
const auto hasBot = ranges::any_of(users, &UserData::isBot);
|
||||
if (!peer->isMegagroup() && hasBot) {
|
||||
ShowAddParticipantsError("USER_BOT", peer, users);
|
||||
ShowAddParticipantsError("USER_BOT", peer, users, show);
|
||||
return;
|
||||
}
|
||||
auto list = QVector<MTPInputUser>();
|
||||
@@ -496,8 +499,12 @@ void ChatParticipants::add(
|
||||
channel->session().api().applyUpdates(result);
|
||||
requestCountDelayed(channel);
|
||||
if (callback) callback(true);
|
||||
ChatInviteForbidden(
|
||||
show,
|
||||
channel,
|
||||
CollectForbiddenUsers(&channel->session(), result));
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
ShowAddParticipantsError(error.type(), peer, users);
|
||||
ShowAddParticipantsError(error.type(), peer, users, show);
|
||||
if (callback) callback(false);
|
||||
}).afterDelay(kSmallDelayMs).send();
|
||||
};
|
||||
|
@@ -14,6 +14,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
class ApiWrap;
|
||||
class ChannelData;
|
||||
|
||||
namespace Ui {
|
||||
class Show;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Api {
|
||||
|
||||
class ChatParticipant final {
|
||||
@@ -95,6 +99,7 @@ public:
|
||||
void add(
|
||||
not_null<PeerData*> peer,
|
||||
const std::vector<not_null<UserData*>> &users,
|
||||
std::shared_ptr<Ui::Show> show = nullptr,
|
||||
bool passGroupHistory = true,
|
||||
Fn<void(bool)> done = nullptr);
|
||||
|
||||
|
Reference in New Issue
Block a user