fix multiline tests
This commit is contained in:
committed by
mathieui
parent
6993577cbe
commit
f2a55c4f27
+4
-10
@@ -223,7 +223,10 @@ void Bridge::send_channel_message(const Iid& iid, const std::string& body, std::
|
|||||||
if (lines.empty())
|
if (lines.empty())
|
||||||
return ;
|
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;
|
std::string uuid;
|
||||||
const auto xmpp_body = this->make_xmpp_body(body);
|
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);
|
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<std::string> 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));
|
irc->send_batch(uuid, "draft/multiline", {iid.get_local()}, messages, std::move(mirror_to_all_resources));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1528,7 +1528,7 @@ void IrcClient::process_batch(const std::string& reference_tag)
|
|||||||
for (const IrcMessage& message: it->second.second)
|
for (const IrcMessage& message: it->second.second)
|
||||||
{
|
{
|
||||||
auto it_tags = message.tags.find("draft/multiline-concat");
|
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];
|
body += "\n" + message.arguments[1];
|
||||||
else
|
else
|
||||||
body += message.arguments[1];
|
body += message.arguments[1];
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ scenario = (
|
|||||||
"/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]"
|
"/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]"
|
"/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]"
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -51,6 +51,6 @@ scenario = (
|
|||||||
expect_unordered(
|
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='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']"],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ scenario = (
|
|||||||
"/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]"
|
"/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]"
|
"/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]"
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -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 % ('Connecting to %s:6667 (not encrypted)' % irc_host)),
|
||||||
expect_stanza(xpath % 'Connected to IRC server.'))
|
expect_stanza(xpath % 'Connected to IRC server.'))
|
||||||
|
|
||||||
if expected_irc_presence:
|
|
||||||
result += (expect_stanza("/presence[@from='" + irc_host + "@biboumi.localhost']"),)
|
|
||||||
|
|
||||||
result += (
|
result += (
|
||||||
expect_stanza("/message/body[text()='irc.localhost: *** Looking up your hostname...']"),
|
expect_stanza("/message/body[text()='irc.localhost: *** Looking up your hostname...']"),
|
||||||
expect_stanza("/message/body[text()='irc.localhost: *** Found 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:
|
if login is not None:
|
||||||
result += (expect_stanza("/message/body[text()='irc.localhost: You are now logged in as %s']" % (login,)),)
|
result += (expect_stanza("/message/body[text()='irc.localhost: You are now logged in as %s']" % (login,)),)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user