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
4de9816f
Commit
4de9816f
authored
Jul 13, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure emojis are initialized before parsing a message
for emoji related data
parent
3519bfe7
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
21 deletions
+31
-21
spec/chatbox.js
spec/chatbox.js
+1
-1
spec/controlbox.js
spec/controlbox.js
+8
-8
spec/mam.js
spec/mam.js
+1
-1
spec/muc_messages.js
spec/muc_messages.js
+3
-2
spec/omemo.js
spec/omemo.js
+1
-1
src/headless/converse-chat.js
src/headless/converse-chat.js
+7
-1
src/headless/converse-muc.js
src/headless/converse-muc.js
+6
-5
src/headless/utils/stanza.js
src/headless/utils/stanza.js
+4
-2
No files found.
spec/chatbox.js
View file @
4de9816f
/*global mock */
/*global mock
, converse
*/
const
_
=
converse
.
env
.
_
;
const
_
=
converse
.
env
.
_
;
const
$msg
=
converse
.
env
.
$msg
;
const
$msg
=
converse
.
env
.
$msg
;
...
...
spec/controlbox.js
View file @
4de9816f
/*global mock */
/*global mock
, converse
*/
const
_
=
converse
.
env
.
_
,
const
_
=
converse
.
env
.
_
;
$msg
=
converse
.
env
.
$msg
,
const
$msg
=
converse
.
env
.
$msg
;
u
=
converse
.
env
.
utils
,
const
u
=
converse
.
env
.
utils
;
Strophe
=
converse
.
env
.
Strophe
,
const
Strophe
=
converse
.
env
.
Strophe
;
sizzle
=
converse
.
env
.
sizzle
;
const
sizzle
=
converse
.
env
.
sizzle
;
describe
(
"
The Controlbox
"
,
function
()
{
describe
(
"
The Controlbox
"
,
function
()
{
...
@@ -90,7 +90,7 @@ describe("The Controlbox", function () {
...
@@ -90,7 +90,7 @@ describe("The Controlbox", function () {
_converse
.
handleMessageStanza
(
msg
);
_converse
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
"
.msgs-indicator
"
).
length
);
await
u
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
"
.msgs-indicator
"
).
length
);
spyOn
(
chatview
.
model
,
'
incrementUnreadMsgCounter
'
).
and
.
callThrough
();
spyOn
(
chatview
.
model
,
'
incrementUnreadMsgCounter
'
).
and
.
callThrough
();
expect
(
_converse
.
chatboxviews
.
el
.
querySelector
(
'
.restore-chat .message-count
'
).
textContent
).
toBe
(
'
1
'
);
await
u
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
el
.
querySelector
(
'
.restore-chat .message-count
'
)?.
textContent
===
'
1
'
);
expect
(
_converse
.
rosterview
.
el
.
querySelector
(
'
.msgs-indicator
'
).
textContent
).
toBe
(
'
1
'
);
expect
(
_converse
.
rosterview
.
el
.
querySelector
(
'
.msgs-indicator
'
).
textContent
).
toBe
(
'
1
'
);
msg
=
$msg
({
msg
=
$msg
({
...
@@ -102,7 +102,7 @@ describe("The Controlbox", function () {
...
@@ -102,7 +102,7 @@ describe("The Controlbox", function () {
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
_converse
.
handleMessageStanza
(
msg
);
_converse
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
chatview
.
model
.
incrementUnreadMsgCounter
.
calls
.
count
());
await
u
.
waitUntil
(()
=>
chatview
.
model
.
incrementUnreadMsgCounter
.
calls
.
count
());
expect
(
_converse
.
chatboxviews
.
el
.
querySelector
(
'
.restore-chat .message-count
'
).
textContent
).
toBe
(
'
2
'
);
await
u
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
el
.
querySelector
(
'
.restore-chat .message-count
'
)?.
textContent
===
'
2
'
);
expect
(
_converse
.
rosterview
.
el
.
querySelector
(
'
.msgs-indicator
'
).
textContent
).
toBe
(
'
2
'
);
expect
(
_converse
.
rosterview
.
el
.
querySelector
(
'
.msgs-indicator
'
).
textContent
).
toBe
(
'
2
'
);
chatview
.
model
.
set
({
'
minimized
'
:
false
});
chatview
.
model
.
set
({
'
minimized
'
:
false
});
expect
(
_converse
.
chatboxviews
.
el
.
querySelector
(
'
.restore-chat .message-count
'
)).
toBe
(
null
);
expect
(
_converse
.
chatboxviews
.
el
.
querySelector
(
'
.restore-chat .message-count
'
)).
toBe
(
null
);
...
...
spec/mam.js
View file @
4de9816f
/*global mock */
/*global mock
, converse
*/
const
Model
=
converse
.
env
.
Model
;
const
Model
=
converse
.
env
.
Model
;
const
Strophe
=
converse
.
env
.
Strophe
;
const
Strophe
=
converse
.
env
.
Strophe
;
...
...
spec/muc_messages.js
View file @
4de9816f
/*global mock */
/*global mock
, converse
*/
const
{
Promise
,
Strophe
,
$msg
,
$pres
,
sizzle
,
stanza_utils
}
=
converse
.
env
;
const
{
Promise
,
Strophe
,
$msg
,
$pres
,
sizzle
,
stanza_utils
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
...
@@ -334,7 +334,7 @@ describe("A Groupchat Message", function () {
...
@@ -334,7 +334,7 @@ describe("A Groupchat Message", function () {
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
owner
'
,
'
jid
'
:
'
newguy@montague.lit/_converse.js-290929789
'
,
'
jid
'
:
'
newguy@montague.lit/_converse.js-290929789
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
}).
tree
();
}).
tree
();
...
@@ -367,6 +367,7 @@ describe("A Groupchat Message", function () {
...
@@ -367,6 +367,7 @@ describe("A Groupchat Message", function () {
const
view
=
_converse
.
api
.
chatviews
.
get
(
muc_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
muc_jid
);
spyOn
(
converse
.
env
.
log
,
'
error
'
);
spyOn
(
converse
.
env
.
log
,
'
error
'
);
await
view
.
model
.
handleMAMResult
({
'
messages
'
:
[
msg
]
});
await
view
.
model
.
handleMAMResult
({
'
messages
'
:
[
msg
]
});
await
u
.
waitUntil
(()
=>
converse
.
env
.
log
.
error
.
calls
.
count
());
expect
(
converse
.
env
.
log
.
error
).
toHaveBeenCalledWith
(
expect
(
converse
.
env
.
log
.
error
).
toHaveBeenCalledWith
(
'
Invalid Stanza: MUC messages SHOULD NOT be XEP-0280 carbon copied
'
'
Invalid Stanza: MUC messages SHOULD NOT be XEP-0280 carbon copied
'
);
);
...
...
spec/omemo.js
View file @
4de9816f
/*global mock */
/*global mock
, converse
*/
const
{
$iq
,
$pres
,
$msg
,
_
,
Strophe
}
=
converse
.
env
;
const
{
$iq
,
$pres
,
$msg
,
_
,
Strophe
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
...
...
src/headless/converse-chat.js
View file @
4de9816f
...
@@ -437,7 +437,7 @@ converse.plugins.add('converse-chat', {
...
@@ -437,7 +437,7 @@ converse.plugins.add('converse-chat', {
* @async
* @async
* @private
* @private
* @method _converse.ChatRoom#queueMessage
* @method _converse.ChatRoom#queueMessage
* @param {
XMLElement } stanza - The message stanza.
* @param {
Promise<MessageAttributes> } attrs - A promise which resolves to the message attributes
*/
*/
queueMessage
(
attrs
)
{
queueMessage
(
attrs
)
{
this
.
msg_chain
=
(
this
.
msg_chain
||
this
.
messages
.
fetched
);
this
.
msg_chain
=
(
this
.
msg_chain
||
this
.
messages
.
fetched
);
...
@@ -445,6 +445,12 @@ converse.plugins.add('converse-chat', {
...
@@ -445,6 +445,12 @@ converse.plugins.add('converse-chat', {
return
this
.
msg_chain
;
return
this
.
msg_chain
;
},
},
/**
* @async
* @private
* @method _converse.ChatRoom#onMessage
* @param { MessageAttributes } attrs_promse - A promise which resolves to the message attributes.
*/
async
onMessage
(
attrs
)
{
async
onMessage
(
attrs
)
{
attrs
=
await
attrs
;
attrs
=
await
attrs
;
if
(
u
.
isErrorObject
(
attrs
))
{
if
(
u
.
isErrorObject
(
attrs
))
{
...
...
src/headless/converse-muc.js
View file @
4de9816f
...
@@ -1911,15 +1911,15 @@ converse.plugins.add('converse-muc', {
...
@@ -1911,15 +1911,15 @@ converse.plugins.add('converse-muc', {
* @async
* @async
* @private
* @private
* @method _converse.ChatRoom#queueMessage
* @method _converse.ChatRoom#queueMessage
* @param {
XMLElement } stanza - The message stanza.
* @param {
Promise<MessageAttributes> } attrs - A promise which resolves to the message attributes
*/
*/
queueMessage
(
stanza
)
{
queueMessage
(
attrs
)
{
if
(
this
.
messages
?.
fetched
)
{
if
(
this
.
messages
?.
fetched
)
{
this
.
msg_chain
=
(
this
.
msg_chain
||
this
.
messages
.
fetched
);
this
.
msg_chain
=
(
this
.
msg_chain
||
this
.
messages
.
fetched
);
this
.
msg_chain
=
this
.
msg_chain
.
then
(()
=>
this
.
onMessage
(
stanza
));
this
.
msg_chain
=
this
.
msg_chain
.
then
(()
=>
this
.
onMessage
(
attrs
));
return
this
.
msg_chain
;
return
this
.
msg_chain
;
}
else
{
}
else
{
this
.
message_queue
.
push
(
stanza
);
this
.
message_queue
.
push
(
attrs
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
},
},
...
@@ -1983,9 +1983,10 @@ converse.plugins.add('converse-muc', {
...
@@ -1983,9 +1983,10 @@ converse.plugins.add('converse-muc', {
* should be called.
* should be called.
* @private
* @private
* @method _converse.ChatRoom#onMessage
* @method _converse.ChatRoom#onMessage
* @param { MessageAttributes } attrs -
The message attributes
* @param { MessageAttributes } attrs -
A promise which resolves to the message attributes.
*/
*/
async
onMessage
(
attrs
)
{
async
onMessage
(
attrs
)
{
attrs
=
await
attrs
;
if
(
u
.
isErrorObject
(
attrs
))
{
if
(
u
.
isErrorObject
(
attrs
))
{
attrs
.
stanza
&&
log
.
error
(
attrs
.
stanza
);
attrs
.
stanza
&&
log
.
error
(
attrs
.
stanza
);
return
log
.
error
(
attrs
.
message
);
return
log
.
error
(
attrs
.
message
);
...
...
src/headless/utils/stanza.js
View file @
4de9816f
...
@@ -523,6 +523,7 @@ const st = {
...
@@ -523,6 +523,7 @@ const st = {
return
new
StanzaParseError
(
`Invalid Stanza: Forged MAM message from
${
from
}
`
,
stanza
);
return
new
StanzaParseError
(
`Invalid Stanza: Forged MAM message from
${
from
}
`
,
stanza
);
}
}
}
}
await
api
.
emojis
.
initialize
();
attrs
=
Object
.
assign
({
attrs
=
Object
.
assign
({
'
message
'
:
attrs
.
body
||
attrs
.
error
,
// TODO: Remove and use body and error attributes instead
'
message
'
:
attrs
.
body
||
attrs
.
error
,
// TODO: Remove and use body and error attributes instead
'
is_only_emojis
'
:
attrs
.
body
?
u
.
isOnlyEmojis
(
attrs
.
body
)
:
false
,
'
is_only_emojis
'
:
attrs
.
body
?
u
.
isOnlyEmojis
(
attrs
.
body
)
:
false
,
...
@@ -543,9 +544,9 @@ const st = {
...
@@ -543,9 +544,9 @@ const st = {
* message stanza, if it was contained, otherwise it's the message stanza itself.
* message stanza, if it was contained, otherwise it's the message stanza itself.
* @param { _converse.ChatRoom } chatbox
* @param { _converse.ChatRoom } chatbox
* @param { _converse } _converse
* @param { _converse } _converse
* @returns {
(MUCMessageAttributes|Error)
}
* @returns {
Promise<MUCMessageAttributes|Error>
}
*/
*/
parseMUCMessage
(
stanza
,
chatbox
,
_converse
)
{
async
parseMUCMessage
(
stanza
,
chatbox
,
_converse
)
{
const
err
=
rejectUnencapsulatedForward
(
stanza
);
const
err
=
rejectUnencapsulatedForward
(
stanza
);
if
(
err
)
{
if
(
err
)
{
return
err
;
return
err
;
...
@@ -650,6 +651,7 @@ const st = {
...
@@ -650,6 +651,7 @@ const st = {
getEncryptionAttributes
(
stanza
,
_converse
)
getEncryptionAttributes
(
stanza
,
_converse
)
);
);
await
api
.
emojis
.
initialize
();
attrs
=
Object
.
assign
({
attrs
=
Object
.
assign
({
'
is_only_emojis
'
:
attrs
.
body
?
u
.
isOnlyEmojis
(
attrs
.
body
)
:
false
,
'
is_only_emojis
'
:
attrs
.
body
?
u
.
isOnlyEmojis
(
attrs
.
body
)
:
false
,
'
is_receipt_request
'
:
isReceiptRequest
(
stanza
,
attrs
),
'
is_receipt_request
'
:
isReceiptRequest
(
stanza
,
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