Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
e2fc3cf6
Commit
e2fc3cf6
authored
Mar 23, 2018
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly handle force-join presences by sending everything in return
fix
#3305
parent
cdace807
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
5 deletions
+54
-5
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+7
-3
src/bridge/bridge.hpp
src/bridge/bridge.hpp
+5
-1
src/xmpp/biboumi_component.cpp
src/xmpp/biboumi_component.cpp
+1
-1
tests/end_to_end/__main__.py
tests/end_to_end/__main__.py
+41
-0
No files found.
src/bridge/bridge.cpp
View file @
e2fc3cf6
...
...
@@ -166,8 +166,11 @@ IrcClient* Bridge::find_irc_client(const std::string& hostname) const
}
}
bool
Bridge
::
join_irc_channel
(
const
Iid
&
iid
,
std
::
string
nickname
,
const
std
::
string
&
password
,
const
std
::
string
&
resource
,
HistoryLimit
history_limit
)
bool
Bridge
::
join_irc_channel
(
const
Iid
&
iid
,
std
::
string
nickname
,
const
std
::
string
&
password
,
const
std
::
string
&
resource
,
HistoryLimit
history_limit
,
const
bool
force_join
)
{
const
auto
&
hostname
=
iid
.
get_server
();
#ifdef USE_DATABASE
...
...
@@ -185,7 +188,8 @@ bool Bridge::join_irc_channel(const Iid& iid, std::string nickname, const std::s
{
irc
->
send_join_command
(
iid
.
get_local
(),
password
);
return
true
;
}
else
if
(
!
res_in_chan
)
{
}
else
if
(
!
res_in_chan
||
force_join
)
{
// See https://github.com/xsf/xeps/pull/499 for the force_join argument
this
->
generate_channel_join_for_resource
(
iid
,
resource
);
}
return
false
;
...
...
src/bridge/bridge.hpp
View file @
e2fc3cf6
...
...
@@ -75,7 +75,11 @@ public:
* Try to join an irc_channel, does nothing and return true if the channel
* was already joined.
*/
bool
join_irc_channel
(
const
Iid
&
iid
,
std
::
string
nickname
,
const
std
::
string
&
password
,
const
std
::
string
&
resource
,
HistoryLimit
history_limit
);
bool
join_irc_channel
(
const
Iid
&
iid
,
std
::
string
nickname
,
const
std
::
string
&
password
,
const
std
::
string
&
resource
,
HistoryLimit
history_limit
,
const
bool
force_join
);
void
send_channel_message
(
const
Iid
&
iid
,
const
std
::
string
&
body
,
std
::
string
id
);
void
send_private_message
(
const
Iid
&
iid
,
const
std
::
string
&
body
,
const
std
::
string
&
type
=
"PRIVMSG"
);
...
...
src/xmpp/biboumi_component.cpp
View file @
e2fc3cf6
...
...
@@ -181,7 +181,7 @@ void BiboumiComponent::handle_presence(const Stanza& stanza)
history_limit
.
stanzas
=
0
;
}
bridge
->
join_irc_channel
(
iid
,
to
.
resource
,
password
?
password
->
get_inner
()
:
""
,
from
.
resource
,
history_limit
);
from
.
resource
,
history_limit
,
x
!=
nullptr
);
}
else
if
(
type
==
"unavailable"
)
{
...
...
tests/end_to_end/__main__.py
View file @
e2fc3cf6
...
...
@@ -706,6 +706,47 @@ if __name__ == '__main__':
(
"/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"
,),
]),
]),
Scenario
(
"channel_force_join"
,
[
handshake_sequence
(),
# First user joins
partial
(
send_stanza
,
"<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/{nick_one}'><x xmlns='http://jabber.org/protocol/muc'/></presence>"
),
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'][@jid='~nick@localhost'][@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())]"
),
# Second user joins
partial
(
send_stanza
,
"<presence from='{jid_two}/{resource_one}' to='#foo%{irc_server_one}/{nick_two}'><x xmlns='http://jabber.org/protocol/muc'/></presence>"
),
connection_sequence
(
"irc.localhost"
,
'{jid_two}/{resource_one}'
),
partial
(
expect_unordered
,
[
(
"/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='none'][@role='participant'][@jid='~bobby@localhost']"
,),
(
"/presence[@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']"
,),
(
"/presence[@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='none'][@jid='~bobby@localhost'][@role='participant']"
,
"/presence/muc_user:x/muc_user:status[@code='110']"
,),
(
"/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"
,),
]),
# Here we simulate a desynchronization of a client: The client thinks it’s
# disconnected from the room, but biboumi still thinks it’s in the room. The
# client thus sends a join presence, and biboumi should send everything
# (user list, history, etc) in response
partial
(
send_stanza
,
"<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/{nick_one}'><x xmlns='http://jabber.org/protocol/muc'/></presence>"
),
partial
(
expect_unordered
,
[
(
"/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='none'][@role='participant'][@jid='~bobby@localhost']"
,),
(
"/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']"
,),
(
"/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"
,),
]),
]),
Scenario
(
"channel_join_with_password"
,
[
handshake_sequence
(),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment