summaryrefslogtreecommitdiff
path: root/src/bridge/bridge.cpp
diff options
context:
space:
mode:
authorJonas Schäfer <j.wielicki@sotecware.net>2019-08-05 18:23:41 +0200
committerJonas Schäfer <j.wielicki@sotecware.net>2019-08-20 21:42:43 +0200
commitb68f36056dab9f7cd8f6b9fcda4db445df1b5ada (patch)
treefde671310cf165cb50d10f2c78800fe73fd3adc7 /src/bridge/bridge.cpp
parenta8cd24148522473caba5ba46b06c9b7b5f6633a9 (diff)
downloadbiboumi-b68f36056dab9f7cd8f6b9fcda4db445df1b5ada.tar.gz
biboumi-b68f36056dab9f7cd8f6b9fcda4db445df1b5ada.tar.bz2
biboumi-b68f36056dab9f7cd8f6b9fcda4db445df1b5ada.tar.xz
biboumi-b68f36056dab9f7cd8f6b9fcda4db445df1b5ada.zip
XEP-0410: implement server-side optimisation for self-pings
This prevents the ping from round-tripping through IRC and possibly a random other client of the user. Please see XEP-0410 for the rationale. Fixes #3385.
Diffstat (limited to 'src/bridge/bridge.cpp')
-rw-r--r--src/bridge/bridge.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index 65a345e..f065930 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -747,6 +747,23 @@ void Bridge::send_irc_participant_ping_request(const Iid& iid, const std::string
"", true);
return;
}
+ if (chan->get_self()->nick == nick)
+ {
+ // XEP-0410 self-ping optimisation: always reply without going the full
+ // round-trip through IRC and possibly another XMPP client. See the XEP
+ // for details.
+ Jid iq_from(from_jid);
+ iq_from.local = std::to_string(iid);
+ iq_from.resource = nick;
+
+ Stanza iq("iq");
+ iq["from"] = iq_from.full();
+ iq["to"] = to_jid;
+ iq["id"] = iq_id;
+ iq["type"] = "result";
+ this->xmpp.send_stanza(iq);
+ return;
+ }
if (chan->get_self()->nick != nick && !chan->find_user(nick))
{
this->xmpp.send_stanza_error("iq", to_jid, from_jid, iq_id, "cancel", "item-not-found",