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
5c445a02
Commit
5c445a02
authored
Feb 24, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't show headlines from full JID if allow_non_roster_messaging is false
parent
6dfc82da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
27 deletions
+28
-27
spec/headline.js
spec/headline.js
+24
-7
src/converse-headline.js
src/converse-headline.js
+4
-20
No files found.
spec/headline.js
View file @
5c445a02
...
...
@@ -24,8 +24,6 @@
* <body>SORRY FOR THIS ADVERT</body
* </message
*/
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
sinon
.
spy
(
utils
,
'
isHeadlineMessage
'
);
runs
(
function
()
{
var
stanza
=
$msg
({
...
...
@@ -46,10 +44,8 @@
});
}));
it
(
"
will open and display headline messages
"
,
mock
.
initConverse
(
function
(
_converse
)
{
/*
* <message from='notify.example.com'
/* <message from='notify.example.com'
* to='romeo@im.example.com'
* type='headline'
* xml:lang='en'>
...
...
@@ -62,8 +58,6 @@
* </x>
* </message>
*/
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
sinon
.
spy
(
utils
,
'
isHeadlineMessage
'
);
runs
(
function
()
{
var
stanza
=
$msg
({
...
...
@@ -90,5 +84,28 @@
utils
.
isHeadlineMessage
.
restore
();
// unwraps
});
}));
it
(
"
will not show a headline messages from a full JID if allow_non_roster_messaging is false
"
,
mock
.
initConverse
(
function
(
_converse
)
{
_converse
.
allow_non_roster_messaging
=
false
;
sinon
.
spy
(
utils
,
'
isHeadlineMessage
'
);
runs
(
function
()
{
var
stanza
=
$msg
({
'
type
'
:
'
headline
'
,
'
from
'
:
'
andre5114@jabber.snc.ru/Spark
'
,
'
to
'
:
'
dummy@localhost
'
,
'
xml:lang
'
:
'
en
'
})
.
c
(
'
nick
'
).
t
(
'
gpocy
'
).
up
()
.
c
(
'
body
'
).
t
(
'
Здравствуйте друзья
'
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
});
waits
(
250
);
runs
(
function
()
{
expect
(
_
.
without
(
'
controlbox
'
,
_converse
.
chatboxviews
.
keys
()).
length
).
toBe
(
0
);
expect
(
utils
.
isHeadlineMessage
.
called
).
toBeTruthy
();
expect
(
utils
.
isHeadlineMessage
.
returned
(
true
)).
toBeTruthy
();
utils
.
isHeadlineMessage
.
restore
();
// unwraps
});
}));
});
}));
src/converse-headline.js
View file @
5c445a02
...
...
@@ -17,24 +17,6 @@
var
_
=
converse
.
env
.
_
,
utils
=
converse
.
env
.
utils
;
var
onHeadlineMessage
=
function
(
message
)
{
/* Handler method for all incoming messages of type "headline".
*/
var
from_jid
=
message
.
getAttribute
(
'
from
'
);
var
_converse
=
this
.
__super__
.
_converse
;
if
(
utils
.
isHeadlineMessage
(
message
))
{
_converse
.
chatboxes
.
create
({
'
id
'
:
from_jid
,
'
jid
'
:
from_jid
,
'
fullname
'
:
from_jid
,
'
type
'
:
'
headline
'
}).
createMessage
(
message
,
undefined
,
message
);
_converse
.
emit
(
'
message
'
,
message
);
}
return
true
;
};
converse
.
plugins
.
add
(
'
converse-headline
'
,
{
overrides
:
{
...
...
@@ -107,10 +89,12 @@
});
var
onHeadlineMessage
=
function
(
message
)
{
/* Handler method for all incoming messages of type "headline".
*/
/* Handler method for all incoming messages of type "headline". */
var
from_jid
=
message
.
getAttribute
(
'
from
'
);
if
(
utils
.
isHeadlineMessage
(
message
))
{
if
(
_
.
includes
(
from_jid
,
'
@
'
)
&&
!
_converse
.
allow_non_roster_messaging
)
{
return
;
}
_converse
.
chatboxes
.
create
({
'
id
'
:
from_jid
,
'
jid
'
:
from_jid
,
...
...
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