Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
82ee7f69
Commit
82ee7f69
authored
May 28, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't ignore messages sent to different resource
But make this behavior configurable. Updates #647
parent
b82e0f31
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
17 deletions
+66
-17
docs/source/configuration.rst
docs/source/configuration.rst
+9
-0
spec/chatbox.js
spec/chatbox.js
+55
-14
src/converse-core.js
src/converse-core.js
+2
-3
No files found.
docs/source/configuration.rst
View file @
82ee7f69
...
...
@@ -414,6 +414,15 @@ these values.
*Beware*: a malicious script could use these tokens to assume your identity
and inject fake chat messages.
filter_by_resource
------------------
* Default: ``false``
Before version 1.0.3 converse.js would ignore received messages if they were
intended for a different resource then the current user had. It was decided to
drop this restriction but leave it configurable.
forward_messages
----------------
...
...
spec/chatbox.js
View file @
82ee7f69
...
...
@@ -413,6 +413,19 @@
runs
(
function
()
{});
});
describe
(
"
when received from someone else
"
,
function
()
{
it
(
"
will cause the chat area to be scrolled down only if it was at the bottom already
"
,
function
()
{
// TODO
});
});
describe
(
"
when sent by the current user
"
,
function
()
{
it
(
"
will always cause the chat area to be scrolled down
"
,
function
()
{
// TODO
});
});
it
(
"
can be received which will open a chatbox and be displayed inside it
"
,
function
()
{
spyOn
(
converse
,
'
emit
'
);
var
message
=
'
This is a received message
'
;
...
...
@@ -456,22 +469,50 @@
}.
bind
(
converse
));
}.
bind
(
converse
));
it
(
"
is ignored if it's intended for a different resource
"
,
function
()
{
it
(
"
is ignored if it's intended for a different resource
and filter_by_resource is set to true
"
,
function
()
{
// Send a message from a different resource
var
message
,
sender_jid
,
msg
;
spyOn
(
converse
,
'
log
'
);
spyOn
(
converse
.
chatboxes
,
'
getChatBox
'
);
var
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
msg
=
$msg
({
from
:
sender_jid
,
to
:
converse
.
bare_jid
+
'
/
'
+
"
some-other-resource
"
,
type
:
'
chat
'
,
id
:
(
new
Date
()).
getTime
()
}).
c
(
'
body
'
).
t
(
"
This message will not be shown
"
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
converse
.
chatboxes
.
onMessage
(
msg
);
expect
(
converse
.
log
).
toHaveBeenCalledWith
(
"
onMessage: Ignoring incoming message intended for a different resource: dummy@localhost/some-other-resource
"
,
"
info
"
);
expect
(
converse
.
chatboxes
.
getChatBox
).
not
.
toHaveBeenCalled
();
spyOn
(
converse
.
chatboxes
,
'
getChatBox
'
).
andCallThrough
();
runs
(
function
()
{
converse
.
filter_by_resource
=
true
;
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
msg
=
$msg
({
from
:
sender_jid
,
to
:
converse
.
bare_jid
+
'
/
'
+
"
some-other-resource
"
,
type
:
'
chat
'
,
id
:
(
new
Date
()).
getTime
()
}).
c
(
'
body
'
).
t
(
"
This message will not be shown
"
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
converse
.
chatboxes
.
onMessage
(
msg
);
});
waits
(
50
);
runs
(
function
()
{
expect
(
converse
.
log
).
toHaveBeenCalledWith
(
"
onMessage: Ignoring incoming message intended for a different resource: dummy@localhost/some-other-resource
"
,
"
info
"
);
expect
(
converse
.
chatboxes
.
getChatBox
).
not
.
toHaveBeenCalled
();
converse
.
filter_by_resource
=
false
;
});
waits
(
50
);
runs
(
function
()
{
message
=
"
This message sent to a different resource will be shown
"
;
msg
=
$msg
({
from
:
sender_jid
,
to
:
converse
.
bare_jid
+
'
/
'
+
"
some-other-resource
"
,
type
:
'
chat
'
,
id
:
'
134234623462346
'
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
converse
.
chatboxes
.
onMessage
(
msg
);
});
waits
(
50
);
runs
(
function
()
{
expect
(
converse
.
chatboxes
.
getChatBox
).
toHaveBeenCalled
();
var
chatboxview
=
converse
.
chatboxviews
.
get
(
sender_jid
);
var
$chat_content
=
chatboxview
.
$el
.
find
(
'
.chat-content:last
'
);
var
msg_txt
=
$chat_content
.
find
(
'
.chat-message
'
).
find
(
'
.chat-msg-content
'
).
text
();
expect
(
msg_txt
).
toEqual
(
message
);
});
});
it
(
"
is ignored if it's a malformed headline message
"
,
function
()
{
...
...
src/converse-core.js
View file @
82ee7f69
...
...
@@ -259,6 +259,7 @@
csi_waiting_time
:
0
,
// Support for XEP-0352. Seconds before client is considered idle and CSI is sent out.
debug
:
false
,
expose_rid_and_sid
:
false
,
filter_by_resource
:
false
,
forward_messages
:
false
,
hide_offline_users
:
false
,
include_offline_state
:
false
,
...
...
@@ -1261,15 +1262,13 @@
to_jid
=
$message
.
attr
(
'
to
'
),
to_resource
=
Strophe
.
getResourceFromJid
(
to_jid
);
if
(
to_resource
&&
to_resource
!==
converse
.
resource
)
{
if
(
converse
.
filter_by_resource
&&
(
to_resource
&&
to_resource
!==
converse
.
resource
)
)
{
converse
.
log
(
'
onMessage: Ignoring incoming message intended for a different resource:
'
+
to_jid
,
'
info
'
);
return
true
;
}
else
if
(
from_jid
===
converse
.
connection
.
jid
)
{
// FIXME: Forwarded messages should be sent to specific
// resources, not broadcasted
converse
.
log
(
"
onMessage: Ignoring incoming message sent from this client's JID:
"
+
from_jid
,
'
info
'
...
...
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