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
79bfb456
Commit
79bfb456
authored
Dec 06, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use async/await in MAM code and tests
parent
6e05f3b6
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
337 additions
and
367 deletions
+337
-367
spec/mam.js
spec/mam.js
+319
-330
src/converse-omemo.js
src/converse-omemo.js
+2
-2
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+12
-21
src/headless/converse-mam.js
src/headless/converse-mam.js
+4
-14
No files found.
spec/mam.js
View file @
79bfb456
This diff is collapsed.
Click to expand it.
src/converse-omemo.js
View file @
79bfb456
...
...
@@ -331,10 +331,10 @@ converse.plugins.add('converse-omemo', {
}
},
getMessageAttributesFromStanza
(
stanza
,
original_stanza
)
{
async
getMessageAttributesFromStanza
(
stanza
,
original_stanza
)
{
const
{
_converse
}
=
this
.
__super__
,
encrypted
=
sizzle
(
`encrypted[xmlns="
${
Strophe
.
NS
.
OMEMO
}
"]`
,
original_stanza
).
pop
(),
attrs
=
this
.
__super__
.
getMessageAttributesFromStanza
.
apply
(
this
,
arguments
);
attrs
=
await
this
.
__super__
.
getMessageAttributesFromStanza
.
apply
(
this
,
arguments
);
if
(
!
encrypted
||
!
_converse
.
config
.
get
(
'
trusted
'
))
{
return
attrs
;
...
...
src/headless/converse-chatboxes.js
View file @
79bfb456
...
...
@@ -557,31 +557,22 @@ converse.plugins.add('converse-chatboxes', {
return
attrs
;
},
createMessage
(
message
,
original_stanza
)
{
async
createMessage
(
message
,
original_stanza
)
{
/* Create a Backbone.Message object inside this chat box
* based on the identified message stanza.
*/
const
that
=
this
;
function
_create
(
attrs
)
{
const
is_csn
=
u
.
isOnlyChatStateNotification
(
attrs
);
if
(
is_csn
&&
(
attrs
.
is_delayed
||
(
attrs
.
type
===
'
groupchat
'
&&
Strophe
.
getResourceFromJid
(
attrs
.
from
)
==
that
.
get
(
'
nick
'
))))
{
// XXX: MUC leakage
// No need showing delayed or our own CSN messages
return
;
}
else
if
(
!
is_csn
&&
!
attrs
.
file
&&
!
attrs
.
plaintext
&&
!
attrs
.
message
&&
!
attrs
.
oob_url
&&
attrs
.
type
!==
'
error
'
)
{
// TODO: handle <subject> messages (currently being done by ChatRoom)
return
;
}
else
{
return
that
.
messages
.
create
(
attrs
);
}
}
const
result
=
this
.
getMessageAttributesFromStanza
(
message
,
original_stanza
)
if
(
typeof
result
.
then
===
"
function
"
)
{
return
new
Promise
((
resolve
,
reject
)
=>
result
.
then
(
attrs
=>
resolve
(
_create
(
attrs
))));
const
attrs
=
await
this
.
getMessageAttributesFromStanza
(
message
,
original_stanza
),
is_csn
=
u
.
isOnlyChatStateNotification
(
attrs
);
if
(
is_csn
&&
(
attrs
.
is_delayed
||
(
attrs
.
type
===
'
groupchat
'
&&
Strophe
.
getResourceFromJid
(
attrs
.
from
)
==
this
.
get
(
'
nick
'
))))
{
// XXX: MUC leakage
// No need showing delayed or our own CSN messages
return
;
}
else
if
(
!
is_csn
&&
!
attrs
.
file
&&
!
attrs
.
plaintext
&&
!
attrs
.
message
&&
!
attrs
.
oob_url
&&
attrs
.
type
!==
'
error
'
)
{
// TODO: handle <subject> messages (currently being done by ChatRoom)
return
;
}
else
{
const
message
=
_create
(
result
)
return
Promise
.
resolve
(
message
);
return
this
.
messages
.
create
(
attrs
);
}
},
...
...
src/headless/converse-mam.js
View file @
79bfb456
...
...
@@ -133,20 +133,10 @@ converse.plugins.add('converse-mam', {
// New functions which don't exist yet can also be added.
ChatBox
:
{
getMessageAttributesFromStanza
(
message
,
original_stanza
)
{
function
_process
(
attrs
)
{
const
archive_id
=
getMessageArchiveID
(
original_stanza
);
if
(
archive_id
)
{
attrs
.
archive_id
=
archive_id
;
}
return
attrs
;
}
const
result
=
this
.
__super__
.
getMessageAttributesFromStanza
.
apply
(
this
,
arguments
)
if
(
result
instanceof
Promise
)
{
return
new
Promise
((
resolve
,
reject
)
=>
result
.
then
((
attrs
)
=>
resolve
(
_process
(
attrs
))).
catch
(
reject
));
}
else
{
return
_process
(
result
);
}
async
getMessageAttributesFromStanza
(
message
,
original_stanza
)
{
const
attrs
=
await
this
.
__super__
.
getMessageAttributesFromStanza
.
apply
(
this
,
arguments
);
attrs
.
archive_id
=
getMessageArchiveID
(
original_stanza
);
return
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