diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index df32551..0b90c8b 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -223,7 +223,10 @@ void Bridge::send_channel_message(const Iid& iid, const std::string& body, std:: if (lines.empty()) return ; - if (irc->has_capability("draft/multiline")) + if (irc->has_capability("draft/multiline") + // /me and /mode cannot be multi lined + && lines[0].substr(0, 5) != "/mode" + && lines[0].substr(0, 4) != "/me ") { std::string uuid; const auto xmpp_body = this->make_xmpp_body(body); @@ -277,15 +280,6 @@ void Bridge::send_channel_message(const Iid& iid, const std::string& body, std:: this->xmpp.send_stanza(stanza); } }; - - // MODE can't be multiline. Only check the first line, and discard the rest silently - if (lines[0].substr(0, 5) == "/mode") - { - std::vector args = utils::split(body.substr(5), ' ', false); - irc->send_mode_command(iid.get_local(), args); - return; // We do not want to send that back to the - // XMPP user, that’s not a textual message. - } irc->send_batch(uuid, "draft/multiline", {iid.get_local()}, messages, std::move(mirror_to_all_resources)); return; } diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index a1b972c..5e0503e 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -1528,7 +1528,7 @@ void IrcClient::process_batch(const std::string& reference_tag) for (const IrcMessage& message: it->second.second) { auto it_tags = message.tags.find("draft/multiline-concat"); - if (it_tags == message.tags.end()) + if (!body.empty() && it_tags == message.tags.end()) body += "\n" + message.arguments[1]; else body += message.arguments[1]; diff --git a/tests/end_to_end/scenarios/channel_messages.py b/tests/end_to_end/scenarios/channel_messages.py index b55914e..3262832 100644 --- a/tests/end_to_end/scenarios/channel_messages.py +++ b/tests/end_to_end/scenarios/channel_messages.py @@ -29,7 +29,7 @@ scenario = ( "/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]" ], [ - "/message[@id][@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_two}/{resource_one}'][@type='groupchat']/body[text()='\ncoucou']", + "/message[@id][@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_two}/{resource_one}'][@type='groupchat']/body[text()='coucou']", "/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]" ] ), diff --git a/tests/end_to_end/scenarios/multiline_message.py b/tests/end_to_end/scenarios/multiline_message.py index c35c44b..e26bc90 100644 --- a/tests/end_to_end/scenarios/multiline_message.py +++ b/tests/end_to_end/scenarios/multiline_message.py @@ -51,6 +51,6 @@ scenario = ( expect_unordered( ["/message[@from='#foo%{irc_server_one}/{nick_one}'][@id='the-message-id'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='a\nb\nc']"], - ["/message[@from='#foo%{irc_server_one}/{nick_one}'][@id][@to='{jid_two}/{resource_one}'][@type='groupchat']/body[text()='\na\nb\nc']"], + ["/message[@from='#foo%{irc_server_one}/{nick_one}'][@id][@to='{jid_two}/{resource_one}'][@type='groupchat']/body[text()='a\nb\nc']"], ) ) diff --git a/tests/end_to_end/scenarios/slash_me_channel_message.py b/tests/end_to_end/scenarios/slash_me_channel_message.py index 28d1289..d30fba3 100644 --- a/tests/end_to_end/scenarios/slash_me_channel_message.py +++ b/tests/end_to_end/scenarios/slash_me_channel_message.py @@ -11,7 +11,7 @@ scenario = ( "/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]" ], [ - "/message[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_two}/{resource_one}'][@type='groupchat']/body[text()='\n/me rit en IRC']", + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_two}/{resource_one}'][@type='groupchat']/body[text()='/me rit en IRC']", "/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]" ], ), diff --git a/tests/end_to_end/sequences.py b/tests/end_to_end/sequences.py index 647c787..e4117f6 100644 --- a/tests/end_to_end/sequences.py +++ b/tests/end_to_end/sequences.py @@ -23,14 +23,14 @@ def connection_begin(irc_host, jid, expected_irc_presence=False, fixed_irc_serve expect_stanza(xpath % ('Connecting to %s:6667 (not encrypted)' % irc_host)), expect_stanza(xpath % 'Connected to IRC server.')) - if expected_irc_presence: - result += (expect_stanza("/presence[@from='" + irc_host + "@biboumi.localhost']"),) - result += ( expect_stanza("/message/body[text()='irc.localhost: *** Looking up your hostname...']"), expect_stanza("/message/body[text()='irc.localhost: *** Found your hostname']") ) + if expected_irc_presence: + result += (expect_stanza("/presence[@from='" + irc_host + "@biboumi.localhost']"),) + if login is not None: result += (expect_stanza("/message/body[text()='irc.localhost: You are now logged in as %s']" % (login,)),)