summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2016-04-25 11:29:52 +0200
committerlouiz’ <louiz@louiz.org>2016-04-27 11:03:52 +0200
commit1e56c59e8241dbfc6a2526c371cc2e894f9d0f18 (patch)
tree5f4e2de755e26e751f03e09c8ad02ebb17a31b09 /src
parent82e0cf99b0dd0ba48f31060656d03a9586b939c6 (diff)
downloadbiboumi-1e56c59e8241dbfc6a2526c371cc2e894f9d0f18.tar.gz
biboumi-1e56c59e8241dbfc6a2526c371cc2e894f9d0f18.tar.bz2
biboumi-1e56c59e8241dbfc6a2526c371cc2e894f9d0f18.tar.xz
biboumi-1e56c59e8241dbfc6a2526c371cc2e894f9d0f18.zip
Include the Configure ad-hoc command on biboumi's JID for fixed_irc_server
Because a jid like “freenode.example.org” is both the JID for the configured IRC server, and biboumi’s JID. fix #3175
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/biboumi_adhoc_commands.cpp14
-rw-r--r--src/xmpp/biboumi_component.cpp11
2 files changed, 20 insertions, 5 deletions
diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp
index 7c157cb..eec930d 100644
--- a/src/xmpp/biboumi_adhoc_commands.cpp
+++ b/src/xmpp/biboumi_adhoc_commands.cpp
@@ -118,16 +118,19 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com
{
const Jid owner(session.get_owner_jid());
const Jid target(session.get_target_jid());
+ std::string server_domain;
+ if ((server_domain = Config::get("fixed_irc_server", "")).empty())
+ server_domain = target.local;
auto options = Database::get_irc_server_options(owner.local + "@" + owner.domain,
- target.local);
+ server_domain);
XmlNode x("jabber:x:data:x");
x["type"] = "form";
XmlNode title("title");
- title.set_inner("Configure the IRC server "s + target.local);
+ title.set_inner("Configure the IRC server "s + server_domain);
x.add_child(std::move(title));
XmlNode instructions("instructions");
- instructions.set_inner("Edit the form, to configure the settings of the IRC server "s + target.local);
+ instructions.set_inner("Edit the form, to configure the settings of the IRC server "s + server_domain);
x.add_child(std::move(instructions));
XmlNode required("required");
@@ -285,8 +288,11 @@ void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& com
{
const Jid owner(session.get_owner_jid());
const Jid target(session.get_target_jid());
+ std::string server_domain;
+ if ((server_domain = Config::get("fixed_irc_server", "")).empty())
+ server_domain = target.local;
auto options = Database::get_irc_server_options(owner.local + "@" + owner.domain,
- target.local);
+ server_domain);
for (const XmlNode* field: x->get_children("field", "jabber:x:data"))
{
const XmlNode* value = field->get_child("value", "jabber:x:data");
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index 65fbfc5..5b1d0e0 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -61,9 +61,18 @@ BiboumiComponent::BiboumiComponent(std::shared_ptr<Poller> poller, const std::st
{"reload", AdhocCommand({&Reload}, "Reload biboumi’s configuration", true)}
};
+#ifdef USE_DATABASE
+ AdhocCommand configure_server_command({&ConfigureIrcServerStep1, &ConfigureIrcServerStep2}, "Configure a few settings for that IRC server", false);
+ if (!Config::get("fixed_irc_server", "").empty())
+ {
+ this->adhoc_commands_handler.get_commands().emplace(std::make_pair("configure",
+ configure_server_command));
+ }
+#endif
+
this->irc_server_adhoc_commands_handler.get_commands() = {
#ifdef USE_DATABASE
- {"configure", AdhocCommand({&ConfigureIrcServerStep1, &ConfigureIrcServerStep2}, "Configure a few settings for that IRC server", false)},
+ {"configure", configure_server_command},
#endif
};
this->irc_channel_adhoc_commands_handler.get_commands() = {