diff options
| author | Kevin Smith <git@kismith.co.uk> | 2011-10-18 14:27:12 (GMT) |
|---|---|---|
| committer | Kevin Smith <git@kismith.co.uk> | 2011-10-18 14:27:22 (GMT) |
| commit | c1663b9b935eeeef87fb242e09efc48a1b1b5dca (patch) | |
| tree | f555695d29277447efd49b2c11979f8e7540d60a /Swift/Controllers/Chat/MUCController.cpp | |
| parent | cc3828e7f77074064f92ddf306765da0780fa823 (diff) | |
| download | swift-contrib-c1663b9b935eeeef87fb242e09efc48a1b1b5dca.zip swift-contrib-c1663b9b935eeeef87fb242e09efc48a1b1b5dca.tar.bz2 | |
When changing affiliation, only send the new one.
Previously removing from admin and adding to members would send both none and member, causing people to be ejected from members-only rooms.
Resolves: #1016
Diffstat (limited to 'Swift/Controllers/Chat/MUCController.cpp')
| -rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 30e85ad..6d3f9f2 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -613,45 +613,53 @@ void MUCController::handleConfigurationFailed(ErrorPayload::ref error) { chatWindow_->addErrorMessage(errorMessage); } void MUCController::handleOccupantRoleChangeFailed(ErrorPayload::ref error, const JID&, MUCOccupant::Role) { std::string errorMessage = getErrorMessage(error); errorMessage = str(format(QT_TRANSLATE_NOOP("", "Occupant role change failed: %1%.")) % errorMessage); chatWindow_->addErrorMessage(errorMessage); } void MUCController::handleConfigurationFormReceived(Form::ref form) { chatWindow_->showRoomConfigurationForm(form); } void MUCController::handleConfigurationCancelled() { muc_->cancelConfigureRoom(); } void MUCController::handleDestroyRoomRequest() { muc_->destroyRoom(); } void MUCController::handleInvitePersonToThisMUCRequest(const JID& jid, const std::string& reason) { muc_->invitePerson(jid, reason); } void MUCController::handleGetAffiliationsRequest() { muc_->requestAffiliationList(MUCOccupant::Owner); muc_->requestAffiliationList(MUCOccupant::Admin); muc_->requestAffiliationList(MUCOccupant::Member); muc_->requestAffiliationList(MUCOccupant::Outcast); } typedef std::pair<MUCOccupant::Affiliation, JID> AffiliationChangePair; void MUCController::handleChangeAffiliationsRequest(const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& changes) { + std::set<JID> addedJIDs; foreach (const AffiliationChangePair& change, changes) { - muc_->changeAffiliation(change.second, change.first); + if (change.first != MUCOccupant::NoAffiliation) { + addedJIDs.insert(change.second); + } + } + foreach (const AffiliationChangePair& change, changes) { + if (change.first != MUCOccupant::NoAffiliation || addedJIDs.find(change.second) == addedJIDs.end()) { + muc_->changeAffiliation(change.second, change.first); + } } } void MUCController::handleAffiliationListReceived(MUCOccupant::Affiliation affiliation, const std::vector<JID>& jids) { chatWindow_->setAffiliations(affiliation, jids); } } |
Swift