Commit 161a7988 authored by me@boku.ru's avatar me@boku.ru Committed by vitalyster

Use the default JID resource for the sender when forming carbons

parent 0a78acef
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#include "Swiften/Elements/VCard.h" #include "Swiften/Elements/VCard.h"
#include "Swiften/Elements/Presence.h" #include "Swiften/Elements/Presence.h"
//Default resource name which contacts use
#define JID_DEFAULT_RESOURCE "bot"
namespace Transport { namespace Transport {
class RosterManager; class RosterManager;
......
...@@ -49,7 +49,7 @@ void Buddy::sendPresence() { ...@@ -49,7 +49,7 @@ void Buddy::sendPresence() {
void Buddy::generateJID() { void Buddy::generateJID() {
m_jid = Swift::JID(); m_jid = Swift::JID();
m_jid = Swift::JID(getSafeName(), m_rosterManager->getUser()->getComponent()->getJID().toString(), "bot"); m_jid = Swift::JID(getSafeName(), m_rosterManager->getUser()->getComponent()->getJID().toString(), JID_DEFAULT_RESOURCE);
} }
void Buddy::setID(long id) { void Buddy::setID(long id) {
......
...@@ -241,9 +241,13 @@ void Conversation::handleMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Mes ...@@ -241,9 +241,13 @@ void Conversation::handleMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Mes
#ifdef SWIFTEN_SUPPORTS_CARBONS #ifdef SWIFTEN_SUPPORTS_CARBONS
LOG4CXX_INFO(logger, "CARBON MSG"); LOG4CXX_INFO(logger, "CARBON MSG");
//Swap from and to //Swap from and to
Swift::JID from = message->getFrom(); Swift::JID from = message->getTo();
message->setFrom(message->getTo()); if (from.getResource().empty()) {
message->setTo(from); //If no resource is specified, set the same that is used for legacy network contacts
from = Swift::JID(from.getNode(), from.getDomain(), JID_DEFAULT_RESOURCE);
}
message->setTo(message->getFrom());
message->setFrom(from);
//Carbons should be sent to every resource directly. //Carbons should be sent to every resource directly.
//Even if we tried to send to bare jid, the server would at best route it //Even if we tried to send to bare jid, the server would at best route it
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment