Skip to content

Commit

Permalink
PoC fix for conversejs#1442
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlovl committed Feb 12, 2019
1 parent 81b6dfe commit 0dad10f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
19 changes: 11 additions & 8 deletions dist/converse.js
Original file line number Diff line number Diff line change
Expand Up @@ -61716,13 +61716,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) {
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'));
}

handleReceipt(stanza) {
const to_bare_jid = Strophe.getBareJidFromJid(stanza.getAttribute('to'));

if (to_bare_jid === _converse.bare_jid) {
Expand Down Expand Up @@ -62257,8 +62251,13 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
'fullname': _.get(_converse.api.contacts.get(contact_jid), 'attributes.fullname')
},
chatbox = this.getChatBox(contact_jid, chatbox_attrs, has_body);
const requests_receipt = !_.isUndefined(sizzle(`request[xmlns="${Strophe.NS.RECEIPTS}"]`, stanza).pop());

if (chatbox && !chatbox.handleMessageCorrection(stanza) && !chatbox.handleReceipt(stanza, from_jid, is_carbon, is_me) && !chatbox.handleChatMarker(stanza, from_jid, is_carbon)) {
if (requests_receipt && !is_carbon && !is_me) {
this.sendReceiptStanza(from_jid, stanza.getAttribute('id'));
}

if (chatbox && !chatbox.handleMessageCorrection(stanza) && !chatbox.handleReceipt(stanza) && !chatbox.handleChatMarker(stanza, from_jid, is_carbon)) {
await chatbox.createMessage(stanza, original_stanza);
}

Expand Down Expand Up @@ -67030,6 +67029,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
return;
}

if (this.handleReceipt(stanza)) {
return;
}

const msg = await this.messages.create(attrs);

if (forwarded && msg && msg.get('sender') === 'me') {
Expand Down
14 changes: 8 additions & 6 deletions src/headless/converse-chatboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,7 @@ converse.plugins.add('converse-chatboxes', {
_converse.api.send(receipt_stanza);
},

handleReceipt (stanza, from_jid, is_carbon, is_me) {
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'));
}
handleReceipt (stanza) {
const to_bare_jid = Strophe.getBareJidFromJid(stanza.getAttribute('to'));
if (to_bare_jid === _converse.bare_jid) {
const receipt = sizzle(`received[xmlns="${Strophe.NS.RECEIPTS}"]`, stanza).pop();
Expand Down Expand Up @@ -850,9 +846,15 @@ converse.plugins.add('converse-chatboxes', {
const has_body = sizzle(`body, encrypted[xmlns="${Strophe.NS.OMEMO}"]`, stanza).length > 0,
chatbox_attrs = {'fullname': _.get(_converse.api.contacts.get(contact_jid), 'attributes.fullname')},
chatbox = this.getChatBox(contact_jid, chatbox_attrs, has_body);

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'));
}

if (chatbox &&
!chatbox.handleMessageCorrection(stanza) &&
!chatbox.handleReceipt (stanza, from_jid, is_carbon, is_me) &&
!chatbox.handleReceipt (stanza) &&
!chatbox.handleChatMarker(stanza, from_jid, is_carbon)) {
await chatbox.createMessage(stanza, original_stanza);
}
Expand Down
5 changes: 5 additions & 0 deletions src/headless/converse-muc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,11 @@ converse.plugins.add('converse-muc', {
// No need showing delayed or our own CSN messages
return;
}

if (this.handleReceipt (stanza)) {
return;
}

const msg = await this.messages.create(attrs);
if (forwarded && msg && msg.get('sender') === 'me') {
msg.save({'received': moment().format()});
Expand Down

0 comments on commit 0dad10f

Please sign in to comment.