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
216a6849
Commit
216a6849
authored
Dec 12, 2018
by
Christoph Scholz
Committed by
JC Brand
Dec 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent message delivery receipts for carbons and own
parent
6ec18345
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
15 deletions
+77
-15
CHANGES.md
CHANGES.md
+1
-0
dist/converse.js
dist/converse.js
+8
-7
spec/messages.js
spec/messages.js
+59
-0
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+9
-8
No files found.
CHANGES.md
View file @
216a6849
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
-
Bugfix: MUC commands were being ignored
-
Bugfix: MUC commands were being ignored
-
UI: Always show the OMEMO lock icon (grayed out if not available).
-
UI: Always show the OMEMO lock icon (grayed out if not available).
-
#1374 Can't load embedded chat when changing
`view_mode`
between page reloads
-
#1374 Can't load embedded chat when changing
`view_mode`
between page reloads
-
Bugfix: Message Delivery Receipts were being sent for carbons and own messages
## 4.0.6 (2018-12-07)
## 4.0.6 (2018-12-07)
...
...
dist/converse.js
View file @
216a6849
...
@@ -62207,14 +62207,15 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
...
@@ -62207,14 +62207,15 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
return true;
return true;
}
}
let from_jid = stanza.getAttribute('from');
let from_jid = stanza.getAttribute('from'),
is_carbon = false;
const forwarded = stanza.querySelector('forwarded'),
const forwarded = stanza.querySelector('forwarded'),
original_stanza = stanza;
original_stanza = stanza;
if (!_.isNull(forwarded)) {
if (!_.isNull(forwarded)) {
const forwarded_message = forwarded.querySelector('message'),
const forwarded_message = forwarded.querySelector('message'),
forwarded_from = forwarded_message.getAttribute('from')
,
forwarded_from = forwarded_message.getAttribute('from')
;
is_carbon = !_.isNull(stanza.querySelector(`received[xmlns="${Strophe.NS.CARBONS}"]`));
is_carbon = !_.isNull(stanza.querySelector(`received[xmlns="${Strophe.NS.CARBONS}"]`));
if (is_carbon && Strophe.getBareJidFromJid(forwarded_from) !== from_jid) {
if (is_carbon && Strophe.getBareJidFromJid(forwarded_from) !== from_jid) {
// Prevent message forging via carbons
// Prevent message forging via carbons
...
@@ -62227,15 +62228,15 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
...
@@ -62227,15 +62228,15 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
to_jid = stanza.getAttribute('to');
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;
const requests_receipt = !_.isUndefined(sizzle(`request[xmlns="${Strophe.NS.RECEIPTS}"]`, stanza).pop());
const requests_receipt = !_.isUndefined(sizzle(`request[xmlns="${Strophe.NS.RECEIPTS}"]`, stanza).pop());
if (requests_receipt) {
if (requests_receipt
&& !is_carbon && !is_me
) {
this.sendReceiptStanza(from_jid, stanza.getAttribute('id'));
this.sendReceiptStanza(from_jid, stanza.getAttribute('id'));
}
}
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;
let contact_jid;
if (is_me) {
if (is_me) {
spec/messages.js
View file @
216a6849
...
@@ -1224,6 +1224,65 @@
...
@@ -1224,6 +1224,65 @@
done
();
done
();
}));
}));
it
(
"
carbon received does not emit a message delivery receipt
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
msg_id
=
u
.
getUniqueId
();
const
sent_stanzas
=
[];
spyOn
(
_converse
.
chatboxes
,
'
sendReceiptStanza
'
).
and
.
callThrough
();
const
msg
=
$msg
({
'
from
'
:
sender_jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
chat
'
,
'
id
'
:
u
.
getUniqueId
(),
}).
c
(
'
received
'
,
{
'
xmlns
'
:
'
urn:xmpp:carbons:2
'
})
.
c
(
'
forwarded
'
,
{
'
xmlns
'
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
message
'
,
{
'
xmlns
'
:
'
jabber:client
'
,
'
from
'
:
sender_jid
,
'
to
'
:
_converse
.
bare_jid
+
'
/another-resource
'
,
'
type
'
:
'
chat
'
,
'
id
'
:
msg_id
}).
c
(
'
body
'
).
t
(
'
Message!
'
).
up
()
.
c
(
'
request
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
RECEIPTS
}).
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
);
expect
(
_converse
.
chatboxes
.
sendReceiptStanza
).
not
.
toHaveBeenCalled
();
done
();
}));
it
(
"
forwarded does not emit a message delivery receipt if it's mine
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
const
recipient_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
msg_id
=
u
.
getUniqueId
();
const
sent_stanzas
=
[];
spyOn
(
_converse
.
chatboxes
,
'
sendReceiptStanza
'
).
and
.
callThrough
();
const
msg
=
$msg
({
'
from
'
:
converse
.
bare_jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
chat
'
,
'
id
'
:
u
.
getUniqueId
(),
}).
c
(
'
forwarded
'
,
{
'
xmlns
'
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
message
'
,
{
'
xmlns
'
:
'
jabber:client
'
,
'
from
'
:
_converse
.
bare_jid
+
'
/another-resource
'
,
'
to
'
:
recipient_jid
,
'
type
'
:
'
chat
'
,
'
id
'
:
msg_id
}).
c
(
'
body
'
).
t
(
'
Message!
'
).
up
()
.
c
(
'
request
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
RECEIPTS
}).
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
);
expect
(
_converse
.
chatboxes
.
sendReceiptStanza
).
not
.
toHaveBeenCalled
();
done
();
}));
it
(
"
delivery can be acknowledged by a receipt
"
,
it
(
"
delivery can be acknowledged by a receipt
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
...
...
src/headless/converse-chatboxes.js
View file @
216a6849
...
@@ -746,14 +746,15 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -746,14 +746,15 @@ converse.plugins.add('converse-chatboxes', {
return
true
;
return
true
;
}
}
let
from_jid
=
stanza
.
getAttribute
(
'
from
'
);
let
from_jid
=
stanza
.
getAttribute
(
'
from
'
),
is_carbon
=
false
;
const
forwarded
=
stanza
.
querySelector
(
'
forwarded
'
),
const
forwarded
=
stanza
.
querySelector
(
'
forwarded
'
),
original_stanza
=
stanza
;
original_stanza
=
stanza
;
if
(
!
_
.
isNull
(
forwarded
))
{
if
(
!
_
.
isNull
(
forwarded
))
{
const
forwarded_message
=
forwarded
.
querySelector
(
'
message
'
),
const
forwarded_message
=
forwarded
.
querySelector
(
'
message
'
),
forwarded_from
=
forwarded_message
.
getAttribute
(
'
from
'
)
,
forwarded_from
=
forwarded_message
.
getAttribute
(
'
from
'
)
;
is_carbon
=
!
_
.
isNull
(
stanza
.
querySelector
(
`received[xmlns="
${
Strophe
.
NS
.
CARBONS
}
"]`
));
is_carbon
=
!
_
.
isNull
(
stanza
.
querySelector
(
`received[xmlns="
${
Strophe
.
NS
.
CARBONS
}
"]`
));
if
(
is_carbon
&&
Strophe
.
getBareJidFromJid
(
forwarded_from
)
!==
from_jid
)
{
if
(
is_carbon
&&
Strophe
.
getBareJidFromJid
(
forwarded_from
)
!==
from_jid
)
{
// Prevent message forging via carbons
// Prevent message forging via carbons
...
@@ -765,15 +766,15 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -765,15 +766,15 @@ converse.plugins.add('converse-chatboxes', {
to_jid
=
stanza
.
getAttribute
(
'
to
'
);
to_jid
=
stanza
.
getAttribute
(
'
to
'
);
}
}
const
requests_receipt
=
!
_
.
isUndefined
(
sizzle
(
`request[xmlns="
${
Strophe
.
NS
.
RECEIPTS
}
"]`
,
stanza
).
pop
());
if
(
requests_receipt
)
{
this
.
sendReceiptStanza
(
from_jid
,
stanza
.
getAttribute
(
'
id
'
));
}
const
from_bare_jid
=
Strophe
.
getBareJidFromJid
(
from_jid
),
const
from_bare_jid
=
Strophe
.
getBareJidFromJid
(
from_jid
),
from_resource
=
Strophe
.
getResourceFromJid
(
from_jid
),
from_resource
=
Strophe
.
getResourceFromJid
(
from_jid
),
is_me
=
from_bare_jid
===
_converse
.
bare_jid
;
is_me
=
from_bare_jid
===
_converse
.
bare_jid
;
const
requests_receipt
=
!
_
.
isUndefined
(
sizzle
(
`request[xmlns="
${
Strophe
.
NS
.
RECEIPTS
}
"]`
,
stanza
).
pop
());
if
(
requests_receipt
&&
!
is_carbon
&&
!
is_me
)
{
this
.
sendReceiptStanza
(
from_jid
,
stanza
.
getAttribute
(
'
id
'
));
}
let
contact_jid
;
let
contact_jid
;
if
(
is_me
)
{
if
(
is_me
)
{
// I am the sender, so this must be a forwarded message...
// I am the sender, so this must be a forwarded 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