Don't hardcode ver, update node name, and add tests

This commit is contained in:
Luca Matei Pintilie
2026-08-19 21:30:27 +02:00
parent 567b139e1c
commit df83dd19ae
10 changed files with 223 additions and 13 deletions
+17 -10
View File
@@ -1,3 +1,4 @@
#include <xmpp/hash_disco.hpp>
#include <xmpp/biboumi_component.hpp>
#include <utils/timed_events.hpp>
@@ -13,7 +14,6 @@
#include <xmpp/jid.hpp>
#include <stdexcept>
#include <iostream>
#include <cstdlib>
@@ -545,7 +545,8 @@ void BiboumiComponent::handle_iq(const Stanza& stanza)
const std::string node = query->get_tag("node");
if (to_str == this->served_hostname)
{
if (node.empty() || node.rfind("https://biboumi.louiz.org/#", 0) == 0)
const std::string expected_node_name = (NODE_NAME "#" + this->get_self_ver());
if (node.empty() || node == expected_node_name)
{
// On the gateway itself
this->send_self_disco_info(id, from, node);
@@ -952,21 +953,18 @@ std::vector<Bridge*> BiboumiComponent::get_bridges() const
return res;
}
void BiboumiComponent::send_self_disco_info(const std::string& id, const std::string& jid_to, const std::string& node)
Stanza BiboumiComponent::get_self_disco_info(const std::string &node)
{
Stanza iq("iq");
{
iq["type"] = "result";
iq["id"] = id;
if (!node.empty()) iq["node"] = node;
iq["to"] = jid_to;
iq["from"] = this->served_hostname;
XmlSubNode query(iq, "query");
query["xmlns"] = DISCO_INFO_NS;
if (!node.empty()) query["node"] = node;
XmlSubNode gwid(query, "identity");
gwid["category"] = "gateway";
gwid["type"] = "irc";
gwid["name"] = "Biboumi";
gwid["name"] = "Biboumi (" SOFTWARE_VERSION ")";
XmlSubNode identity(query, "identity");
identity["category"] = "conference";
identity["type"] = "irc";
@@ -977,6 +975,15 @@ void BiboumiComponent::send_self_disco_info(const std::string& id, const std::st
feature["var"] = ns;
}
}
return iq;
}
void BiboumiComponent::send_self_disco_info(const std::string& id, const std::string& jid_to, const std::string& node)
{
Stanza iq = this->get_self_disco_info(node);
iq["id"] = id;
iq["to"] = jid_to;
iq["from"] = this->served_hostname;
this->send_stanza(iq);
}
@@ -1213,8 +1220,8 @@ void BiboumiComponent::send_presence_to_contact(const std::string& from, const s
XmlSubNode c(presence, "c");
c["xmlns"] = CAPS_NS;
c["hash"] = "sha-1";
c["node"] = "https://biboumi.louiz.org/";
c["ver"] = "URGCt+50NTdI6Ifcm1/YYNVxSjc=";
c["node"] = NODE_NAME;
c["ver"] = this->get_self_ver();
}
this->send_stanza(presence);
}