mirror of https://github.com/procxx/kepka.git
Update kicked count in Channel Info box.
This commit is contained in:
parent
69d9072ff0
commit
21f4bbbe7b
|
@ -937,47 +937,65 @@ void ApiWrap::requestSelfParticipant(ChannelData *channel) {
|
||||||
_selfParticipantRequests.insert(channel, requestId);
|
_selfParticipantRequests.insert(channel, requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::kickParticipant(PeerData *peer, UserData *user, const MTPChannelBannedRights ¤tRights) {
|
void ApiWrap::kickParticipant(
|
||||||
auto kick = KickRequest(peer, user);
|
not_null<ChatData*> chat,
|
||||||
if (_kickRequests.contains(kick)) return;
|
not_null<UserData*> user) {
|
||||||
|
request(MTPmessages_DeleteChatUser(
|
||||||
if (auto channel = peer->asChannel()) {
|
chat->inputChat,
|
||||||
auto rights = ChannelData::KickedRestrictedRights();
|
user->inputUser
|
||||||
auto requestId = request(MTPchannels_EditBanned(channel->inputChannel, user->inputUser, rights)).done([this, channel, user, currentRights, rights](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
applyUpdates(result);
|
applyUpdates(result);
|
||||||
|
}).send();
|
||||||
_kickRequests.remove(KickRequest(channel, user));
|
|
||||||
channel->applyEditBanned(user, currentRights, rights);
|
|
||||||
}).fail([this, kick](const RPCError &error) {
|
|
||||||
_kickRequests.remove(kick);
|
|
||||||
}).send();
|
|
||||||
|
|
||||||
_kickRequests.insert(kick, requestId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::unblockParticipant(PeerData *peer, UserData *user) {
|
void ApiWrap::kickParticipant(
|
||||||
auto kick = KickRequest(peer, user);
|
not_null<ChannelData*> channel,
|
||||||
|
not_null<UserData*> user,
|
||||||
|
const MTPChannelBannedRights ¤tRights) {
|
||||||
|
const auto kick = KickRequest(channel, user);
|
||||||
if (_kickRequests.contains(kick)) return;
|
if (_kickRequests.contains(kick)) return;
|
||||||
|
|
||||||
if (auto channel = peer->asChannel()) {
|
const auto rights = ChannelData::KickedRestrictedRights();
|
||||||
auto requestId = request(MTPchannels_EditBanned(channel->inputChannel, user->inputUser, MTP_channelBannedRights(MTP_flags(0), MTP_int(0)))).done([this, peer, user](const MTPUpdates &result) {
|
const auto requestId = request(MTPchannels_EditBanned(
|
||||||
applyUpdates(result);
|
channel->inputChannel,
|
||||||
|
user->inputUser,
|
||||||
|
rights
|
||||||
|
)).done([=](const MTPUpdates &result) {
|
||||||
|
applyUpdates(result);
|
||||||
|
|
||||||
_kickRequests.remove(KickRequest(peer, user));
|
_kickRequests.remove(KickRequest(channel, user));
|
||||||
if (auto channel = peer->asMegagroup()) {
|
channel->applyEditBanned(user, currentRights, rights);
|
||||||
if (channel->kickedCount() > 0) {
|
}).fail([this, kick](const RPCError &error) {
|
||||||
channel->setKickedCount(channel->kickedCount() - 1);
|
_kickRequests.remove(kick);
|
||||||
} else {
|
}).send();
|
||||||
channel->updateFullForced();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).fail([this, kick](const RPCError &error) {
|
|
||||||
_kickRequests.remove(kick);
|
|
||||||
}).send();
|
|
||||||
|
|
||||||
_kickRequests.insert(kick, requestId);
|
_kickRequests.emplace(kick, requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApiWrap::unblockParticipant(
|
||||||
|
not_null<ChannelData*> channel,
|
||||||
|
not_null<UserData*> user) {
|
||||||
|
const auto kick = KickRequest(channel, user);
|
||||||
|
if (_kickRequests.contains(kick)) return;
|
||||||
|
|
||||||
|
const auto requestId = request(MTPchannels_EditBanned(
|
||||||
|
channel->inputChannel,
|
||||||
|
user->inputUser,
|
||||||
|
MTP_channelBannedRights(MTP_flags(0), MTP_int(0))
|
||||||
|
)).done([=](const MTPUpdates &result) {
|
||||||
|
applyUpdates(result);
|
||||||
|
|
||||||
|
_kickRequests.remove(KickRequest(channel, user));
|
||||||
|
if (channel->kickedCount() > 0) {
|
||||||
|
channel->setKickedCount(channel->kickedCount() - 1);
|
||||||
|
} else {
|
||||||
|
channel->updateFullForced();
|
||||||
|
}
|
||||||
|
}).fail([this, kick](const RPCError &error) {
|
||||||
|
_kickRequests.remove(kick);
|
||||||
|
}).send();
|
||||||
|
|
||||||
|
_kickRequests.emplace(kick, requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::requestChannelMembersForAdd(
|
void ApiWrap::requestChannelMembersForAdd(
|
||||||
|
|
|
@ -77,8 +77,14 @@ public:
|
||||||
void processFullPeer(UserData *user, const MTPUserFull &result);
|
void processFullPeer(UserData *user, const MTPUserFull &result);
|
||||||
|
|
||||||
void requestSelfParticipant(ChannelData *channel);
|
void requestSelfParticipant(ChannelData *channel);
|
||||||
void kickParticipant(PeerData *peer, UserData *user, const MTPChannelBannedRights ¤tRights);
|
void kickParticipant(not_null<ChatData*> chat, not_null<UserData*> user);
|
||||||
void unblockParticipant(PeerData *peer, UserData *user);
|
void kickParticipant(
|
||||||
|
not_null<ChannelData*> channel,
|
||||||
|
not_null<UserData*> user,
|
||||||
|
const MTPChannelBannedRights ¤tRights);
|
||||||
|
void unblockParticipant(
|
||||||
|
not_null<ChannelData*> channel,
|
||||||
|
not_null<UserData*> user);
|
||||||
|
|
||||||
void requestWebPageDelayed(WebPageData *page);
|
void requestWebPageDelayed(WebPageData *page);
|
||||||
void clearWebPageRequest(WebPageData *page);
|
void clearWebPageRequest(WebPageData *page);
|
||||||
|
@ -357,9 +363,10 @@ private:
|
||||||
mtpRequestId _channelMembersForAddRequestId = 0;
|
mtpRequestId _channelMembersForAddRequestId = 0;
|
||||||
base::lambda<void(const MTPchannels_ChannelParticipants&)> _channelMembersForAddCallback;
|
base::lambda<void(const MTPchannels_ChannelParticipants&)> _channelMembersForAddCallback;
|
||||||
|
|
||||||
typedef QPair<PeerData*, UserData*> KickRequest;
|
using KickRequest = std::pair<
|
||||||
typedef QMap<KickRequest, mtpRequestId> KickRequests;
|
not_null<ChannelData*>,
|
||||||
KickRequests _kickRequests;
|
not_null<UserData*>>;
|
||||||
|
base::flat_map<KickRequest, mtpRequestId> _kickRequests;
|
||||||
|
|
||||||
QMap<ChannelData*, mtpRequestId> _selfParticipantRequests;
|
QMap<ChannelData*, mtpRequestId> _selfParticipantRequests;
|
||||||
|
|
||||||
|
|
|
@ -565,13 +565,22 @@ void DeleteMessagesBox::deleteAndClear() {
|
||||||
|
|
||||||
if (_moderateFrom) {
|
if (_moderateFrom) {
|
||||||
if (_banUser && _banUser->checked()) {
|
if (_banUser && _banUser->checked()) {
|
||||||
Auth().api().kickParticipant(_moderateInChannel, _moderateFrom, MTP_channelBannedRights(MTP_flags(0), MTP_int(0)));
|
Auth().api().kickParticipant(
|
||||||
|
_moderateInChannel,
|
||||||
|
_moderateFrom,
|
||||||
|
MTP_channelBannedRights(MTP_flags(0), MTP_int(0)));
|
||||||
}
|
}
|
||||||
if (_reportSpam->checked()) {
|
if (_reportSpam->checked()) {
|
||||||
MTP::send(MTPchannels_ReportSpam(_moderateInChannel->inputChannel, _moderateFrom->inputUser, MTP_vector<MTPint>(1, MTP_int(_ids[0].msg))));
|
MTP::send(
|
||||||
|
MTPchannels_ReportSpam(
|
||||||
|
_moderateInChannel->inputChannel,
|
||||||
|
_moderateFrom->inputUser,
|
||||||
|
MTP_vector<MTPint>(1, MTP_int(_ids[0].msg))));
|
||||||
}
|
}
|
||||||
if (_deleteAll && _deleteAll->checked()) {
|
if (_deleteAll && _deleteAll->checked()) {
|
||||||
App::main()->deleteAllFromUser(_moderateInChannel, _moderateFrom);
|
App::main()->deleteAllFromUser(
|
||||||
|
_moderateInChannel,
|
||||||
|
_moderateFrom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -794,9 +794,12 @@ void ChannelData::applyEditBanned(not_null<UserData*> user, const MTPChannelBann
|
||||||
}
|
}
|
||||||
Data::ChannelAdminChanges(this).feed(peerToUser(user->id), false);
|
Data::ChannelAdminChanges(this).feed(peerToUser(user->id), false);
|
||||||
} else {
|
} else {
|
||||||
if (isKicked && membersCount() > 1) {
|
if (isKicked) {
|
||||||
setMembersCount(membersCount() - 1);
|
if (membersCount() > 1) {
|
||||||
flags |= Notify::PeerUpdate::Flag::MembersChanged;
|
setMembersCount(membersCount() - 1);
|
||||||
|
flags |= Notify::PeerUpdate::Flag::MembersChanged;
|
||||||
|
}
|
||||||
|
setKickedCount(kickedCount() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(this, flags);
|
Notify::peerUpdatedDelayed(this, flags);
|
||||||
|
|
|
@ -309,7 +309,8 @@ void ChatMembersController::removeMember(not_null<UserData*> user) {
|
||||||
auto text = lng_profile_sure_kick(lt_user, user->firstName);
|
auto text = lng_profile_sure_kick(lt_user, user->firstName);
|
||||||
Ui::show(Box<ConfirmBox>(text, lang(lng_box_remove), [user, chat = _chat] {
|
Ui::show(Box<ConfirmBox>(text, lang(lng_box_remove), [user, chat = _chat] {
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
if (App::main()) App::main()->kickParticipant(chat, user);
|
Auth().api().kickParticipant(chat, user);
|
||||||
|
Ui::showPeerHistory(chat->id, ShowAtTheEndMsgId);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1268,21 +1268,6 @@ bool MainWidget::addParticipantsFail(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::kickParticipant(ChatData *chat, UserData *user) {
|
|
||||||
MTP::send(
|
|
||||||
MTPmessages_DeleteChatUser(chat->inputChat, user->inputUser),
|
|
||||||
rpcDone(&MainWidget::sentUpdatesReceived),
|
|
||||||
rpcFail(&MainWidget::kickParticipantFail, chat));
|
|
||||||
Ui::showPeerHistory(chat->id, ShowAtTheEndMsgId);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MainWidget::kickParticipantFail(ChatData *chat, const RPCError &error) {
|
|
||||||
if (MTP::isDefaultHandledError(error)) return false;
|
|
||||||
|
|
||||||
error.type();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWidget::checkPeerHistory(PeerData *peer) {
|
void MainWidget::checkPeerHistory(PeerData *peer) {
|
||||||
auto offsetId = 0;
|
auto offsetId = 0;
|
||||||
auto offsetDate = 0;
|
auto offsetDate = 0;
|
||||||
|
|
|
@ -224,9 +224,6 @@ public:
|
||||||
not_null<ChannelData*> channel,
|
not_null<ChannelData*> channel,
|
||||||
const RPCError &e); // for multi invite in channels
|
const RPCError &e); // for multi invite in channels
|
||||||
|
|
||||||
void kickParticipant(ChatData *chat, UserData *user);
|
|
||||||
bool kickParticipantFail(ChatData *chat, const RPCError &e);
|
|
||||||
|
|
||||||
void checkPeerHistory(PeerData *peer);
|
void checkPeerHistory(PeerData *peer);
|
||||||
void checkedHistory(PeerData *peer, const MTPmessages_Messages &result);
|
void checkedHistory(PeerData *peer, const MTPmessages_Messages &result);
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,7 @@ void GroupMembersWidget::restrictUser(not_null<UserData*> user) {
|
||||||
void GroupMembersWidget::removePeer(PeerData *selectedPeer) {
|
void GroupMembersWidget::removePeer(PeerData *selectedPeer) {
|
||||||
auto user = selectedPeer->asUser();
|
auto user = selectedPeer->asUser();
|
||||||
Assert(user != nullptr);
|
Assert(user != nullptr);
|
||||||
|
|
||||||
auto text = lng_profile_sure_kick(lt_user, user->firstName);
|
auto text = lng_profile_sure_kick(lt_user, user->firstName);
|
||||||
auto currentRestrictedRights = [&]() -> MTPChannelBannedRights {
|
auto currentRestrictedRights = [&]() -> MTPChannelBannedRights {
|
||||||
if (auto channel = peer()->asMegagroup()) {
|
if (auto channel = peer()->asMegagroup()) {
|
||||||
|
@ -128,10 +129,14 @@ void GroupMembersWidget::removePeer(PeerData *selectedPeer) {
|
||||||
}();
|
}();
|
||||||
Ui::show(Box<ConfirmBox>(text, lang(lng_box_remove), [user, currentRestrictedRights, peer = peer()] {
|
Ui::show(Box<ConfirmBox>(text, lang(lng_box_remove), [user, currentRestrictedRights, peer = peer()] {
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
if (auto chat = peer->asChat()) {
|
if (const auto chat = peer->asChat()) {
|
||||||
if (App::main()) App::main()->kickParticipant(chat, user);
|
Auth().api().kickParticipant(chat, user);
|
||||||
} else if (auto channel = peer->asChannel()) {
|
Ui::showPeerHistory(chat->id, ShowAtTheEndMsgId);
|
||||||
Auth().api().kickParticipant(channel, user, currentRestrictedRights);
|
} else if (const auto channel = peer->asChannel()) {
|
||||||
|
Auth().api().kickParticipant(
|
||||||
|
channel,
|
||||||
|
user,
|
||||||
|
currentRestrictedRights);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -860,7 +860,9 @@ void ParticipantsBoxController::kickMemberSure(not_null<UserData*> user) {
|
||||||
_editBox->closeBox();
|
_editBox->closeBox();
|
||||||
}
|
}
|
||||||
auto alreadyIt = _additional.restrictedRights.find(user);
|
auto alreadyIt = _additional.restrictedRights.find(user);
|
||||||
auto currentRights = (alreadyIt == _additional.restrictedRights.cend()) ? MTP_channelBannedRights(MTP_flags(0), MTP_int(0)) : alreadyIt->second;
|
auto currentRights = (alreadyIt == _additional.restrictedRights.cend())
|
||||||
|
? MTP_channelBannedRights(MTP_flags(0), MTP_int(0))
|
||||||
|
: alreadyIt->second;
|
||||||
|
|
||||||
if (auto row = delegate()->peerListFindRow(user->id)) {
|
if (auto row = delegate()->peerListFindRow(user->id)) {
|
||||||
delegate()->peerListRemoveRow(row);
|
delegate()->peerListRemoveRow(row);
|
||||||
|
@ -899,7 +901,9 @@ void ParticipantsBoxController::removeAdminSure(not_null<UserData*> user) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticipantsBoxController::removeKicked(not_null<PeerListRow*> row, not_null<UserData*> user) {
|
void ParticipantsBoxController::removeKicked(
|
||||||
|
not_null<PeerListRow*> row,
|
||||||
|
not_null<UserData*> user) {
|
||||||
delegate()->peerListRemoveRow(row);
|
delegate()->peerListRemoveRow(row);
|
||||||
delegate()->peerListRefreshRows();
|
delegate()->peerListRefreshRows();
|
||||||
|
|
||||||
|
|
|
@ -124,9 +124,13 @@ private:
|
||||||
void sortByOnlineDelayed();
|
void sortByOnlineDelayed();
|
||||||
void sortByOnline();
|
void sortByOnline();
|
||||||
void showAdmin(not_null<UserData*> user);
|
void showAdmin(not_null<UserData*> user);
|
||||||
void editAdminDone(not_null<UserData*> user, const MTPChannelAdminRights &rights);
|
void editAdminDone(
|
||||||
|
not_null<UserData*> user,
|
||||||
|
const MTPChannelAdminRights &rights);
|
||||||
void showRestricted(not_null<UserData*> user);
|
void showRestricted(not_null<UserData*> user);
|
||||||
void editRestrictedDone(not_null<UserData*> user, const MTPChannelBannedRights &rights);
|
void editRestrictedDone(
|
||||||
|
not_null<UserData*> user,
|
||||||
|
const MTPChannelBannedRights &rights);
|
||||||
void removeKicked(not_null<PeerListRow*> row, not_null<UserData*> user);
|
void removeKicked(not_null<PeerListRow*> row, not_null<UserData*> user);
|
||||||
void kickMember(not_null<UserData*> user);
|
void kickMember(not_null<UserData*> user);
|
||||||
void kickMemberSure(not_null<UserData*> user);
|
void kickMemberSure(not_null<UserData*> user);
|
||||||
|
|
Loading…
Reference in New Issue