@@ -507,22 +507,24 @@ void BiboumiComponent::handle_iq(const Stanza& stanza)
|
||||
|
||||
Bridge* BiboumiComponent::get_user_bridge(const std::string& user_jid)
|
||||
{
|
||||
auto bare_jid = Jid{user_jid}.bare();
|
||||
try
|
||||
{
|
||||
return this->bridges.at(user_jid).get();
|
||||
return this->bridges.at(bare_jid).get();
|
||||
}
|
||||
catch (const std::out_of_range& exception)
|
||||
{
|
||||
this->bridges.emplace(user_jid, std::make_unique<Bridge>(user_jid, *this, this->poller));
|
||||
return this->bridges.at(user_jid).get();
|
||||
this->bridges.emplace(bare_jid, std::make_unique<Bridge>(bare_jid, *this, this->poller));
|
||||
return this->bridges.at(bare_jid).get();
|
||||
}
|
||||
}
|
||||
|
||||
Bridge* BiboumiComponent::find_user_bridge(const std::string& user_jid)
|
||||
{
|
||||
auto bare_jid = Jid{user_jid}.bare();
|
||||
try
|
||||
{
|
||||
return this->bridges.at(user_jid).get();
|
||||
return this->bridges.at(bare_jid).get();
|
||||
}
|
||||
catch (const std::out_of_range& exception)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
private:
|
||||
/**
|
||||
* Return the bridge associated with the given full JID. Create a new one
|
||||
* Return the bridge associated with the bare JID. Create a new one
|
||||
* if none already exist.
|
||||
*/
|
||||
Bridge* get_user_bridge(const std::string& user_jid);
|
||||
|
||||
@@ -296,6 +296,7 @@ common_replacements = {
|
||||
'irc_host_one': 'irc.localhost',
|
||||
'biboumi_host': 'biboumi.localhost',
|
||||
'resource_one': 'resource1',
|
||||
'resource_two': 'resource2',
|
||||
'nick_one': 'Nick',
|
||||
'jid_one': 'first@example.com',
|
||||
'jid_two': 'second@example.com',
|
||||
@@ -579,6 +580,31 @@ if __name__ == '__main__':
|
||||
partial(send_stanza, "<iq type='set' id='hello-command2' from='{jid_one}/{resource_one}' to='{biboumi_host}'><command xmlns='http://jabber.org/protocol/commands' node='hello' sessionid='{sessionid}' action='next'><x xmlns='jabber:x:data' type='submit'><field var='name'><value>COUCOU</value></field></x></command></iq>"),
|
||||
partial(expect_stanza, "/iq[@type='result']/commands:command[@node='hello'][@status='completed']/commands:note[@type='info'][text()='Hello COUCOU!']")
|
||||
]),
|
||||
Scenario("simple_multisessionnick",
|
||||
[
|
||||
handshake_sequence(),
|
||||
partial(send_stanza,
|
||||
"<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/{nick_one}' />"),
|
||||
connection_sequence("irc.localhost", '{jid_one}/{resource_one}'),
|
||||
partial(expect_stanza,
|
||||
"/message/body[text()='Mode #foo [+nt] by {irc_host_one}']"),
|
||||
partial(expect_stanza,
|
||||
("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']",
|
||||
"/presence/muc_user:x/muc_user:status[@code='110']")
|
||||
),
|
||||
partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"),
|
||||
|
||||
# The other resources joins the same room, with the same nick
|
||||
partial(send_stanza,
|
||||
"<presence from='{jid_one}/{resource_two}' to='#foo%{irc_server_one}/{nick_one}' />"),
|
||||
# We receive our own join
|
||||
partial(expect_stanza,
|
||||
("/presence[@to='{jid_one}/{resource_two}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']",
|
||||
"/presence/muc_user:x/muc_user:status[@code='110']")
|
||||
),
|
||||
partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"),
|
||||
]),
|
||||
|
||||
)
|
||||
|
||||
failures = 0
|
||||
|
||||
Reference in New Issue
Block a user