summaryrefslogtreecommitdiff
path: root/src/bridge
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2018-03-12 00:04:26 +0100
committerlouiz’ <louiz@louiz.org>2018-03-12 00:13:59 +0100
commitbb596582bd2d8b9aab3fe08e76a7d24d82bf614a (patch)
tree9ebe416dfb7b9b2dd6c6a4ba4b56a69b7c455456 /src/bridge
parent158d743bf539399e48c64044639b90e5c1705ac1 (diff)
downloadbiboumi-bb596582bd2d8b9aab3fe08e76a7d24d82bf614a.tar.gz
biboumi-bb596582bd2d8b9aab3fe08e76a7d24d82bf614a.tar.bz2
biboumi-bb596582bd2d8b9aab3fe08e76a7d24d82bf614a.tar.xz
biboumi-bb596582bd2d8b9aab3fe08e76a7d24d82bf614a.zip
Add a <item/> node in the presence of a leaving participant
fix #3339
Diffstat (limited to 'src/bridge')
-rw-r--r--src/bridge/bridge.cpp24
-rw-r--r--src/bridge/bridge.hpp2
2 files changed, 18 insertions, 8 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index cd3492f..9269bb7 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -419,7 +419,7 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
}
else if (channel->joined)
{
- this->send_muc_leave(iid, channel->get_self()->nick, "", true, true, resource);
+ this->send_muc_leave(iid, *channel->get_self(), "", true, true, resource);
}
if (persistent)
this->remove_resource_from_chan(key, resource);
@@ -430,7 +430,7 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
else
{
if (channel && channel->joined)
- this->send_muc_leave(iid, channel->get_self()->nick,
+ this->send_muc_leave(iid, *channel->get_self(),
"Biboumi note: " + std::to_string(resources - 1) + " resources are still in this channel.",
true, true, resource);
this->remove_resource_from_chan(key, resource);
@@ -847,19 +847,29 @@ 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, const std::string& nick,
+void Bridge::send_muc_leave(const Iid& iid, const IrcUser& user,
const std::string& message, const bool self,
const bool user_requested,
const std::string& resource)
{
+ const IrcClient* client = this->find_irc_client(iid.get_server());
+ if (!client)
+ {
+ log_error("Tried to send an unavailable presence for non existant client: ", std::to_string(iid));
+ return;
+ }
+ std::string affiliation;
+ std::string role;
+ std::tie(role, affiliation) = get_role_affiliation_from_irc_mode(user.get_most_significant_mode(client->get_sorted_user_modes()));
+
if (!resource.empty())
- this->xmpp.send_muc_leave(std::to_string(iid), nick, this->make_xmpp_body(message),
- this->user_jid + "/" + resource, self, user_requested);
+ this->xmpp.send_muc_leave(std::to_string(iid), user.nick, this->make_xmpp_body(message),
+ this->user_jid + "/" + resource, self, user_requested, affiliation, role);
else
{
for (const auto &res: this->resources_in_chan[iid.to_tuple()])
- this->xmpp.send_muc_leave(std::to_string(iid), nick, this->make_xmpp_body(message),
- this->user_jid + "/" + res, self, user_requested);
+ this->xmpp.send_muc_leave(std::to_string(iid), user.nick, this->make_xmpp_body(message),
+ this->user_jid + "/" + res, self, user_requested, affiliation, role);
if (self)
{
// Copy the resources currently in that channel
diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp
index c2f0233..44df4c2 100644
--- a/src/bridge/bridge.hpp
+++ b/src/bridge/bridge.hpp
@@ -170,7 +170,7 @@ public:
/**
* Send an unavailable presence from this participant
*/
- void send_muc_leave(const Iid& iid, const std::string& nick,
+ void send_muc_leave(const Iid& iid, const IrcUser& nick,
const std::string& message, const bool self,
const bool user_requested,
const std::string& resource="");