Changeset - cedac0a9b001
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2016-02-01 10:16:06
jkaluza@redhat.com
Fix leaving the room
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
spectrum/src/frontends/slack/SlackSession.cpp
Show inline comments
 
@@ -190,49 +190,49 @@ void SlackSession::handleJoinRoomCreated(const std::string &channelId, std::vect
 
	m_component->getFrontend()->onPresenceReceived(presence);
 

	
 
	m_onlineBuddiesTimer->start();
 
}
 

	
 
void SlackSession::handleJoinMessage(const std::string &message, std::vector<std::string> &args, bool quiet) {
 
	LOG4CXX_INFO(logger, m_uinfo.jid << ": Going to join the room " << args[3] << "@" << args[4] << ", transporting it to channel " << args[5]);
 
	m_api->createChannel(args[5], m_idManager->getSelfId(), boost::bind(&SlackSession::handleJoinRoomCreated, this, _1, args));
 
}
 

	
 
void SlackSession::handleSlackChannelCreated(const std::string &channelId) {
 
	m_slackChannel = channelId;
 

	
 
	LOG4CXX_INFO(logger, m_uinfo.jid << ": Main Slack Channel created, connecting the legacy network");
 
	Swift::Presence::ref presence = Swift::Presence::create();
 
	presence->setFrom(Swift::JID("", m_uinfo.jid, "default"));
 
	presence->setTo(m_component->getJID());
 
	presence->setType(Swift::Presence::Available);
 
	presence->addPayload(boost::shared_ptr<Swift::Payload>(new Swift::MUCPayload()));
 
	m_component->getFrontend()->onPresenceReceived(presence);
 
}
 

	
 
void SlackSession::leaveRoom(const std::string &channel) {
 
	std::string channelId = m_idManager->getId(channel);
 
	std::string to = m_channel2jid[channel];
 
	std::string to = m_channel2jid[channelId];
 
	if (to.empty()) {
 
		LOG4CXX_ERROR(logger, "Spectrum 2 is not configured to transport this Slack channel.")
 
		return;
 
	}
 

	
 
	LOG4CXX_INFO(logger, m_uinfo.jid << ": Leaving the legacy network room " << to);
 

	
 
	Swift::Presence::ref presence = Swift::Presence::create();
 
	presence->setFrom(Swift::JID("", m_uinfo.jid, "default"));
 
	presence->setTo(Swift::JID(to + "/" + m_uinfo.uin));
 
	presence->setType(Swift::Presence::Unavailable);
 
	presence->addPayload(boost::shared_ptr<Swift::Payload>(new Swift::MUCPayload()));
 
	m_component->getFrontend()->onPresenceReceived(presence);
 
}
 

	
 
void SlackSession::handleMessageReceived(const std::string &channel, const std::string &user, const std::string &message, const std::string &ts, bool quiet) {
 
	std::string to = m_channel2jid[channel];
 
	if (m_idManager->getName(user) == m_idManager->getSelfName()) {
 
		return;
 
	}
 

	
 
	if (!to.empty()) {
 
		boost::shared_ptr<Swift::Message> msg(new Swift::Message());
 
		msg->setType(Swift::Message::Groupchat);
0 comments (0 inline, 0 general)