Bugfix. Own groupchat messages weren't being recognized
This commit is contained in:
parent
dc4c832fce
commit
f120fbd209
63
dist/converse.js
vendored
63
dist/converse.js
vendored
@ -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,
|
||||
|
@ -822,29 +822,6 @@
|
||||
});
|
||||
}));
|
||||
|
||||
it("will specially mark messages in which you are mentioned",
|
||||
mock.initConverseWithPromises(
|
||||
null, ['rosterGroupsFetched'], {},
|
||||
function (done, _converse) {
|
||||
|
||||
test_utils.createContacts(_converse, 'current');
|
||||
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
|
||||
var view = _converse.chatboxviews.get('lounge@localhost');
|
||||
if (!$(view.el).find('.chat-area').length) { view.renderChatArea(); }
|
||||
var message = 'dummy: Your attention is required';
|
||||
var nick = mock.chatroom_names[0],
|
||||
msg = $msg({
|
||||
from: 'lounge@localhost/'+nick,
|
||||
id: (new Date()).getTime(),
|
||||
to: 'dummy@localhost',
|
||||
type: 'groupchat'
|
||||
}).c('body').t(message).tree();
|
||||
view.model.onMessage(msg);
|
||||
expect($(view.el).find('.chat-msg').hasClass('mentioned')).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
it("supports the /me command",
|
||||
mock.initConverseWithPromises(
|
||||
null, ['rosterGroupsFetched'], {},
|
||||
|
@ -1866,6 +1866,50 @@
|
||||
|
||||
describe("A Groupchat Message", function () {
|
||||
|
||||
it("is specially marked when you are mentioned in it",
|
||||
mock.initConverseWithPromises(
|
||||
null, ['rosterGroupsFetched'], {},
|
||||
function (done, _converse) {
|
||||
|
||||
test_utils.createContacts(_converse, 'current');
|
||||
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
|
||||
const view = _converse.chatboxviews.get('lounge@localhost');
|
||||
if (!$(view.el).find('.chat-area').length) { view.renderChatArea(); }
|
||||
const message = 'dummy: Your attention is required';
|
||||
const nick = mock.chatroom_names[0],
|
||||
msg = $msg({
|
||||
from: 'lounge@localhost/'+nick,
|
||||
id: (new Date()).getTime(),
|
||||
to: 'dummy@localhost',
|
||||
type: 'groupchat'
|
||||
}).c('body').t(message).tree();
|
||||
view.model.onMessage(msg);
|
||||
expect($(view.el).find('.chat-msg').hasClass('mentioned')).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
it("keeps track whether you are the sender or not",
|
||||
mock.initConverseWithPromises(
|
||||
null, ['rosterGroupsFetched'], {},
|
||||
function (done, _converse) {
|
||||
|
||||
test_utils.createContacts(_converse, 'current');
|
||||
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
|
||||
const view = _converse.chatboxviews.get('lounge@localhost');
|
||||
const msg = $msg({
|
||||
from: 'lounge@localhost/dummy',
|
||||
id: (new Date()).getTime(),
|
||||
to: 'dummy@localhost',
|
||||
type: 'groupchat'
|
||||
}).c('body').t('I wrote this message!').tree();
|
||||
view.model.onMessage(msg);
|
||||
expect(view.model.messages.last().get('sender')).toBe('me');
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
it("can be replaced with a correction",
|
||||
mock.initConverseWithPromises(
|
||||
null, ['rosterGroupsFetched'], {},
|
||||
|
@ -482,7 +482,7 @@
|
||||
if (attrs.type === 'groupchat') {
|
||||
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';
|
||||
|
Loading…
Reference in New Issue
Block a user