Don't send out receipts or markers for MAM messages

Eventually we need to add better support for receipts and markers of MAM
messages.

We'll need to do the following:

* First check whether the MAM page already contains the receipts or markers, to avoid duplication
* Only ever in catchup mode
* Only after full catchup to ensure that the receipt is not in a different page than the message
This commit is contained in:
JC Brand 2019-03-12 13:00:15 +01:00
parent 76bff83ca3
commit 5b4ce87a4d
3 changed files with 18 additions and 12 deletions

View File

@ -6,6 +6,7 @@
- Upgrade to Backbone 1.4.0
- Fix "flashing" of roster filter when you have less than 5 roster contacts.
- Fix handling of CAPTCHAs offered by ejabberd.
- Don't send out receipts or markers for MAM messages
- Allow setting of debug mode via URL with `/#converse?debug=true`
- New config setting [locked_muc_domain](https://conversejs.org/docs/html/configuration.html#locked-muc-domain)
- New config setting [show_client_info](https://conversejs.org/docs/html/configuration.html#show-client-info)

14
dist/converse.js vendored
View File

@ -62009,7 +62009,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
_converse.api.send(stanza);
},
handleChatMarker(stanza, from_jid, is_carbon, is_roster_contact) {
handleChatMarker(stanza, from_jid, is_carbon, is_roster_contact, is_mam) {
const to_bare_jid = Strophe.getBareJidFromJid(stanza.getAttribute('to'));
if (to_bare_jid !== _converse.bare_jid) {
@ -62030,7 +62030,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
const marker = markers.pop();
if (marker.nodeName === 'markable') {
if (is_roster_contact && !is_carbon) {
if (is_roster_contact && !is_carbon && !is_mam) {
this.sendMarker(from_jid, stanza.getAttribute('id'), 'received');
}
@ -62069,7 +62069,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
_converse.api.send(receipt_stanza);
},
handleReceipt(stanza, from_jid, is_carbon, is_me) {
handleReceipt(stanza, from_jid, is_carbon, is_me, is_mam) {
const requests_receipt = !_.isUndefined(sizzle(`request[xmlns="${Strophe.NS.RECEIPTS}"]`, stanza).pop());
if (requests_receipt && !is_carbon && !is_me) {
@ -62590,7 +62590,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
}
let from_jid = stanza.getAttribute('from'),
is_carbon = false;
is_carbon = false,
is_mam = false;
const forwarded = stanza.querySelector('forwarded'),
original_stanza = stanza;
@ -62598,6 +62599,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
const forwarded_message = forwarded.querySelector('message'),
forwarded_from = forwarded_message.getAttribute('from');
is_carbon = !_.isNull(stanza.querySelector(`received[xmlns="${Strophe.NS.CARBONS}"]`));
is_mam = sizzle(`message > result[xmlns="${Strophe.NS.MAM}"]`, stanza).length > 0;
if (is_carbon && Strophe.getBareJidFromJid(forwarded_from) !== from_jid) {
// Prevent message forging via carbons
@ -62647,7 +62649,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
chatbox.updateMessage(message, original_stanza);
}
if (!message && !chatbox.handleMessageCorrection(stanza) && !chatbox.handleReceipt(stanza, from_jid, is_carbon, is_me) && !chatbox.handleChatMarker(stanza, from_jid, is_carbon, is_roster_contact)) {
if (!message && !chatbox.handleMessageCorrection(stanza) && !chatbox.handleReceipt(stanza, from_jid, is_carbon, is_me, is_mam) && !chatbox.handleChatMarker(stanza, from_jid, is_carbon, is_roster_contact, is_mam)) {
const attrs = await chatbox.getMessageAttributesFromStanza(stanza, original_stanza);
if (attrs['chat_state'] || !u.isEmptyMessage(attrs)) {
@ -95747,7 +95749,7 @@ _headless_utils_core__WEBPACK_IMPORTED_MODULE_16__["default"].isImageURL = funct
const filename = url.filename().toLowerCase();
if (url.protocol().toLowerCase() !== "https") {
if (window.location.protocol === 'https:' && url.protocol().toLowerCase() !== "https") {
return false;
}

View File

@ -370,7 +370,7 @@ converse.plugins.add('converse-chatboxes', {
_converse.api.send(stanza);
},
handleChatMarker (stanza, from_jid, is_carbon, is_roster_contact) {
handleChatMarker (stanza, from_jid, is_carbon, is_roster_contact, is_mam) {
const to_bare_jid = Strophe.getBareJidFromJid(stanza.getAttribute('to'));
if (to_bare_jid !== _converse.bare_jid) {
return false;
@ -388,7 +388,7 @@ converse.plugins.add('converse-chatboxes', {
} else {
const marker = markers.pop();
if (marker.nodeName === 'markable') {
if (is_roster_contact && !is_carbon) {
if (is_roster_contact && !is_carbon && !is_mam) {
this.sendMarker(from_jid, stanza.getAttribute('id'), 'received');
}
return false;
@ -416,7 +416,7 @@ converse.plugins.add('converse-chatboxes', {
_converse.api.send(receipt_stanza);
},
handleReceipt (stanza, from_jid, is_carbon, is_me) {
handleReceipt (stanza, from_jid, is_carbon, is_me, is_mam) {
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'));
@ -882,7 +882,9 @@ converse.plugins.add('converse-chatboxes', {
}
let from_jid = stanza.getAttribute('from'),
is_carbon = false;
is_carbon = false,
is_mam = false;
const forwarded = stanza.querySelector('forwarded'),
original_stanza = stanza;
@ -890,6 +892,7 @@ converse.plugins.add('converse-chatboxes', {
const forwarded_message = forwarded.querySelector('message'),
forwarded_from = forwarded_message.getAttribute('from');
is_carbon = !_.isNull(stanza.querySelector(`received[xmlns="${Strophe.NS.CARBONS}"]`));
is_mam = sizzle(`message > result[xmlns="${Strophe.NS.MAM}"]`, stanza).length > 0;
if (is_carbon && Strophe.getBareJidFromJid(forwarded_from) !== from_jid) {
// Prevent message forging via carbons
@ -936,8 +939,8 @@ converse.plugins.add('converse-chatboxes', {
}
if (!message &&
!chatbox.handleMessageCorrection(stanza) &&
!chatbox.handleReceipt (stanza, from_jid, is_carbon, is_me) &&
!chatbox.handleChatMarker(stanza, from_jid, is_carbon, is_roster_contact)) {
!chatbox.handleReceipt (stanza, from_jid, is_carbon, is_me, is_mam) &&
!chatbox.handleChatMarker(stanza, from_jid, is_carbon, is_roster_contact, is_mam)) {
const attrs = await chatbox.getMessageAttributesFromStanza(stanza, original_stanza);
if (attrs['chat_state'] || !u.isEmptyMessage(attrs)) {