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
4a5603ab
Commit
4a5603ab
authored
Feb 13, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More specific selector for markers and another test
Updates #1442
parent
dbcf6002
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
37 deletions
+114
-37
dist/converse.js
dist/converse.js
+25
-21
spec/messages.js
spec/messages.js
+68
-1
src/headless/converse-muc.js
src/headless/converse-muc.js
+21
-15
No files found.
dist/converse.js
View file @
4a5603ab
...
@@ -66988,11 +66988,32 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
...
@@ -66988,11 +66988,32 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
},
},
isReceipt(stanza) {
isReceipt(stanza) {
return sizzle(`[xmlns="${Strophe.NS.RECEIPTS}"]`, stanza).length > 0;
return sizzle(`
received
[xmlns="${Strophe.NS.RECEIPTS}"]`, stanza).length > 0;
},
},
isChatMarker(stanza) {
isChatMarker(stanza) {
return sizzle(`[xmlns="${Strophe.NS.MARKERS}"]`, stanza).length > 0;
return sizzle(`received[xmlns="${Strophe.NS.MARKERS}"],
displayed[xmlns="${Strophe.NS.MARKERS}"],
acknowledged[xmlns="${Strophe.NS.MARKERS}"]`, stanza).length > 0;
},
subjectChangeHandled(attrs) {
if (attrs.subject && !attrs.thread && !attrs.message) {
// https://xmpp.org/extensions/xep-0045.html#subject-mod
// -----------------------------------------------------
// The subject is changed by sending a message of type "groupchat" to the <room@service>,
// where the <message/> MUST contain a <subject/> element that specifies the new subject but
// MUST NOT contain a <body/> element (or a <thread/> element).
_utils_form__WEBPACK_IMPORTED_MODULE_7__["default"].safeSave(this, {
'subject': {
'author': attrs.nick,
'text': attrs.subject || ''
}
});
return true;
}
return false;
},
},
async onMessage(stanza) {
async onMessage(stanza) {
...
@@ -67019,22 +67040,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
...
@@ -67019,22 +67040,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
return;
return;
}
}
if (!this.handleMessageCorrection(stanza) && !this.isReceipt(stanza) && !this.isChatMarker(stanza)) {
if (!this.handleMessageCorrection(stanza) && !this.isReceipt(stanza) && !this.isChatMarker(stanza) && !this.subjectChangeHandled(attrs)) {
if (attrs.subject && !attrs.thread && !attrs.message) {
// https://xmpp.org/extensions/xep-0045.html#subject-mod
// -----------------------------------------------------
// The subject is changed by sending a message of type "groupchat" to the <room@service>,
// where the <message/> MUST contain a <subject/> element that specifies the new subject but
// MUST NOT contain a <body/> element (or a <thread/> element).
_utils_form__WEBPACK_IMPORTED_MODULE_7__["default"].safeSave(this, {
'subject': {
'author': attrs.nick,
'text': attrs.subject || ''
}
});
return;
}
const is_csn = _utils_form__WEBPACK_IMPORTED_MODULE_7__["default"].isOnlyChatStateNotification(attrs),
const is_csn = _utils_form__WEBPACK_IMPORTED_MODULE_7__["default"].isOnlyChatStateNotification(attrs),
own_message = Strophe.getResourceFromJid(attrs.from) == this.get('nick');
own_message = Strophe.getResourceFromJid(attrs.from) == this.get('nick');
...
@@ -67043,15 +67049,13 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
...
@@ -67043,15 +67049,13 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
return;
return;
}
}
const msg = await this.
messages.create(attrs
);
const msg = await this.
createMessage(stanza, original_stanza
);
if (forwarded && msg && msg.get('sender') === 'me') {
if (forwarded && msg && msg.get('sender') === 'me') {
msg.save({
msg.save({
'received': moment().format()
'received': moment().format()
});
});
}
}
this.incrementUnreadMsgCounter(msg);
}
}
if (attrs.nick !== this.get('nick')) {
if (attrs.nick !== this.get('nick')) {
spec/messages.js
View file @
4a5603ab
...
@@ -2347,7 +2347,7 @@
...
@@ -2347,7 +2347,7 @@
done
();
done
();
}));
}));
it
(
"
can cause a delivery receipt
"
,
it
(
"
can cause a delivery receipt
to be returned
"
,
mock
.
initConverse
(
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
...
@@ -2381,6 +2381,73 @@
...
@@ -2381,6 +2381,73 @@
done
();
done
();
}));
}));
it
(
"
can cause a chat marker to be returned
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
textarea
.
value
=
'
But soft, what light through yonder airlock breaks?
'
;
view
.
keyPressed
({
target
:
textarea
,
preventDefault
:
_
.
noop
,
keyCode
:
13
// Enter
});
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
const
msg_obj
=
view
.
model
.
messages
.
at
(
0
);
let
stanza
=
u
.
toStanza
(
`
<message xml:lang="en" to="dummy@localhost/resource"
from="lounge@localhost/some1" type="groupchat" xmlns="jabber:client">
<received xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
</message>`
);
spyOn
(
_converse
,
'
emit
'
).
and
.
callThrough
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
emit
.
calls
.
count
()
===
1
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
stanza
=
u
.
toStanza
(
`
<message xml:lang="en" to="dummy@localhost/resource"
from="lounge@localhost/some1" type="groupchat" xmlns="jabber:client">
<displayed xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
emit
.
calls
.
count
()
===
2
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
stanza
=
u
.
toStanza
(
`
<message xml:lang="en" to="dummy@localhost/resource"
from="lounge@localhost/some1" type="groupchat" xmlns="jabber:client">
<acknowledged xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
emit
.
calls
.
count
()
===
3
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
stanza
=
u
.
toStanza
(
`
<message xml:lang="en" to="dummy@localhost/resource"
from="lounge@localhost/some1" type="groupchat" xmlns="jabber:client">
<body>'tis I!</body>
<markable xmlns="urn:xmpp:chat-markers:0"/>
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
emit
.
calls
.
count
()
===
5
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
2
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
done
();
}));
describe
(
"
when received
"
,
function
()
{
describe
(
"
when received
"
,
function
()
{
it
(
"
highlights all users mentioned via XEP-0372 references
"
,
it
(
"
highlights all users mentioned via XEP-0372 references
"
,
...
...
src/headless/converse-muc.js
View file @
4a5603ab
...
@@ -979,11 +979,27 @@ converse.plugins.add('converse-muc', {
...
@@ -979,11 +979,27 @@ converse.plugins.add('converse-muc', {
},
},
isReceipt
(
stanza
)
{
isReceipt
(
stanza
)
{
return
sizzle
(
`[xmlns="
${
Strophe
.
NS
.
RECEIPTS
}
"]`
,
stanza
).
length
>
0
;
return
sizzle
(
`
received
[xmlns="
${
Strophe
.
NS
.
RECEIPTS
}
"]`
,
stanza
).
length
>
0
;
},
},
isChatMarker
(
stanza
)
{
isChatMarker
(
stanza
)
{
return
sizzle
(
`[xmlns="
${
Strophe
.
NS
.
MARKERS
}
"]`
,
stanza
).
length
>
0
;
return
sizzle
(
`received[xmlns="
${
Strophe
.
NS
.
MARKERS
}
"],
displayed[xmlns="
${
Strophe
.
NS
.
MARKERS
}
"],
acknowledged[xmlns="
${
Strophe
.
NS
.
MARKERS
}
"]`
,
stanza
).
length
>
0
;
},
subjectChangeHandled
(
attrs
)
{
if
(
attrs
.
subject
&&
!
attrs
.
thread
&&
!
attrs
.
message
)
{
// https://xmpp.org/extensions/xep-0045.html#subject-mod
// -----------------------------------------------------
// The subject is changed by sending a message of type "groupchat" to the <room@service>,
// where the <message/> MUST contain a <subject/> element that specifies the new subject but
// MUST NOT contain a <body/> element (or a <thread/> element).
u
.
safeSave
(
this
,
{
'
subject
'
:
{
'
author
'
:
attrs
.
nick
,
'
text
'
:
attrs
.
subject
||
''
}});
return
true
;
}
return
false
;
},
},
async
onMessage
(
stanza
)
{
async
onMessage
(
stanza
)
{
...
@@ -1008,17 +1024,8 @@ converse.plugins.add('converse-muc', {
...
@@ -1008,17 +1024,8 @@ converse.plugins.add('converse-muc', {
}
}
if
(
!
this
.
handleMessageCorrection
(
stanza
)
&&
if
(
!
this
.
handleMessageCorrection
(
stanza
)
&&
!
this
.
isReceipt
(
stanza
)
&&
!
this
.
isReceipt
(
stanza
)
&&
!
this
.
isChatMarker
(
stanza
))
{
!
this
.
isChatMarker
(
stanza
)
&&
!
this
.
subjectChangeHandled
(
attrs
))
{
if
(
attrs
.
subject
&&
!
attrs
.
thread
&&
!
attrs
.
message
)
{
// https://xmpp.org/extensions/xep-0045.html#subject-mod
// -----------------------------------------------------
// The subject is changed by sending a message of type "groupchat" to the <room@service>,
// where the <message/> MUST contain a <subject/> element that specifies the new subject but
// MUST NOT contain a <body/> element (or a <thread/> element).
u
.
safeSave
(
this
,
{
'
subject
'
:
{
'
author
'
:
attrs
.
nick
,
'
text
'
:
attrs
.
subject
||
''
}});
return
;
}
const
is_csn
=
u
.
isOnlyChatStateNotification
(
attrs
),
const
is_csn
=
u
.
isOnlyChatStateNotification
(
attrs
),
own_message
=
Strophe
.
getResourceFromJid
(
attrs
.
from
)
==
this
.
get
(
'
nick
'
);
own_message
=
Strophe
.
getResourceFromJid
(
attrs
.
from
)
==
this
.
get
(
'
nick
'
);
...
@@ -1026,11 +1033,10 @@ converse.plugins.add('converse-muc', {
...
@@ -1026,11 +1033,10 @@ converse.plugins.add('converse-muc', {
// No need showing delayed or our own CSN messages
// No need showing delayed or our own CSN messages
return
;
return
;
}
}
const
msg
=
await
this
.
messages
.
create
(
attrs
);
const
msg
=
await
this
.
createMessage
(
stanza
,
original_stanza
);
if
(
forwarded
&&
msg
&&
msg
.
get
(
'
sender
'
)
===
'
me
'
)
{
if
(
forwarded
&&
msg
&&
msg
.
get
(
'
sender
'
)
===
'
me
'
)
{
msg
.
save
({
'
received
'
:
moment
().
format
()});
msg
.
save
({
'
received
'
:
moment
().
format
()});
}
}
this
.
incrementUnreadMsgCounter
(
msg
);
}
}
if
(
attrs
.
nick
!==
this
.
get
(
'
nick
'
))
{
if
(
attrs
.
nick
!==
this
.
get
(
'
nick
'
))
{
// We only emit an event if it's not our own message
// We only emit an event if it's not our own message
...
...
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