|
@@ -68819,7 +68819,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
attrs.from = stanza.getAttribute('from');
|
|
|
attrs.nick = Strophe.unescapeNode(Strophe.getResourceFromJid(attrs.from));
|
|
|
|
|
|
- if (attrs.from === this.get('nick')) {
|
|
|
+ if (Strophe.getResourceFromJid(attrs.from) === this.get('nick')) {
|
|
|
attrs.sender = 'me';
|
|
|
} else {
|
|
|
attrs.sender = 'them';
|
|
@@ -69253,6 +69253,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
|
|
|
|
|
|
_.extend(_converse.api, {
|
|
|
+ /**
|
|
|
+ * The "chats" grouping (used for one-on-one chats)
|
|
|
+ *
|
|
|
+ * @namespace
|
|
|
+ */
|
|
|
'chats': {
|
|
|
'create'(jids, attrs) {
|
|
|
if (_.isUndefined(jids)) {
|
|
@@ -69283,6 +69288,39 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * Opens a new one-on-one chat.
|
|
|
+ *
|
|
|
+ * @function
|
|
|
+ *
|
|
|
+ * @param {String|string[]} name - e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']
|
|
|
+ * @returns {Promise} Promise which resolves with the Backbone.Model representing the chat.
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * // To open a single chat, provide the JID of the contact you're chatting with in that chat:
|
|
|
+ * converse.plugins.add('myplugin', {
|
|
|
+ * initialize: function() {
|
|
|
+ * var _converse = this._converse;
|
|
|
+ * // Note, buddy@example.org must be in your contacts roster!
|
|
|
+ * _converse.api.chats.open('buddy@example.com').then((chat) => {
|
|
|
+ * // Now you can do something with the chat model
|
|
|
+ * });
|
|
|
+ * }
|
|
|
+ * });
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * // To open an array of chats, provide an array of JIDs:
|
|
|
+ * converse.plugins.add('myplugin', {
|
|
|
+ * initialize: function () {
|
|
|
+ * var _converse = this._converse;
|
|
|
+ * // Note, these users must first be in your contacts roster!
|
|
|
+ * _converse.api.chats.open(['buddy1@example.com', 'buddy2@example.com']).then((chats) => {
|
|
|
+ * // Now you can do something with the chat models
|
|
|
+ * });
|
|
|
+ * }
|
|
|
+ * });
|
|
|
+ *
|
|
|
+ */
|
|
|
'open'(jids, attrs) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
Promise.all([_converse.api.waitUntil('rosterContactsFetched'), _converse.api.waitUntil('chatBoxesFetched')]).then(() => {
|
|
@@ -69301,6 +69339,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns a chat model. The chat should already be open.
|
|
|
+ *
|
|
|
+ * @function
|
|
|
+ *
|
|
|
+ * @param {String|string[]} name - e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']
|
|
|
+ * @returns {Backbone.Model}
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * // To return a single chat, provide the JID of the contact you're chatting with in that chat:
|
|
|
+ * const model = _converse.api.chats.get('buddy@example.com');
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * // To return an array of chats, provide an array of JIDs:
|
|
|
+ * const models = _converse.api.chats.get(['buddy1@example.com', 'buddy2@example.com']);
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * // To return all open chats, call the method without any parameters::
|
|
|
+ * const models = _converse.api.chats.get();
|
|
|
+ *
|
|
|
+ */
|
|
|
'get'(jids) {
|
|
|
if (_.isUndefined(jids)) {
|
|
|
const result = [];
|
|
@@ -73088,6 +73147,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ iqresult.c('query', attrs);
|
|
|
+
|
|
|
_.each(plugin._identities, identity => {
|
|
|
const attrs = {
|
|
|
'category': identity.category,
|