diff --git a/backends/swiften/main.cpp b/backends/swiften/main.cpp index 5a2c1f37..424ce975 100644 --- a/backends/swiften/main.cpp +++ b/backends/swiften/main.cpp @@ -143,7 +143,13 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient { boost::shared_ptr iq = boost::dynamic_pointer_cast(stanza); if (iq) { if (m_handlers[user]->m_id2resource.find(stanza->getID()) != m_handlers[user]->m_id2resource.end()) { - iq->setTo(Swift::JID(iq->getTo().getNode(), iq->getTo().getDomain(), m_handlers[user]->m_id2resource[stanza->getID()])); + std::string resource = m_handlers[user]->m_id2resource[stanza->getID()]; + if (resource.empty()) { + iq->setTo(Swift::JID(iq->getTo().getNode(), iq->getTo().getDomain())); + } else { + iq->setTo(Swift::JID(iq->getTo().getNode(), iq->getTo().getDomain(), resource)); + } + m_handlers[user]->m_id2resource.erase(stanza->getID()); } client->getIQRouter()->sendIQ(iq);