Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
louiz’
biboumi
Commits
51696c09
Commit
51696c09
authored
Apr 19, 2017
by
louiz’
Browse files
Make sure the channel is joined before trying to leave it
fix
#3243
parent
47ff1cd3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
10 deletions
+23
-10
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+6
-6
src/bridge/bridge.hpp
src/bridge/bridge.hpp
+1
-1
tests/end_to_end/__main__.py
tests/end_to_end/__main__.py
+16
-3
No files found.
src/bridge/bridge.cpp
View file @
51696c09
...
...
@@ -425,7 +425,6 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
return
;
IrcChannel
*
channel
=
irc
->
get_channel
(
iid
.
get_local
());
auto
nick
=
channel
->
get_self
()
->
nick
;
const
auto
resources
=
this
->
number_of_resources_in_chan
(
key
);
if
(
resources
==
1
)
...
...
@@ -447,9 +446,9 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
else
irc
->
send_part_command
(
iid
.
get_local
(),
status_message
);
}
else
else
if
(
channel
->
joined
)
{
this
->
send_muc_leave
(
iid
,
std
::
move
(
nick
)
,
""
,
true
,
resource
);
this
->
send_muc_leave
(
iid
,
channel
->
get_self
()
->
nick
,
""
,
true
,
resource
);
}
// Since there are no resources left in that channel, we don't
// want to receive private messages using this room's JID
...
...
@@ -457,8 +456,8 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
}
else
{
if
(
channel
)
this
->
send_muc_leave
(
iid
,
std
::
move
(
nick
)
,
if
(
channel
&&
channel
->
joined
)
this
->
send_muc_leave
(
iid
,
channel
->
get_self
()
->
nick
,
"Biboumi note: "
s
+
std
::
to_string
(
resources
-
1
)
+
" resources are still in this channel."
,
true
,
resource
);
this
->
remove_resource_from_chan
(
key
,
resource
);
...
...
@@ -876,7 +875,8 @@ void Bridge::send_presence_error(const Iid& iid, const std::string& nick,
this
->
xmpp
.
send_presence_error
(
std
::
to_string
(
iid
),
nick
,
this
->
user_jid
,
type
,
condition
,
error_code
,
text
);
}
void
Bridge
::
send_muc_leave
(
const
Iid
&
iid
,
std
::
string
&&
nick
,
const
std
::
string
&
message
,
const
bool
self
,
void
Bridge
::
send_muc_leave
(
const
Iid
&
iid
,
const
std
::
string
&
nick
,
const
std
::
string
&
message
,
const
bool
self
,
const
std
::
string
&
resource
)
{
if
(
!
resource
.
empty
())
...
...
src/bridge/bridge.hpp
View file @
51696c09
...
...
@@ -169,7 +169,7 @@ public:
/**
* Send an unavailable presence from this participant
*/
void
send_muc_leave
(
const
Iid
&
iid
,
std
::
string
&
&
nick
,
const
std
::
string
&
message
,
const
bool
self
,
const
std
::
string
&
resource
=
""
);
void
send_muc_leave
(
const
Iid
&
iid
,
const
std
::
string
&
nick
,
const
std
::
string
&
message
,
const
bool
self
,
const
std
::
string
&
resource
=
""
);
/**
* Send presences to indicate that an user old_nick (ourself if self ==
* true) changed his nick to new_nick. The user_mode is needed because
...
...
tests/end_to_end/__main__.py
View file @
51696c09
...
...
@@ -2457,11 +2457,24 @@ if __name__ == '__main__':
handshake_sequence
(),
partial
(
send_stanza
,
"<presence type='subscribe' from='{jid_one}/{resource_one}' to='{biboumi_host}' id='sub1' />"
),
partial
(
expect_stanza
,
"/presence[@to='{jid_one}'][@from='{biboumi_host}'][@type='subscribed']"
)
],
conf
=
'fixed_server'
)
],
conf
=
'fixed_server'
),
Scenario
(
"leave_unjoined_chan"
,
[
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"
),
partial
(
expect_stanza
,
"/presence"
),
partial
(
expect_stanza
,
"/message"
),
partial
(
send_stanza
,
"<presence from='{jid_two}/{resource_two}' to='#foo%{irc_server_one}/{nick_one}' />"
),
connection_begin_sequence
(
"irc.localhost"
,
'{jid_two}/{resource_two}'
),
partial
(
expect_stanza
,
"/message[@to='{jid_two}/{resource_two}'][@type='chat']/body[text()='irc.localhost: {nick_one}: Nickname is already in use.']"
),
partial
(
expect_stanza
,
"/presence[@type='error']/error[@type='cancel'][@code='409']/stanza:conflict"
),
partial
(
send_stanza
,
"<presence from='{jid_two}/{resource_two}' to='#foo%{irc_server_one}/{nick_one}' type='unavailable' />"
)
])
)
failures
=
0
scenar_list
=
sys
.
argv
[
1
:]
...
...
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