From 30359b48e18bcf171a53d50d84a178b9cb376d7a Mon Sep 17 00:00:00 2001 From: Kevin Smith <git@kismith.co.uk> Date: Wed, 19 Oct 2011 12:03:21 +0100 Subject: Use real JID for bans, not room JID. Resolves: #1020 diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 6d3f9f2..1120f4b 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -126,12 +126,18 @@ void MUCController::handleWindowOccupantSelectionChanged(ContactRosterItem* item } void MUCController::handleActionRequestedOnOccupant(ChatWindow::OccupantAction action, ContactRosterItem* item) { + JID mucJID = item->getJID(); + MUCOccupant occupant = muc_->getOccupant(mucJID.getResource()); + JID realJID; + if (occupant.getRealJID()) { + realJID = occupant.getRealJID().get(); + } switch (action) { - case ChatWindow::Kick: muc_->kickOccupant(item->getJID());break; - case ChatWindow::Ban: muc_->changeAffiliation(item->getJID(), MUCOccupant::Outcast);break; - case ChatWindow::MakeModerator: muc_->changeOccupantRole(item->getJID(), MUCOccupant::Moderator);break; - case ChatWindow::MakeParticipant: muc_->changeOccupantRole(item->getJID(), MUCOccupant::Participant);break; - case ChatWindow::MakeVisitor: muc_->changeOccupantRole(item->getJID(), MUCOccupant::Visitor);break; + case ChatWindow::Kick: muc_->kickOccupant(mucJID);break; + case ChatWindow::Ban: muc_->changeAffiliation(realJID, MUCOccupant::Outcast);break; + case ChatWindow::MakeModerator: muc_->changeOccupantRole(mucJID, MUCOccupant::Moderator);break; + case ChatWindow::MakeParticipant: muc_->changeOccupantRole(mucJID, MUCOccupant::Participant);break; + case ChatWindow::MakeVisitor: muc_->changeOccupantRole(mucJID, MUCOccupant::Visitor);break; } } diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp index 824ced1..78546c8 100644 --- a/Swiften/MUC/MUC.cpp +++ b/Swiften/MUC/MUC.cpp @@ -233,7 +233,7 @@ bool MUC::hasOccupant(const std::string& nick) { return occupants.find(nick) != occupants.end(); } -MUCOccupant MUC::getOccupant(const std::string& nick) { +const MUCOccupant& MUC::getOccupant(const std::string& nick) { return occupants.find(nick)->second; } diff --git a/Swiften/MUC/MUC.h b/Swiften/MUC/MUC.h index 1070c69..39acb22 100644 --- a/Swiften/MUC/MUC.h +++ b/Swiften/MUC/MUC.h @@ -54,7 +54,7 @@ namespace Swift { /** Expose public so it can be called when e.g. user goes offline */ void handleUserLeft(LeavingType); /** Get occupant information*/ - MUCOccupant getOccupant(const std::string& nick); + const MUCOccupant& getOccupant(const std::string& nick); bool hasOccupant(const std::string& nick); void kickOccupant(const JID& jid); void changeOccupantRole(const JID& jid, MUCOccupant::Role role); -- cgit v0.10.2-6-g49f6