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
273b9584
Commit
273b9584
authored
May 03, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor onMessage to use `const` instead of `let`
parent
52ea8d5a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
90 deletions
+57
-90
dist/converse.js
dist/converse.js
+18
-28
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+21
-34
src/headless/dist/converse-headless.js
src/headless/dist/converse-headless.js
+18
-28
No files found.
dist/converse.js
View file @
273b9584
...
...
@@ -63055,17 +63055,13 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
return true;
}
let from_jid = stanza.getAttribute('from'),
is_carbon = false,
is_mam = false;
const forwarded = stanza.querySelector('forwarded'),
original_stanza = stanza;
let is_carbon = false;
const forwarded = stanza.querySelector('forwarded');
const original_stanza = stanza;
if (!_.isNull(forwarded)) {
const forwarded_message = forwarded.querySelector('message'),
forwarded_from = forwarded_message.getAttribute('from'),
xmlns = Strophe.NS.CARBONS;
is_carbon = sizzle(`received[xmlns="${xmlns}"]`, stanza).length > 0;
const xmlns = Strophe.NS.CARBONS;
is_carbon = sizzle(`received[xmlns="${xmlns}"]`, original_stanza).length > 0;
if (is_carbon && original_stanza.getAttribute('from') !== _converse.bare_jid) {
// Prevent message forging via carbons
...
...
@@ -63073,28 +63069,19 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
return true;
}
is_mam = sizzle(`message > result[xmlns="${Strophe.NS.MAM}"]`, stanza).length > 0;
stanza = forwarded_message;
from_jid = stanza.getAttribute('from');
stanza = forwarded.querySelector('message');
to_jid = stanza.getAttribute('to');
}
const from_bare_jid = Strophe.getBareJidFromJid(from_jid),
from_resource = Strophe.getResourceFromJid(from_jid),
is_me = from_bare_jid === _converse.bare_jid;
let contact_jid;
if (is_me) {
// I am the sender, so this must be a forwarded message...
if (_.isNull(to_jid)) {
return _converse.log(`Don't know how to handle message stanza without 'to' attribute. ${stanza.outerHTML}`, Strophe.LogLevel.ERROR);
}
const from_jid = stanza.getAttribute('from');
const from_bare_jid = Strophe.getBareJidFromJid(from_jid);
const is_me = from_bare_jid === _converse.bare_jid;
contact_jid = Strophe.getBareJidFromJid(to_jid);
} else {
contact_jid = from_bare_jid;
if (is_me && _.isNull(to_jid)) {
return _converse.log(`Don't know how to handle message stanza without 'to' attribute. ${stanza.outerHTML}`, Strophe.LogLevel.ERROR);
}
const contact_jid = is_me ? Strophe.getBareJidFromJid(to_jid) : from_bare_jid;
const contact = await _converse.api.contacts.get(contact_jid);
const is_roster_contact = !_.isUndefined(contact);
...
...
@@ -63103,13 +63090,16 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
} // Get chat box, but only create when the message has something to show to the user
const has_body = sizzle(`body, encrypted[xmlns="${Strophe.NS.OMEMO}"]`, stanza).length > 0,
roster_nick = _.get(contact, 'attributes.nickname'),
chatbox = this.getChatBox(contact_jid, {
const has_body = sizzle(`body, encrypted[xmlns="${Strophe.NS.OMEMO}"]`, stanza).length > 0;
const roster_nick = _.get(contact, 'attributes.nickname');
const chatbox = this.getChatBox(contact_jid, {
'nickname': roster_nick
}, has_body);
if (chatbox) {
const is_mam = sizzle(`message > result[xmlns="${Strophe.NS.MAM}"]`, original_stanza).length > 0;
const message = await chatbox.getDuplicateMessage(stanza);
if (message) {
src/headless/converse-chatboxes.js
View file @
273b9584
...
...
@@ -403,7 +403,7 @@ converse.plugins.add('converse-chatboxes', {
'
msgid
'
:
id
});
},
sendMarker
(
to_jid
,
id
,
type
)
{
const
stanza
=
$msg
({
'
from
'
:
_converse
.
connection
.
jid
,
...
...
@@ -931,47 +931,33 @@ converse.plugins.add('converse-chatboxes', {
return
true
;
}
let
from_jid
=
stanza
.
getAttribute
(
'
from
'
),
is_carbon
=
false
,
is_mam
=
false
;
const
forwarded
=
stanza
.
querySelector
(
'
forwarded
'
),
original_stanza
=
stanza
;
let
is_carbon
=
false
;
const
forwarded
=
stanza
.
querySelector
(
'
forwarded
'
);
const
original_stanza
=
stanza
;
if
(
!
_
.
isNull
(
forwarded
))
{
const
forwarded_message
=
forwarded
.
querySelector
(
'
message
'
),
forwarded_from
=
forwarded_message
.
getAttribute
(
'
from
'
),
xmlns
=
Strophe
.
NS
.
CARBONS
;
is_carbon
=
sizzle
(
`received[xmlns="
${
xmlns
}
"]`
,
stanza
).
length
>
0
;
const
xmlns
=
Strophe
.
NS
.
CARBONS
;
is_carbon
=
sizzle
(
`received[xmlns="
${
xmlns
}
"]`
,
original_stanza
).
length
>
0
;
if
(
is_carbon
&&
original_stanza
.
getAttribute
(
'
from
'
)
!==
_converse
.
bare_jid
)
{
// Prevent message forging via carbons
// https://xmpp.org/extensions/xep-0280.html#security
return
true
;
}
is_mam
=
sizzle
(
`message > result[xmlns="
${
Strophe
.
NS
.
MAM
}
"]`
,
stanza
).
length
>
0
;
stanza
=
forwarded_message
;
from_jid
=
stanza
.
getAttribute
(
'
from
'
);
stanza
=
forwarded
.
querySelector
(
'
message
'
);
to_jid
=
stanza
.
getAttribute
(
'
to
'
);
}
const
from_bare_jid
=
Strophe
.
getBareJidFromJid
(
from_jid
),
from_resource
=
Strophe
.
getResourceFromJid
(
from_jid
),
is_me
=
from_bare_jid
===
_converse
.
bare_jid
;
let
contact_jid
;
if
(
is_me
)
{
// I am the sender, so this must be a forwarded message...
if
(
_
.
isNull
(
to_jid
))
{
return
_converse
.
log
(
`Don't know how to handle message stanza without 'to' attribute.
${
stanza
.
outerHTML
}
`
,
Strophe
.
LogLevel
.
ERROR
);
}
contact_jid
=
Strophe
.
getBareJidFromJid
(
to_jid
);
}
else
{
contact_jid
=
from_bare_jid
;
}
const
from_jid
=
stanza
.
getAttribute
(
'
from
'
);
const
from_bare_jid
=
Strophe
.
getBareJidFromJid
(
from_jid
);
const
is_me
=
from_bare_jid
===
_converse
.
bare_jid
;
if
(
is_me
&&
_
.
isNull
(
to_jid
))
{
return
_converse
.
log
(
`Don't know how to handle message stanza without 'to' attribute.
${
stanza
.
outerHTML
}
`
,
Strophe
.
LogLevel
.
ERROR
);
}
const
contact_jid
=
is_me
?
Strophe
.
getBareJidFromJid
(
to_jid
)
:
from_bare_jid
;
const
contact
=
await
_converse
.
api
.
contacts
.
get
(
contact_jid
);
const
is_roster_contact
=
!
_
.
isUndefined
(
contact
);
if
(
!
is_me
&&
!
is_roster_contact
&&
!
_converse
.
allow_non_roster_messaging
)
{
...
...
@@ -979,11 +965,12 @@ converse.plugins.add('converse-chatboxes', {
}
// Get chat box, but only create when the message has something to show to the user
const
has_body
=
sizzle
(
`body, encrypted[xmlns="
${
Strophe
.
NS
.
OMEMO
}
"]`
,
stanza
).
length
>
0
,
roster_nick
=
_
.
get
(
contact
,
'
attributes.nickname
'
),
chatbox
=
this
.
getChatBox
(
contact_jid
,
{
'
nickname
'
:
roster_nick
},
has_body
);
const
has_body
=
sizzle
(
`body, encrypted[xmlns="
${
Strophe
.
NS
.
OMEMO
}
"]`
,
stanza
).
length
>
0
;
const
roster_nick
=
_
.
get
(
contact
,
'
attributes.nickname
'
);
const
chatbox
=
this
.
getChatBox
(
contact_jid
,
{
'
nickname
'
:
roster_nick
},
has_body
);
if
(
chatbox
)
{
const
is_mam
=
sizzle
(
`message > result[xmlns="
${
Strophe
.
NS
.
MAM
}
"]`
,
original_stanza
).
length
>
0
;
const
message
=
await
chatbox
.
getDuplicateMessage
(
stanza
);
if
(
message
)
{
chatbox
.
updateMessage
(
message
,
original_stanza
);
...
...
src/headless/dist/converse-headless.js
View file @
273b9584
...
...
@@ -41303,17 +41303,13 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
return true;
}
let from_jid = stanza.getAttribute('from'),
is_carbon = false,
is_mam = false;
const forwarded = stanza.querySelector('forwarded'),
original_stanza = stanza;
let is_carbon = false;
const forwarded = stanza.querySelector('forwarded');
const original_stanza = stanza;
if (!_.isNull(forwarded)) {
const forwarded_message = forwarded.querySelector('message'),
forwarded_from = forwarded_message.getAttribute('from'),
xmlns = Strophe.NS.CARBONS;
is_carbon = sizzle(`received[xmlns="${xmlns}"]`, stanza).length > 0;
const xmlns = Strophe.NS.CARBONS;
is_carbon = sizzle(`received[xmlns="${xmlns}"]`, original_stanza).length > 0;
if (is_carbon && original_stanza.getAttribute('from') !== _converse.bare_jid) {
// Prevent message forging via carbons
...
...
@@ -41321,28 +41317,19 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
return true;
}
is_mam = sizzle(`message > result[xmlns="${Strophe.NS.MAM}"]`, stanza).length > 0;
stanza = forwarded_message;
from_jid = stanza.getAttribute('from');
stanza = forwarded.querySelector('message');
to_jid = stanza.getAttribute('to');
}
const from_bare_jid = Strophe.getBareJidFromJid(from_jid),
from_resource = Strophe.getResourceFromJid(from_jid),
is_me = from_bare_jid === _converse.bare_jid;
let contact_jid;
if (is_me) {
// I am the sender, so this must be a forwarded message...
if (_.isNull(to_jid)) {
return _converse.log(`Don't know how to handle message stanza without 'to' attribute. ${stanza.outerHTML}`, Strophe.LogLevel.ERROR);
}
const from_jid = stanza.getAttribute('from');
const from_bare_jid = Strophe.getBareJidFromJid(from_jid);
const is_me = from_bare_jid === _converse.bare_jid;
contact_jid = Strophe.getBareJidFromJid(to_jid);
} else {
contact_jid = from_bare_jid;
if (is_me && _.isNull(to_jid)) {
return _converse.log(`Don't know how to handle message stanza without 'to' attribute. ${stanza.outerHTML}`, Strophe.LogLevel.ERROR);
}
const contact_jid = is_me ? Strophe.getBareJidFromJid(to_jid) : from_bare_jid;
const contact = await _converse.api.contacts.get(contact_jid);
const is_roster_contact = !_.isUndefined(contact);
...
...
@@ -41351,13 +41338,16 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
} // Get chat box, but only create when the message has something to show to the user
const has_body = sizzle(`body, encrypted[xmlns="${Strophe.NS.OMEMO}"]`, stanza).length > 0,
roster_nick = _.get(contact, 'attributes.nickname'),
chatbox = this.getChatBox(contact_jid, {
const has_body = sizzle(`body, encrypted[xmlns="${Strophe.NS.OMEMO}"]`, stanza).length > 0;
const roster_nick = _.get(contact, 'attributes.nickname');
const chatbox = this.getChatBox(contact_jid, {
'nickname': roster_nick
}, has_body);
if (chatbox) {
const is_mam = sizzle(`message > result[xmlns="${Strophe.NS.MAM}"]`, original_stanza).length > 0;
const message = await chatbox.getDuplicateMessage(stanza);
if (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