Commit ec65bb35 authored by JC Brand's avatar JC Brand

`createMessage` doesn't need the delay parameter

parent ce3ba2a4
...@@ -62520,7 +62520,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -62520,7 +62520,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} }
}, },
getMessageAttributesFromStanza(message, delay, original_stanza) { getMessageAttributesFromStanza(message, original_stanza) {
/* Parses a passed in message stanza and returns an object /* Parses a passed in message stanza and returns an object
* of attributes. * of attributes.
* *
...@@ -62582,11 +62582,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -62582,11 +62582,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return attrs; return attrs;
}, },
createMessage(message, delay, original_stanza) { createMessage(message, original_stanza) {
/* Create a Backbone.Message object inside this chat box /* Create a Backbone.Message object inside this chat box
* based on the identified message stanza. * based on the identified message stanza.
*/ */
const attrs = this.getMessageAttributesFromStanza.apply(this, arguments); const attrs = this.getMessageAttributesFromStanza(message, original_stanza);
const is_csn = u.isOnlyChatStateNotification(attrs); const is_csn = u.isOnlyChatStateNotification(attrs);
if (is_csn && (attrs.delayed || attrs.type === 'groupchat' && Strophe.getResourceFromJid(attrs.from) == this.get('nick'))) { if (is_csn && (attrs.delayed || attrs.type === 'groupchat' && Strophe.getResourceFromJid(attrs.from) == this.get('nick'))) {
...@@ -62694,7 +62694,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -62694,7 +62694,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return true; return true;
} }
chatbox.createMessage(message, null, message); chatbox.createMessage(message, message);
return true; return true;
}, },
...@@ -62705,10 +62705,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -62705,10 +62705,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* Parameters: * Parameters:
* (XMLElement) message - The incoming message stanza * (XMLElement) message - The incoming message stanza
*/ */
let contact_jid, let from_jid = message.getAttribute('from'),
delay,
resource,
from_jid = message.getAttribute('from'),
to_jid = message.getAttribute('to'); to_jid = message.getAttribute('to');
const original_stanza = message, const original_stanza = message,
to_resource = Strophe.getResourceFromJid(to_jid), to_resource = Strophe.getResourceFromJid(to_jid),
...@@ -62735,13 +62732,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -62735,13 +62732,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
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
//
// https://xmpp.org/extensions/xep-0280.html#security // https://xmpp.org/extensions/xep-0280.html#security
return true; return true;
} }
message = forwarded_message; message = forwarded_message;
delay = forwarded.querySelector('delay');
from_jid = message.getAttribute('from'); from_jid = message.getAttribute('from');
to_jid = message.getAttribute('to'); to_jid = message.getAttribute('to');
} }
...@@ -62749,14 +62744,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -62749,14 +62744,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
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;
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...
contact_jid = Strophe.getBareJidFromJid(to_jid); contact_jid = Strophe.getBareJidFromJid(to_jid);
resource = Strophe.getResourceFromJid(to_jid);
} else { } else {
contact_jid = from_bare_jid; contact_jid = from_bare_jid;
resource = from_resource;
} // Get chat box, but only create a new one when the message has a body. } // Get chat box, but only create a new one when the message has a body.
...@@ -62775,7 +62769,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -62775,7 +62769,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// Only create the message when we're sure it's not a // Only create the message when we're sure it's not a
// duplicate // duplicate
chatbox.incrementUnreadMsgCounter(original_stanza); chatbox.incrementUnreadMsgCounter(original_stanza);
chatbox.createMessage(message, delay, original_stanza); chatbox.createMessage(message, original_stanza);
} }
} }
...@@ -67676,7 +67670,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -67676,7 +67670,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'from': from_jid 'from': from_jid
}); });
chatbox.createMessage(message, undefined, message); chatbox.createMessage(message, message);
_converse.emit('message', { _converse.emit('message', {
'chatbox': chatbox, 'chatbox': chatbox,
...@@ -67875,7 +67869,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -67875,7 +67869,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// //
// New functions which don't exist yet can also be added. // New functions which don't exist yet can also be added.
ChatBox: { ChatBox: {
getMessageAttributesFromStanza(message, delay, original_stanza) { getMessageAttributesFromStanza(message, original_stanza) {
const attrs = this.__super__.getMessageAttributesFromStanza.apply(this, arguments); const attrs = this.__super__.getMessageAttributesFromStanza.apply(this, arguments);
const archive_id = getMessageArchiveID(original_stanza); const archive_id = getMessageArchiveID(original_stanza);
...@@ -72079,11 +72073,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -72079,11 +72073,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.fetchFeaturesIfConfigurationChanged(stanza); this.fetchFeaturesIfConfigurationChanged(stanza);
const original_stanza = stanza, const original_stanza = stanza,
forwarded = stanza.querySelector('forwarded'); forwarded = stanza.querySelector('forwarded');
let delay;
if (!_.isNull(forwarded)) { if (!_.isNull(forwarded)) {
stanza = forwarded.querySelector('message'); stanza = forwarded.querySelector('message');
delay = forwarded.querySelector('delay');
} }
const jid = stanza.getAttribute('from'), const jid = stanza.getAttribute('from'),
...@@ -72109,7 +72101,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -72109,7 +72101,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} }
this.incrementUnreadMsgCounter(original_stanza); this.incrementUnreadMsgCounter(original_stanza);
this.createMessage(stanza, delay, original_stanza); this.createMessage(stanza, original_stanza);
if (sender !== this.get('nick')) { if (sender !== this.get('nick')) {
// We only emit an event if it's not our own message // We only emit an event if it's not our own message
...@@ -427,7 +427,7 @@ ...@@ -427,7 +427,7 @@
}, },
getMessageAttributesFromStanza (message, delay, original_stanza) { getMessageAttributesFromStanza (message, original_stanza) {
/* Parses a passed in message stanza and returns an object /* Parses a passed in message stanza and returns an object
* of attributes. * of attributes.
* *
...@@ -487,11 +487,11 @@ ...@@ -487,11 +487,11 @@
return attrs; return attrs;
}, },
createMessage (message, delay, original_stanza) { createMessage (message, original_stanza) {
/* Create a Backbone.Message object inside this chat box /* Create a Backbone.Message object inside this chat box
* based on the identified message stanza. * based on the identified message stanza.
*/ */
const attrs = this.getMessageAttributesFromStanza.apply(this, arguments) const attrs = this.getMessageAttributesFromStanza(message, original_stanza);
const is_csn = u.isOnlyChatStateNotification(attrs); const is_csn = u.isOnlyChatStateNotification(attrs);
if (is_csn && (attrs.delayed || (attrs.type === 'groupchat' && Strophe.getResourceFromJid(attrs.from) == this.get('nick')))) { if (is_csn && (attrs.delayed || (attrs.type === 'groupchat' && Strophe.getResourceFromJid(attrs.from) == this.get('nick')))) {
// XXX: MUC leakage // XXX: MUC leakage
...@@ -591,7 +591,7 @@ ...@@ -591,7 +591,7 @@
if (!chatbox) { if (!chatbox) {
return true; return true;
} }
chatbox.createMessage(message, null, message); chatbox.createMessage(message, message);
return true; return true;
}, },
...@@ -602,8 +602,7 @@ ...@@ -602,8 +602,7 @@
* Parameters: * Parameters:
* (XMLElement) message - The incoming message stanza * (XMLElement) message - The incoming message stanza
*/ */
let contact_jid, delay, resource, let from_jid = message.getAttribute('from'),
from_jid = message.getAttribute('from'),
to_jid = message.getAttribute('to'); to_jid = message.getAttribute('to');
const original_stanza = message, const original_stanza = message,
...@@ -632,12 +631,10 @@ ...@@ -632,12 +631,10 @@
const forwarded_from = forwarded_message.getAttribute('from'); const forwarded_from = forwarded_message.getAttribute('from');
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
//
// https://xmpp.org/extensions/xep-0280.html#security // https://xmpp.org/extensions/xep-0280.html#security
return true; return true;
} }
message = forwarded_message; message = forwarded_message;
delay = forwarded.querySelector('delay');
from_jid = message.getAttribute('from'); from_jid = message.getAttribute('from');
to_jid = message.getAttribute('to'); to_jid = message.getAttribute('to');
} }
...@@ -646,13 +643,12 @@ ...@@ -646,13 +643,12 @@
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;
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...
contact_jid = Strophe.getBareJidFromJid(to_jid); contact_jid = Strophe.getBareJidFromJid(to_jid);
resource = Strophe.getResourceFromJid(to_jid);
} else { } else {
contact_jid = from_bare_jid; contact_jid = from_bare_jid;
resource = from_resource;
} }
// Get chat box, but only create a new one when the message has a body. // Get chat box, but only create a new one when the message has a body.
const attrs = { const attrs = {
...@@ -667,7 +663,7 @@ ...@@ -667,7 +663,7 @@
// Only create the message when we're sure it's not a // Only create the message when we're sure it's not a
// duplicate // duplicate
chatbox.incrementUnreadMsgCounter(original_stanza); chatbox.incrementUnreadMsgCounter(original_stanza);
chatbox.createMessage(message, delay, original_stanza); chatbox.createMessage(message, original_stanza);
} }
} }
_converse.emit('message', {'stanza': original_stanza, 'chatbox': chatbox}); _converse.emit('message', {'stanza': original_stanza, 'chatbox': chatbox});
......
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
'type': 'headline', 'type': 'headline',
'from': from_jid 'from': from_jid
}); });
chatbox.createMessage(message, undefined, message); chatbox.createMessage(message, message);
_converse.emit('message', {'chatbox': chatbox, 'stanza': message}); _converse.emit('message', {'chatbox': chatbox, 'stanza': message});
} }
return true; return true;
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
// //
// New functions which don't exist yet can also be added. // New functions which don't exist yet can also be added.
ChatBox: { ChatBox: {
getMessageAttributesFromStanza (message, delay, original_stanza) { getMessageAttributesFromStanza (message, original_stanza) {
const attrs = this.__super__.getMessageAttributesFromStanza.apply(this, arguments); const attrs = this.__super__.getMessageAttributesFromStanza.apply(this, arguments);
const archive_id = getMessageArchiveID(original_stanza); const archive_id = getMessageArchiveID(original_stanza);
if (archive_id) { if (archive_id) {
......
...@@ -843,10 +843,8 @@ ...@@ -843,10 +843,8 @@
const original_stanza = stanza, const original_stanza = stanza,
forwarded = stanza.querySelector('forwarded'); forwarded = stanza.querySelector('forwarded');
let delay;
if (!_.isNull(forwarded)) { if (!_.isNull(forwarded)) {
stanza = forwarded.querySelector('message'); stanza = forwarded.querySelector('message');
delay = forwarded.querySelector('delay');
} }
const jid = stanza.getAttribute('from'), const jid = stanza.getAttribute('from'),
resource = Strophe.getResourceFromJid(jid), resource = Strophe.getResourceFromJid(jid),
...@@ -863,7 +861,7 @@ ...@@ -863,7 +861,7 @@
return; return;
} }
this.incrementUnreadMsgCounter(original_stanza); this.incrementUnreadMsgCounter(original_stanza);
this.createMessage(stanza, delay, original_stanza); this.createMessage(stanza, original_stanza);
if (sender !== this.get('nick')) { if (sender !== this.get('nick')) {
// We only emit an event if it's not our own message // We only emit an event if it's not our own message
_converse.emit('message', {'stanza': original_stanza, 'chatbox': this}); _converse.emit('message', {'stanza': original_stanza, 'chatbox': this});
......
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
!(utils.isOTRMessage($message[0]) && !_.includes([UNVERIFIED, VERIFIED], this.get('otr_status'))); !(utils.isOTRMessage($message[0]) && !_.includes([UNVERIFIED, VERIFIED], this.get('otr_status')));
}, },
createMessage (message, delay, original_stanza) { createMessage (message, original_stanza) {
const { _converse } = this.__super__, const { _converse } = this.__super__,
text = _.propertyOf(message.querySelector('body'))('textContent'); text = _.propertyOf(message.querySelector('body'))('textContent');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment