diff options
author | louiz’ <louiz@louiz.org> | 2019-11-06 17:21:28 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2019-11-06 17:23:43 +0100 |
commit | e4a4addaf86abbee9d9bf5c486c5d1eaa78b6c2e (patch) | |
tree | 8a800e5ce3d892e9353b3edbf33d6055ec5d8383 | |
parent | 34b4caeccf03f4f6ae14e94b35ca1bb6e3cee1ec (diff) | |
download | biboumi-e4a4addaf86abbee9d9bf5c486c5d1eaa78b6c2e.tar.gz biboumi-e4a4addaf86abbee9d9bf5c486c5d1eaa78b6c2e.tar.bz2 biboumi-e4a4addaf86abbee9d9bf5c486c5d1eaa78b6c2e.tar.xz biboumi-e4a4addaf86abbee9d9bf5c486c5d1eaa78b6c2e.zip |
Add a missing max_history_length field in the IRC server option form
-rw-r--r-- | src/xmpp/biboumi_adhoc_commands.cpp | 18 | ||||
-rw-r--r-- | tests/end_to_end/scenarios/irc_server_configure.py | 5 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp index ef230fe..113943c 100644 --- a/src/xmpp/biboumi_adhoc_commands.cpp +++ b/src/xmpp/biboumi_adhoc_commands.cpp @@ -388,6 +388,15 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com } { + XmlSubNode max_history_length(x, "field"); + max_history_length["var"] = "max_history_length"; + max_history_length["type"] = "text-single"; + max_history_length["label"] = "Throttle limit"; + XmlSubNode value(max_history_length, "value"); + value.set_inner(std::to_string(options.col<Database::MaxHistoryLength>())); + } + + { XmlSubNode encoding_out(x, "field"); encoding_out["var"] = "encoding_out"; encoding_out["type"] = "text-single"; @@ -514,6 +523,15 @@ void ConfigureIrcServerStep2(XmppComponent& xmpp_component, AdhocSession& sessio } } + else if (field->get_tag("var") == "max_history_length" && value) + { + try { + options.col<Database::MaxHistoryLength>() = std::stol(value->get_inner()); + } catch (const std::logic_error&) { + options.col<Database::MaxHistoryLength>() = 20; + } + } + else if (field->get_tag("var") == "encoding_out" && value) options.col<Database::EncodingOut>() = value->get_inner(); diff --git a/tests/end_to_end/scenarios/irc_server_configure.py b/tests/end_to_end/scenarios/irc_server_configure.py index 608364f..5ba619a 100644 --- a/tests/end_to_end/scenarios/irc_server_configure.py +++ b/tests/end_to_end/scenarios/irc_server_configure.py @@ -14,6 +14,7 @@ scenario = ( "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='throttle_limit']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-private'][@var='pass']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-multi'][@var='after_connect_commands']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='max_history_length']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='nick']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='username']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='realname']", @@ -34,6 +35,7 @@ scenario = ( "<field var='nick'><value>my_nickname</value></field>" "<field var='username'><value>username</value></field>" "<field var='throttle_limit'><value>42</value></field>" + "<field var='max_history_length'><value>69</value></field>" "<field var='realname'><value>realname</value></field>" "<field var='encoding_out'><value>UTF-8</value></field>" "<field var='encoding_in'><value>latin-1</value></field>" @@ -56,6 +58,7 @@ scenario = ( "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='username']/dataform:value[text()='username']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='realname']/dataform:value[text()='realname']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='throttle_limit']/dataform:value[text()='42']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='max_history_length']/dataform:value[text()='69']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']/dataform:value[text()='latin-1']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']/dataform:value[text()='UTF-8']", "/iq/commands:command/commands:actions/commands:complete", @@ -94,7 +97,7 @@ scenario = ( "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='encoding_in']/dataform:value", "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='encoding_out']/dataform:value", "/iq/commands:command/commands:actions/commands:complete", - "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='throttle_limit']/dataform:value[text()='-1']", # An invalid value sets this field to -1, aka disabled + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='throttle_limit']/dataform:value[text()='10']", # An invalid value sets this field to its default value after = save_value("sessionid", extract_attribute("/iq[@type='result']/commands:command[@node='configure']", "sessionid")) ), send_stanza("<iq type='set' id='id4' from='{jid_one}/{resource_one}' to='{irc_server_one}'><command xmlns='http://jabber.org/protocol/commands' action='cancel' node='configure' sessionid='{sessionid}' /></iq>"), |