Rename getMessageAttributesFromStanza
to parseMessage
This commit is contained in:
parent
fef5292a12
commit
ce1f7e090e
@ -169,10 +169,10 @@ converse.plugins.add('converse-omemo', {
|
||||
},
|
||||
|
||||
ChatBox: {
|
||||
async getMessageAttributesFromStanza (stanza, original_stanza) {
|
||||
async parseMessage (stanza, original_stanza) {
|
||||
const { _converse } = this.__super__;
|
||||
const encrypted = sizzle(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, original_stanza).pop(),
|
||||
attrs = await this.__super__.getMessageAttributesFromStanza.apply(this, arguments);
|
||||
attrs = await this.__super__.parseMessage.apply(this, arguments);
|
||||
|
||||
if (!encrypted || !_converse.config.get('trusted')) {
|
||||
return attrs;
|
||||
|
@ -9,7 +9,7 @@ import { Model } from 'skeletor.js/src/model.js';
|
||||
import converse from "./converse-core";
|
||||
import filesize from "filesize";
|
||||
import log from "./log";
|
||||
import stanza_utils from "./utils/stanza";
|
||||
import st from "./utils/stanza";
|
||||
|
||||
const { $msg, Strophe, sizzle, utils } = converse.env;
|
||||
const u = converse.env.utils;
|
||||
@ -411,7 +411,7 @@ converse.plugins.add('converse-chat', {
|
||||
},
|
||||
|
||||
async onMessage (stanza, original_stanza, from_jid) {
|
||||
const attrs = await this.getMessageAttributesFromStanza(stanza, original_stanza);
|
||||
const attrs = await this.parseMessage(stanza, original_stanza);
|
||||
const message = this.getDuplicateMessage(attrs);
|
||||
if (message) {
|
||||
this.updateMessage(message, original_stanza);
|
||||
@ -527,7 +527,7 @@ converse.plugins.add('converse-chat', {
|
||||
|
||||
getUpdatedMessageAttributes (message, stanza) { // eslint-disable-line no-unused-vars
|
||||
return {
|
||||
'is_archived': stanza_utils.isArchived(stanza),
|
||||
'is_archived': st.isArchived(stanza),
|
||||
}
|
||||
},
|
||||
|
||||
@ -610,7 +610,7 @@ converse.plugins.add('converse-chat', {
|
||||
* @private
|
||||
* @method _converse.ChatBox#findDanglingRetraction
|
||||
* @param { object } attrs - Attributes representing a received
|
||||
* message, as returned by {@link stanza_utils.getMessageAttributesFromStanza}
|
||||
* message, as returned by {@link st.parseMessage}
|
||||
* @returns { _converse.Message }
|
||||
*/
|
||||
findDanglingRetraction (attrs) {
|
||||
@ -637,7 +637,7 @@ converse.plugins.add('converse-chat', {
|
||||
* @private
|
||||
* @method _converse.ChatBox#handleRetraction
|
||||
* @param { object } attrs - Attributes representing a received
|
||||
* message, as returned by {@link stanza_utils.getMessageAttributesFromStanza}
|
||||
* message, as returned by {@link st.parseMessage}
|
||||
* @returns { Boolean } Returns `true` or `false` depending on
|
||||
* whether a message was retracted or not.
|
||||
*/
|
||||
@ -677,7 +677,7 @@ converse.plugins.add('converse-chat', {
|
||||
* @private
|
||||
* @method _converse.ChatBox#handleCorrection
|
||||
* @param { object } attrs - Attributes representing a received
|
||||
* message, as returned by {@link stanza_utils.getMessageAttributesFromStanza}
|
||||
* message, as returned by {@link st.parseMessage}
|
||||
* @returns { _converse.Message|undefined } Returns the corrected
|
||||
* message or `undefined` if not applicable.
|
||||
*/
|
||||
@ -710,7 +710,7 @@ converse.plugins.add('converse-chat', {
|
||||
* @private
|
||||
* @method _converse.ChatBox#getDuplicateMessage
|
||||
* @param { object } attrs - Attributes representing a received
|
||||
* message, as returned by {@link stanza_utils.getMessageAttributesFromStanza}
|
||||
* message, as returned by {@link st.parseMessage}
|
||||
* @returns {Promise<_converse.Message>}
|
||||
*/
|
||||
getDuplicateMessage (attrs) {
|
||||
@ -1084,17 +1084,17 @@ converse.plugins.add('converse-chat', {
|
||||
/**
|
||||
* Parses a passed in message stanza and returns an object of attributes.
|
||||
* @private
|
||||
* @method _converse.ChatBox#getMessageAttributesFromStanza
|
||||
* @method _converse.ChatBox#parseMessage
|
||||
* @param { XMLElement } stanza - The message stanza
|
||||
* @param { XMLElement } original_stanza - The original stanza, that contains the
|
||||
* message stanza, if it was contained, otherwise it's the message stanza itself.
|
||||
* @returns { Object }
|
||||
*/
|
||||
getMessageAttributesFromStanza (stanza, original_stanza) {
|
||||
parseMessage (stanza, original_stanza) {
|
||||
// XXX: Eventually we want to get rid of this pass-through
|
||||
// method but currently we still need it because converse-omemo
|
||||
// overrides it.
|
||||
return stanza_utils.getMessageAttributesFromStanza(stanza, original_stanza, this, _converse);
|
||||
return st.parseMessage(stanza, original_stanza, this, _converse);
|
||||
},
|
||||
|
||||
maybeShow () {
|
||||
@ -1169,7 +1169,7 @@ converse.plugins.add('converse-chat', {
|
||||
if (!should_show) {
|
||||
return;
|
||||
}
|
||||
const attrs = await chatbox.getMessageAttributesFromStanza(stanza, stanza);
|
||||
const attrs = await chatbox.parseMessage(stanza, stanza);
|
||||
await chatbox.createMessage(attrs);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ converse.plugins.add('converse-headlines', {
|
||||
'type': _converse.HEADLINES_TYPE,
|
||||
'from': from_jid
|
||||
});
|
||||
const attrs = await chatbox.getMessageAttributesFromStanza(message, message);
|
||||
const attrs = await chatbox.parseMessage(message, message);
|
||||
await chatbox.createMessage(attrs);
|
||||
api.trigger('message', {'chatbox': chatbox, 'stanza': message});
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import { clone, debounce, intersection, invoke, isElement, isObject, isString, p
|
||||
import converse from "./converse-core";
|
||||
import log from "./log";
|
||||
import muc_utils from "./utils/muc";
|
||||
import stanza_utils from "./utils/stanza";
|
||||
import st from "./utils/stanza";
|
||||
import u from "./utils/form";
|
||||
|
||||
converse.MUC_TRAFFIC_STATES = ['entered', 'exited'];
|
||||
@ -1566,7 +1566,7 @@ converse.plugins.add('converse-muc', {
|
||||
* @param { XMLElement } pres - The presence stanza
|
||||
*/
|
||||
updateOccupantsOnPresence (pres) {
|
||||
const data = this.parsePresence(pres);
|
||||
const data = st.parseMUCPresenceStanza(pres);
|
||||
if (data.type === 'error' || (!data.jid && !data.nick)) {
|
||||
return true;
|
||||
}
|
||||
@ -1703,7 +1703,7 @@ converse.plugins.add('converse-muc', {
|
||||
* @private
|
||||
* @method _converse.ChatRoom#handleSubjectChange
|
||||
* @param { object } attrs - Attributes representing a received
|
||||
* message, as returned by {@link stanza_utils.getMessageAttributesFromStanza}
|
||||
* message, as returned by {@link st.parseMessage}
|
||||
*/
|
||||
async handleSubjectChange (attrs) {
|
||||
if (isString(attrs.subject) && !attrs.thread && !attrs.message) {
|
||||
@ -1861,7 +1861,7 @@ converse.plugins.add('converse-muc', {
|
||||
* @private
|
||||
* @method _converse.ChatRoom#findDanglingModeration
|
||||
* @param { object } attrs - Attributes representing a received
|
||||
* message, as returned by {@link stanza_utils.getMessageAttributesFromStanza}
|
||||
* message, as returned by {@link st.parseMessage}
|
||||
* @returns { _converse.ChatRoomMessage }
|
||||
*/
|
||||
findDanglingModeration (attrs) {
|
||||
@ -1892,7 +1892,7 @@ converse.plugins.add('converse-muc', {
|
||||
* @private
|
||||
* @method _converse.ChatRoom#handleModeration
|
||||
* @param { object } attrs - Attributes representing a received
|
||||
* message, as returned by {@link stanza_utils.getMessageAttributesFromStanza}
|
||||
* message, as returned by {@link st.parseMessage}
|
||||
* @returns { Boolean } Returns `true` or `false` depending on
|
||||
* whether a message was moderated or not.
|
||||
*/
|
||||
@ -2026,14 +2026,14 @@ converse.plugins.add('converse-muc', {
|
||||
await this.createInfoMessages(stanza);
|
||||
this.fetchFeaturesIfConfigurationChanged(stanza);
|
||||
|
||||
const attrs = await this.getMessageAttributesFromStanza(stanza, original_stanza);
|
||||
const attrs = await this.parseMessage(stanza, original_stanza);
|
||||
const message = this.getDuplicateMessage(attrs);
|
||||
if (message) {
|
||||
this.updateMessage(message, original_stanza);
|
||||
}
|
||||
if (message ||
|
||||
stanza_utils.isReceipt(stanza) ||
|
||||
stanza_utils.isChatMarker(stanza) ||
|
||||
st.isReceipt(stanza) ||
|
||||
st.isChatMarker(stanza) ||
|
||||
this.ignorableCSN(attrs)) {
|
||||
return api.trigger('message', {'stanza': original_stanza});
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ const stanza_utils = {
|
||||
/**
|
||||
* Parses a passed in message stanza and returns an object of attributes.
|
||||
* @private
|
||||
* @method stanza_utils#getMessageAttributesFromStanza
|
||||
* @method stanza_utils#parseMessage
|
||||
* @param { XMLElement } stanza - The message stanza
|
||||
* @param { XMLElement } original_stanza - The original stanza, that contains the
|
||||
* message stanza, if it was contained, otherwise it's the message stanza itself.
|
||||
@ -292,7 +292,7 @@ const stanza_utils = {
|
||||
* @param { _converse } _converse
|
||||
* @returns { Object }
|
||||
*/
|
||||
getMessageAttributesFromStanza (stanza, original_stanza, chatbox, _converse) {
|
||||
parseMessage (stanza, original_stanza, chatbox, _converse) {
|
||||
const is_muc = u.isChatRoom(chatbox);
|
||||
let attrs = Object.assign(
|
||||
stanza_utils.getStanzaIDs(stanza, original_stanza),
|
||||
|
Loading…
Reference in New Issue
Block a user