summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-11-07 23:05:05 +0100
committerlouiz’ <louiz@louiz.org>2017-11-07 23:05:05 +0100
commitcb6b50dc0109ee3a201a4012b63f3914cc5ea6e3 (patch)
tree90f6ce10f84aaa8d7587b804b0c4ef3a5b5aba73 /src
parentf3b1e39cdd7c55c914659f5ac103c3a0855f8f3c (diff)
downloadbiboumi-cb6b50dc0109ee3a201a4012b63f3914cc5ea6e3.tar.gz
biboumi-cb6b50dc0109ee3a201a4012b63f3914cc5ea6e3.tar.bz2
biboumi-cb6b50dc0109ee3a201a4012b63f3914cc5ea6e3.tar.xz
biboumi-cb6b50dc0109ee3a201a4012b63f3914cc5ea6e3.zip
Change how we count the number of connected resources to a server
Diffstat (limited to 'src')
-rw-r--r--src/bridge/bridge.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index 8587264..eb1d553 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -894,7 +894,19 @@ void Bridge::send_muc_leave(const Iid& iid, const std::string& nick,
this->xmpp.send_muc_leave(std::to_string(iid), nick, this->make_xmpp_body(message),
this->user_jid + "/" + res, self, user_requested);
if (self)
- this->remove_all_resources_from_chan(iid.to_tuple());
+ {
+ // Copy the resources currently in that channel
+ const auto resources_in_chan = this->resources_in_chan[iid.to_tuple()];
+
+ this->remove_all_resources_from_chan(iid.to_tuple());
+
+ // Now, for each resource that was in that channel, remove it from the server if it’s
+ // not in any other channel
+ for (const auto& r: resources_in_chan)
+ if (this->number_of_channels_the_resource_is_in(iid.get_server(), r) == 0)
+ this->remove_resource_from_server(iid.get_server(), r);
+
+ }
}
IrcClient* irc = this->find_irc_client(iid.get_server());
@@ -1236,9 +1248,13 @@ std::size_t Bridge::number_of_channels_the_resource_is_in(const std::string& irc
std::size_t res = 0;
for (auto pair: this->resources_in_chan)
{
- if (std::get<0>(pair.first) == irc_hostname && pair.second.count(resource) != 0)
+ if (std::get<1>(pair.first) == irc_hostname && pair.second.count(resource) != 0)
res++;
}
+
+ IrcClient* irc = this->find_irc_client(irc_hostname);
+ if (irc && (irc->get_dummy_channel().joined || irc->get_dummy_channel().joining))
+ res++;
return res;
}