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
5b25d5da
Commit
5b25d5da
authored
Feb 13, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't send markers to someone not on your roster
Updates #324
parent
bce4886a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
17 deletions
+61
-17
.eslintrc.json
.eslintrc.json
+1
-1
CHANGES.md
CHANGES.md
+1
-0
dist/converse.js
dist/converse.js
+11
-8
spec/messages.js
spec/messages.js
+38
-1
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+10
-7
No files found.
.eslintrc.json
View file @
5b25d5da
...
@@ -117,7 +117,7 @@
...
@@ -117,7 +117,7 @@
"error"
,
"error"
,
"except-parens"
"except-parens"
],
],
"no-confusing-arrow"
:
"
error
"
,
"no-confusing-arrow"
:
"
off
"
,
"no-continue"
:
"off"
,
"no-continue"
:
"off"
,
"no-div-regex"
:
"error"
,
"no-div-regex"
:
"error"
,
"no-duplicate-imports"
:
"error"
,
"no-duplicate-imports"
:
"error"
,
...
...
CHANGES.md
View file @
5b25d5da
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
-
New language supported: Esperanto
-
New language supported: Esperanto
-
Accessibility: Tag the chat-content as an ARIA live region, for screen readers
-
Accessibility: Tag the chat-content as an ARIA live region, for screen readers
-
Set releases URL to new Github repo
-
Set releases URL to new Github repo
-
Rudimentary support for XEP-0333 chat markers
-
#1369 Don't wrongly interpret message with
`subject`
as a topic change.
-
#1369 Don't wrongly interpret message with
`subject`
as a topic change.
-
#1405 Status of contacts list are not displayed properly
-
#1405 Status of contacts list are not displayed properly
-
#1408 New config option
`roomconfig_whitelist`
-
#1408 New config option
`roomconfig_whitelist`
...
...
dist/converse.js
View file @
5b25d5da
...
@@ -61659,7 +61659,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
...
@@ -61659,7 +61659,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
_converse.api.send(stanza);
_converse.api.send(stanza);
},
},
handleChatMarker(stanza, from_jid, is_carbon) {
handleChatMarker(stanza, from_jid, is_carbon
, is_roster_contact
) {
const to_bare_jid = Strophe.getBareJidFromJid(stanza.getAttribute('to'));
const to_bare_jid = Strophe.getBareJidFromJid(stanza.getAttribute('to'));
if (to_bare_jid !== _converse.bare_jid) {
if (to_bare_jid !== _converse.bare_jid) {
...
@@ -61679,8 +61679,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
...
@@ -61679,8 +61679,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
} else {
} else {
const marker = markers.pop();
const marker = markers.pop();
if (marker.nodeName === 'markable' && !is_carbon) {
if (marker.nodeName === 'markable') {
if (is_roster_contact && !is_carbon) {
this.sendMarker(from_jid, stanza.getAttribute('id'), 'received');
this.sendMarker(from_jid, stanza.getAttribute('id'), 'received');
}
return false;
return false;
} else {
} else {
const msgid = marker && marker.getAttribute('id'),
const msgid = marker && marker.getAttribute('id'),
...
@@ -62221,7 +62224,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
...
@@ -62221,7 +62224,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
const from_bare_jid = Strophe.getBareJidFromJid(from_jid),
const from_bare_jid = Strophe.getBareJidFromJid(from_jid),
from_resource = Strophe.getResourceFromJid(from_jid),
from_resource = Strophe.getResourceFromJid(from_jid),
is_me = from_bare_jid === _converse.bare_jid;
is_me = from_bare_jid === _converse.bare_jid;
let contact_jid;
let contact_jid,
is_roster_contact = false;
if (is_me) {
if (is_me) {
// I am the sender, so this must be a forwarded message...
// I am the sender, so this must be a forwarded message...
...
@@ -62233,10 +62237,9 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
...
@@ -62233,10 +62237,9 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
} else {
} else {
contact_jid = from_bare_jid;
contact_jid = from_bare_jid;
await _converse.api.waitUntil('rosterContactsFetched');
await _converse.api.waitUntil('rosterContactsFetched');
is_roster_contact = !_.isUndefined(_converse.roster.get(contact_jid));
const roster_item = _converse.roster.get(contact_jid);
if (!is_roster_contact && !_converse.allow_non_roster_messaging) {
if (_.isUndefined(roster_item) && !_converse.allow_non_roster_messaging) {
return;
return;
}
}
} // Get chat box, but only create when the message has something to show to the user
} // Get chat box, but only create when the message has something to show to the user
...
@@ -62248,7 +62251,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
...
@@ -62248,7 +62251,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
},
},
chatbox = this.getChatBox(contact_jid, chatbox_attrs, has_body);
chatbox = this.getChatBox(contact_jid, chatbox_attrs, has_body);
if (chatbox && !chatbox.handleMessageCorrection(stanza) && !chatbox.handleReceipt(stanza, from_jid, is_carbon, is_me) && !chatbox.handleChatMarker(stanza, from_jid, is_carbon)) {
if (chatbox && !chatbox.handleMessageCorrection(stanza) && !chatbox.handleReceipt(stanza, from_jid, is_carbon, is_me) && !chatbox.handleChatMarker(stanza, from_jid, is_carbon
, is_roster_contact
)) {
const attrs = await chatbox.getMessageAttributesFromStanza(stanza, original_stanza);
const attrs = await chatbox.getMessageAttributesFromStanza(stanza, original_stanza);
if (attrs['chat_state'] || !u.isEmptyMessage(attrs)) {
if (attrs['chat_state'] || !u.isEmptyMessage(attrs)) {
spec/messages.js
View file @
5b25d5da
...
@@ -2030,12 +2030,13 @@
...
@@ -2030,12 +2030,13 @@
describe
(
"
A XEP-0333 Chat Marker
"
,
function
()
{
describe
(
"
A XEP-0333 Chat Marker
"
,
function
()
{
it
(
"
is sent when a markable message is received
"
,
it
(
"
is sent when a markable message is received
from a roster contact
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
await
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
await
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
...
@@ -2063,6 +2064,42 @@
...
@@ -2063,6 +2064,42 @@
done
();
done
();
}));
}));
it
(
"
is not sent when a markable message is received from someone not on the roster
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
allow_non_roster_messaging
'
:
true
},
async
function
(
done
,
_converse
)
{
_converse
.
emit
(
'
rosterContactsFetched
'
);
const
contact_jid
=
'
someone@localhost
'
;
const
msgid
=
u
.
getUniqueId
();
const
stanza
=
u
.
toStanza
(
`
<message from='
${
contact_jid
}
'
id='
${
msgid
}
'
type="chat"
to='
${
_converse
.
jid
}
'>
<body>My lord, dispatch; read o'er these articles.</body>
<markable xmlns='urn:xmpp:chat-markers:0'/>
</message>`
);
const
sent_stanzas
=
[];
spyOn
(
_converse
.
connection
,
'
send
'
).
and
.
callFake
(
s
=>
sent_stanzas
.
push
(
s
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
==
2
);
const
sent_messages
=
sent_stanzas
.
map
(
s
=>
_
.
isElement
(
s
)
?
s
:
s
.
nodeTree
)
.
filter
(
e
=>
e
.
nodeName
===
'
message
'
);
// Only one message is sent out, and it's not a chat marker
expect
(
sent_messages
.
length
).
toBe
(
1
);
expect
(
Strophe
.
serialize
(
sent_messages
[
0
])).
toBe
(
`<message id="
${
sent_messages
[
0
].
getAttribute
(
'
id
'
)}
" to="someone@localhost" type="chat" xmlns="jabber:client">`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<no-store xmlns="urn:xmpp:hints"/>`
+
`<no-permanent-store xmlns="urn:xmpp:hints"/>`
+
`</message>`
);
done
();
}));
it
(
"
is ignored if it's a carbon copy of one that I sent from a different client
"
,
it
(
"
is ignored if it's a carbon copy of one that I sent from a different client
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
...
...
src/headless/converse-chatboxes.js
View file @
5b25d5da
...
@@ -324,7 +324,7 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -324,7 +324,7 @@ converse.plugins.add('converse-chatboxes', {
_converse
.
api
.
send
(
stanza
);
_converse
.
api
.
send
(
stanza
);
},
},
handleChatMarker
(
stanza
,
from_jid
,
is_carbon
)
{
handleChatMarker
(
stanza
,
from_jid
,
is_carbon
,
is_roster_contact
)
{
const
to_bare_jid
=
Strophe
.
getBareJidFromJid
(
stanza
.
getAttribute
(
'
to
'
));
const
to_bare_jid
=
Strophe
.
getBareJidFromJid
(
stanza
.
getAttribute
(
'
to
'
));
if
(
to_bare_jid
!==
_converse
.
bare_jid
)
{
if
(
to_bare_jid
!==
_converse
.
bare_jid
)
{
return
false
;
return
false
;
...
@@ -341,8 +341,10 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -341,8 +341,10 @@ converse.plugins.add('converse-chatboxes', {
return
false
;
return
false
;
}
else
{
}
else
{
const
marker
=
markers
.
pop
();
const
marker
=
markers
.
pop
();
if
(
marker
.
nodeName
===
'
markable
'
&&
!
is_carbon
)
{
if
(
marker
.
nodeName
===
'
markable
'
)
{
if
(
is_roster_contact
&&
!
is_carbon
)
{
this
.
sendMarker
(
from_jid
,
stanza
.
getAttribute
(
'
id
'
),
'
received
'
);
this
.
sendMarker
(
from_jid
,
stanza
.
getAttribute
(
'
id
'
),
'
received
'
);
}
return
false
;
return
false
;
}
else
{
}
else
{
const
msgid
=
marker
&&
marker
.
getAttribute
(
'
id
'
),
const
msgid
=
marker
&&
marker
.
getAttribute
(
'
id
'
),
...
@@ -820,7 +822,8 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -820,7 +822,8 @@ converse.plugins.add('converse-chatboxes', {
from_resource
=
Strophe
.
getResourceFromJid
(
from_jid
),
from_resource
=
Strophe
.
getResourceFromJid
(
from_jid
),
is_me
=
from_bare_jid
===
_converse
.
bare_jid
;
is_me
=
from_bare_jid
===
_converse
.
bare_jid
;
let
contact_jid
;
let
contact_jid
,
is_roster_contact
=
false
;
if
(
is_me
)
{
if
(
is_me
)
{
// I am the sender, so this must be a forwarded message...
// I am the sender, so this must be a forwarded message...
if
(
_
.
isNull
(
to_jid
))
{
if
(
_
.
isNull
(
to_jid
))
{
...
@@ -833,8 +836,8 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -833,8 +836,8 @@ converse.plugins.add('converse-chatboxes', {
}
else
{
}
else
{
contact_jid
=
from_bare_jid
;
contact_jid
=
from_bare_jid
;
await
_converse
.
api
.
waitUntil
(
'
rosterContactsFetched
'
);
await
_converse
.
api
.
waitUntil
(
'
rosterContactsFetched
'
);
const
roster_item
=
_converse
.
roster
.
get
(
contact_jid
);
is_roster_contact
=
!
_
.
isUndefined
(
_converse
.
roster
.
get
(
contact_jid
)
);
if
(
_
.
isUndefined
(
roster_item
)
&&
!
_converse
.
allow_non_roster_messaging
)
{
if
(
!
is_roster_contact
&&
!
_converse
.
allow_non_roster_messaging
)
{
return
;
return
;
}
}
}
}
...
@@ -846,7 +849,7 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -846,7 +849,7 @@ converse.plugins.add('converse-chatboxes', {
if
(
chatbox
&&
if
(
chatbox
&&
!
chatbox
.
handleMessageCorrection
(
stanza
)
&&
!
chatbox
.
handleMessageCorrection
(
stanza
)
&&
!
chatbox
.
handleReceipt
(
stanza
,
from_jid
,
is_carbon
,
is_me
)
&&
!
chatbox
.
handleReceipt
(
stanza
,
from_jid
,
is_carbon
,
is_me
)
&&
!
chatbox
.
handleChatMarker
(
stanza
,
from_jid
,
is_carbon
))
{
!
chatbox
.
handleChatMarker
(
stanza
,
from_jid
,
is_carbon
,
is_roster_contact
))
{
const
attrs
=
await
chatbox
.
getMessageAttributesFromStanza
(
stanza
,
original_stanza
);
const
attrs
=
await
chatbox
.
getMessageAttributesFromStanza
(
stanza
,
original_stanza
);
if
(
attrs
[
'
chat_state
'
]
||
!
u
.
isEmptyMessage
(
attrs
))
{
if
(
attrs
[
'
chat_state
'
]
||
!
u
.
isEmptyMessage
(
attrs
))
{
...
...
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