|
@@ -25,6 +25,18 @@
|
|
const MAM_ATTRIBUTES = ['with', 'start', 'end'];
|
|
const MAM_ATTRIBUTES = ['with', 'start', 'end'];
|
|
|
|
|
|
|
|
|
|
|
|
+ function getMessageArchiveID (stanza) {
|
|
|
|
+ const result = sizzle(`result[xmlns="${Strophe.NS.MAM}"]`, stanza).pop();
|
|
|
|
+ if (!_.isUndefined(result)) {
|
|
|
|
+ return result.getAttribute('id');
|
|
|
|
+ }
|
|
|
|
+ const stanza_id = sizzle(`stanza-id[xmlns="${Strophe.NS.SID}"]`, stanza).pop();
|
|
|
|
+ if (!_.isUndefined(stanza_id)) {
|
|
|
|
+ return stanza_id.getAttribute('id');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
converse.plugins.add('converse-mam', {
|
|
converse.plugins.add('converse-mam', {
|
|
|
|
|
|
optional_dependencies: ['converse-chatview', 'converse-muc'],
|
|
optional_dependencies: ['converse-chatview', 'converse-muc'],
|
|
@@ -38,9 +50,9 @@
|
|
ChatBox: {
|
|
ChatBox: {
|
|
getMessageAttributes (message, delay, original_stanza) {
|
|
getMessageAttributes (message, delay, original_stanza) {
|
|
const attrs = this.__super__.getMessageAttributes.apply(this, arguments);
|
|
const attrs = this.__super__.getMessageAttributes.apply(this, arguments);
|
|
- const result = sizzle(`stanza-id[xmlns="${Strophe.NS.SID}"]`, original_stanza).pop();
|
|
|
|
- if (!_.isUndefined(result)) {
|
|
|
|
- attrs.archive_id = result.getAttribute('id');
|
|
|
|
|
|
+ const archive_id = getMessageArchiveID(original_stanza);
|
|
|
|
+ if (archive_id) {
|
|
|
|
+ attrs.archive_id = archive_id;
|
|
}
|
|
}
|
|
return attrs;
|
|
return attrs;
|
|
}
|
|
}
|
|
@@ -191,6 +203,17 @@
|
|
this.model.on('change:connection_status', this.fetchArchivedMessagesIfNecessary, this);
|
|
this.model.on('change:connection_status', this.fetchArchivedMessagesIfNecessary, this);
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ isDuplicate (message, original_stanza) {
|
|
|
|
+ const result = this.__super__.isDuplicate.apply(this, arguments);
|
|
|
|
+ if (result) {
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ const archive_id = getMessageArchiveID(original_stanza);
|
|
|
|
+ if (archive_id) {
|
|
|
|
+ return this.model.messages.filter({'archive_id': archive_id}).length > 0;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
renderChatArea () {
|
|
renderChatArea () {
|
|
const result = this.__super__.renderChatArea.apply(this, arguments);
|
|
const result = this.__super__.renderChatArea.apply(this, arguments);
|
|
if (!this.disable_mam) {
|
|
if (!this.disable_mam) {
|