Changeset - 9ff51c193cc3
[Not reviewed]
0 3 0
Jan Kaluza - 9 years ago 2016-01-05 15:44:18
jkaluza@redhat.com
Twitter: Fix joining room by disabling sending raw xml to backends which do not need it
3 files changed with 10 insertions and 1 deletions:
0 comments (0 inline, 0 general)
backends/twitter/TwitterPlugin.cpp
Show inline comments
 
@@ -168,27 +168,28 @@ void TwitterPlugin::handleLogoutRequest(const std::string &user, const std::stri
 
		userdb[user].connectionState = DISCONNECTED;
 
	}
 

	
 
	if(onlineUsers.count(user)) {
 
		onlineUsers.erase(user);
 
	}
 
}
 

	
 
// User joining a Chatroom
 
void TwitterPlugin::handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &password)
 
{
 
	if(room == adminChatRoom) {	
 
		LOG4CXX_INFO(logger, "Received Join Twitter room request for " << user)
 
		LOG4CXX_INFO(logger, "Received Join Twitter room request for " << user << " '" << nickname << "'")
 

	
 
		setTwitterMode(user, 2);
 
		handleParticipantChanged(user, nickname, room, 0, pbnetwork::STATUS_ONLINE);
 
		handleParticipantChanged(user, adminNickName, room, 0, pbnetwork::STATUS_ONLINE);
 
		userdb[user].nickName = nickname;
 
		handleMessage(user, adminChatRoom, "Connected to Twitter room! Populating your followers list", adminNickName);
 
		tp->runAsThread(new FetchFriends(userdb[user].sessions, user,
 
										 boost::bind(&TwitterPlugin::populateRoster, this, _1, _2, _3, _4)));
 
	} else {
 
		setTwitterMode(user, 0);
 
		LOG4CXX_ERROR(logger, "Couldn't connect to chatroom - " << room <<"! Try twitter-chatroom as the chatroom to access Twitter account")
 
		handleMessage(user, adminLegacyName, "Couldn't connect to chatroom! Try twitter-chatroom as the chatroom to access Twitter account");
 
	}	
 
}
 

	
libtransport/NetworkPluginServer.cpp
Show inline comments
 
@@ -1094,24 +1094,28 @@ void NetworkPluginServer::handleElement(boost::shared_ptr<Swift::Element> elemen
 
// 			}
 
// 		}
 
// 		m_component->getFrontend()->sendIQ(iq);
 
// 		return;
 
// 	}
 
}
 

	
 
void NetworkPluginServer::handleRawXML(const std::string &xml) {
 
	m_xmppParser->parse(xml);
 
}
 

	
 
void NetworkPluginServer::handleRawPresenceReceived(boost::shared_ptr<Swift::Presence> presence) {
 
	if (!CONFIG_BOOL_DEFAULTED(m_config, "features.rawxml", false)) {
 
		return;
 
	}
 

	
 
	User *user = m_userManager->getUser(presence->getFrom().toBare());
 
	if (!user)
 
		return;
 

	
 
	Backend *c = (Backend *) user->getData();
 
	if (!c) {
 
		return;
 
	}
 

	
 
	Swift::JID legacyname = Swift::JID(Buddy::JIDToLegacyName(presence->getTo()));
 
	if (!presence->getTo().getResource().empty()) {
 
		presence->setTo(Swift::JID(legacyname.getNode(), legacyname.getDomain(), presence->getTo().getResource()));
tests/twitter/twitter_test.py
Show inline comments
 
@@ -32,24 +32,25 @@ class Client(sleekxmpp.ClientXMPP):
 

	
 
		self.tests = {}
 
		self.tests["timeline_poll"] = ["Timeline received automatically", False]
 
		self.tests["help"] = ["#help command", False]
 
		self.tests["status1"] = ["#status command response", False]
 
		self.tests["status2"] = ["#status command pushes status", False]
 
		self.tests["follow"] = ["#follow command", False]
 
		self.tests["friends"] = ["#friends command", False]
 
		self.tests["unfollow"] = ["#unfollow command", False]
 
		self.tests["friends2"] = ["#friends after unfollow command", False]
 
		self.tests["mode1"] = ["#mode 1 response", False]
 
		self.tests["mode1buddy"] = ["#mode 1 buddy added", False]
 
		self.tests["mode2"] = ["#mode 2 join room", False]
 

	
 
		self.status = "timeline"
 
		self.timestamp = int(time.time())
 

	
 
	def message(self, msg):
 
		if self.status == "timeline" and msg['body'].find("spectrum2tests") != -1 and msg['body'].find("MsgId") != -1:
 
			self.tests["timeline_poll"][1] = True
 
			self.send_message(mto=msg['from'], mbody="#help")
 
			self.status = "help"
 
		elif self.status == "help" and msg['body'].find("You will receive tweets of people you follow") != -1:
 
			self.tests["help"][1] = True
 
			self.send_message(mto=msg['from'], mbody="#status My testing status " + str(self.timestamp))
 
@@ -74,20 +75,23 @@ class Client(sleekxmpp.ClientXMPP):
 
			self.status = "friends2"
 
			self.tests["unfollow"][1] = True
 
			self.send_message(mto=msg['from'], mbody="#friends")
 
		elif self.status == "friends2" and msg['body'].find("USER LIST") != -1 and msg['body'].find("colinpwheeler") == -1:
 
			self.status = "mode1"
 
			self.tests["friends2"][1] = True
 
			self.finished = True
 

	
 
	def roster_update(self, iq):
 
		roster = iq['roster']['items']
 

	
 
		if self.status == "mode1" and roster.has_key("colinpwheeler@localhost"):
 
			self.plugin['xep_0045'].joinMUC("#twitter@localhost", "client", wait=True)
 
			self.tests["mode2"][1] = True
 
			self.plugin['xep_0045'].leaveMUC("#twitter@localhost", "client")
 
			self.status = "unfollow"
 
			self.tests["mode1buddy"][1] = True
 
			self.send_message(mto="twitter.com@localhost", mbody="#unfollow colinpwheeler")
 

	
 
	def start(self, event):
 
		self.getRoster()
 
		self.sendPresence()
 

	
0 comments (0 inline, 0 general)