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
dc07440d
Commit
dc07440d
authored
Jan 10, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix. Don't create chats for messages without `body`
parent
1984bdd8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
2 deletions
+41
-2
CHANGES.md
CHANGES.md
+1
-0
dist/converse.js
dist/converse.js
+1
-1
spec/chatbox.js
spec/chatbox.js
+38
-0
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+1
-1
No files found.
CHANGES.md
View file @
dc07440d
...
...
@@ -4,6 +4,7 @@
-
Bugfix: MUC commands were being ignored
-
Bugfix: Multiple rooms shown active in the rooms list
-
Bugfix: Don't open chats when receiving messages without a
`body`
-
UI: Always show the OMEMO lock icon (grayed out if not available).
-
Use
`publish-options`
with
`pubsub#access_model`
set to
`open`
when publishing OMEMO public keys and devices
-
Add a new
`converse-pubsub`
plugin, for generic PubSub operations
...
...
dist/converse.js
View file @
dc07440d
...
...
@@ -62401,7 +62401,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
'fullname': _.get(_converse.api.contacts.get(contact_jid), 'attributes.fullname') // Get chat box, but only create a new one when the message has a body.
};
const has_body = sizzle(`body, encrypted[xmlns="${Strophe.NS.OMEMO}"]`).length > 0;
const has_body = sizzle(`body, encrypted[xmlns="${Strophe.NS.OMEMO}"]`
, stanza
).length > 0;
const chatbox = this.getChatBox(contact_jid, attrs, has_body);
if (chatbox && !chatbox.handleMessageCorrection(stanza) && !chatbox.handleReceipt(stanza)) {
spec/chatbox.js
View file @
dc07440d
...
...
@@ -140,6 +140,44 @@
done
();
}));
it
(
"
opens when a new message is received
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
allow_non_roster_messaging
'
:
true
},
async
function
(
done
,
_converse
)
{
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
stanza
=
Strophe
.
xmlHtmlNode
(
"
<message from='
"
+
sender_jid
+
"
'
"
+
"
type='chat'
"
+
"
to='dummy@localhost/resource'>
"
+
"
<body>Hey
\n
Have you heard the news?</body>
"
+
"
</message>
"
).
firstChild
;
const
message_promise
=
new
Promise
(
resolve
=>
_converse
.
api
.
listen
.
on
(
'
message
'
,
resolve
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
message_promise
);
expect
(
_converse
.
chatboxviews
.
keys
().
length
).
toBe
(
2
);
done
();
}));
it
(
"
doesn't open when a message without body is received
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
stanza
=
Strophe
.
xmlHtmlNode
(
`
<message from="
${
sender_jid
}
"
type="chat"
to="dummy@localhost/resource">
<composing xmlns="http://jabber.org/protocol/chatstates"/>
</message>`
).
firstChild
;
const
message_promise
=
new
Promise
(
resolve
=>
_converse
.
api
.
listen
.
on
(
'
message
'
,
resolve
))
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
message_promise
);
expect
(
_converse
.
chatboxviews
.
keys
().
length
).
toBe
(
1
);
done
();
}));
it
(
"
can be trimmed to conserve space
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
...
...
src/headless/converse-chatboxes.js
View file @
dc07440d
...
...
@@ -809,7 +809,7 @@ converse.plugins.add('converse-chatboxes', {
'
fullname
'
:
_
.
get
(
_converse
.
api
.
contacts
.
get
(
contact_jid
),
'
attributes.fullname
'
)
}
// Get chat box, but only create a new one when the message has a body.
const
has_body
=
sizzle
(
`body, encrypted[xmlns="
${
Strophe
.
NS
.
OMEMO
}
"]`
).
length
>
0
;
const
has_body
=
sizzle
(
`body, encrypted[xmlns="
${
Strophe
.
NS
.
OMEMO
}
"]`
,
stanza
).
length
>
0
;
const
chatbox
=
this
.
getChatBox
(
contact_jid
,
attrs
,
has_body
);
if
(
chatbox
&&
!
chatbox
.
handleMessageCorrection
(
stanza
)
&&
!
chatbox
.
handleReceipt
(
stanza
))
{
const
msgid
=
stanza
.
getAttribute
(
'
id
'
),
...
...
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