diff options
author | louiz’ <louiz@louiz.org> | 2017-04-19 23:33:07 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-04-19 23:33:48 +0200 |
commit | 51696c091cc7058b05b33f1085b1246f3b5dc59f (patch) | |
tree | 9ed811ffecaf8a0a41fbacea6f23cef57497e4ef /src/bridge | |
parent | 47ff1cd3116424342c79d173d30a0f118859bc9f (diff) | |
download | biboumi-51696c091cc7058b05b33f1085b1246f3b5dc59f.tar.gz biboumi-51696c091cc7058b05b33f1085b1246f3b5dc59f.tar.bz2 biboumi-51696c091cc7058b05b33f1085b1246f3b5dc59f.tar.xz biboumi-51696c091cc7058b05b33f1085b1246f3b5dc59f.zip |
Make sure the channel is joined before trying to leave it
fix #3243
Diffstat (limited to 'src/bridge')
-rw-r--r-- | src/bridge/bridge.cpp | 12 | ||||
-rw-r--r-- | src/bridge/bridge.hpp | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 69e8c35..589bd03 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -425,7 +425,6 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con return ; IrcChannel* channel = irc->get_channel(iid.get_local()); - auto nick = channel->get_self()->nick; const auto resources = this->number_of_resources_in_chan(key); if (resources == 1) @@ -447,9 +446,9 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con else irc->send_part_command(iid.get_local(), status_message); } - else + else if (channel->joined) { - this->send_muc_leave(iid, std::move(nick), "", true, resource); + this->send_muc_leave(iid, channel->get_self()->nick, "", true, resource); } // Since there are no resources left in that channel, we don't // want to receive private messages using this room's JID @@ -457,8 +456,8 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con } else { - if (channel) - this->send_muc_leave(iid, std::move(nick), + if (channel && channel->joined) + this->send_muc_leave(iid, channel->get_self()->nick, "Biboumi note: "s + std::to_string(resources - 1) + " resources are still in this channel.", true, resource); this->remove_resource_from_chan(key, resource); @@ -876,7 +875,8 @@ void Bridge::send_presence_error(const Iid& iid, const std::string& nick, this->xmpp.send_presence_error(std::to_string(iid), nick, this->user_jid, type, condition, error_code, text); } -void Bridge::send_muc_leave(const Iid &iid, std::string&& nick, const std::string& message, const bool self, +void Bridge::send_muc_leave(const Iid& iid, const std::string& nick, + const std::string& message, const bool self, const std::string& resource) { if (!resource.empty()) diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp index 1c89bd5..d8facad 100644 --- a/src/bridge/bridge.hpp +++ b/src/bridge/bridge.hpp @@ -169,7 +169,7 @@ public: /** * Send an unavailable presence from this participant */ - void send_muc_leave(const Iid& iid, std::string&& nick, const std::string& message, const bool self, const std::string& resource = ""); + void send_muc_leave(const Iid& iid, const std::string& nick, const std::string& message, const bool self, const std::string& resource = ""); /** * Send presences to indicate that an user old_nick (ourself if self == * true) changed his nick to new_nick. The user_mode is needed because |