Commit 27378068 authored by JC Brand's avatar JC Brand

Fixes #1064 /topic without argument sets topic to "undefined"

parent 572cc494
......@@ -68757,7 +68757,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
type: "groupchat"
}).c("subject", {
xmlns: "jabber:client"
}).t(match[2]).tree());
}).t(match[2] || "").tree());
break;
......@@ -69428,19 +69428,25 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
// For translators: the %1$s and %2$s parts will get
// replaced by the user and topic text respectively
// Example: Topic set by JC Brand to: Hello World!
const subject = this.model.get('subject');
const subject = this.model.get('subject'),
message = subject.text ? __('Topic set by %1$s', subject.author) : __('Topic cleared by %1$s', subject.author),
date = moment().format();
this.content.insertAdjacentHTML('beforeend', tpl_info({
'data': '',
'isodate': moment().format(),
'isodate': date,
'extra_classes': 'chat-event',
'message': __('Topic set by %1$s', subject.author)
}));
this.content.insertAdjacentHTML('beforeend', tpl_info({
'data': '',
'isodate': moment().format(),
'extra_classes': 'chat-topic',
'message': subject.text
'message': message
}));
if (subject.text) {
this.content.insertAdjacentHTML('beforeend', tpl_info({
'data': '',
'isodate': date,
'extra_classes': 'chat-topic',
'message': subject.text
}));
}
this.scrollDown();
}
......@@ -70893,9 +70899,14 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
sender = resource && Strophe.unescapeNode(resource) || '';
if (!this.handleMessageCorrection(stanza)) {
const subject = _.propertyOf(stanza.querySelector('subject'))('textContent');
if (sender === '') {
return;
}
const subject_el = stanza.querySelector('subject');
if (subject) {
if (subject_el) {
const subject = _.propertyOf(subject_el)('textContent') || '';
u.safeSave(this, {
'subject': {
'author': sender,
......@@ -70904,10 +70915,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
});
}
if (sender === '') {
return;
}
this.createMessage(stanza, original_stanza).then(msg => this.incrementUnreadMsgCounter(msg)).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
......@@ -78386,8 +78393,10 @@ __e( o.Strophe.getNodeFromJid(o.jid) ) +
__e( o.Strophe.getDomainFromJid(o.jid) ) +
'\n ';
} ;
__p += '\n </div>\n <p class="chatroom-description">' +
__e( o.description ) +
__p += '\n </div>\n <p class="chatroom-description" title="' +
__e(o.description) +
'">' +
__e(o.description) +
'<p/>\n</div>\n<div class="chatbox-buttons row no-gutters">\n <a class="chatbox-btn close-chatbox-button fa fa-sign-out-alt" title="' +
__e(o.info_close) +
'"></a>\n ';
......@@ -770,54 +770,6 @@
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL))
}));
it("shows its description in the chat heading",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
function (done, _converse) {
let sent_IQ, IQ_id, view;
const sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_IQ = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback);
});
_converse.api.rooms.open('coven@chat.shakespeare.lit', {'nick': 'some1'})
.then(() => {
view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
const features_stanza = $iq({
from: 'coven@chat.shakespeare.lit',
'id': IQ_id,
'to': 'dummy@localhost/desktop',
'type': 'result'
})
.c('query', { 'xmlns': 'http://jabber.org/protocol/disco#info'})
.c('identity', {
'category': 'conference',
'name': 'A Dark Cave',
'type': 'text'
}).up()
.c('feature', {'var': 'http://jabber.org/protocol/muc'}).up()
.c('feature', {'var': 'muc_passwordprotected'}).up()
.c('feature', {'var': 'muc_hidden'}).up()
.c('feature', {'var': 'muc_temporary'}).up()
.c('feature', {'var': 'muc_open'}).up()
.c('feature', {'var': 'muc_unmoderated'}).up()
.c('feature', {'var': 'muc_nonanonymous'}).up()
.c('feature', {'var': 'urn:xmpp:mam:0'}).up()
.c('x', { 'xmlns':'jabber:x:data', 'type':'result'})
.c('field', {'var':'FORM_TYPE', 'type':'hidden'})
.c('value').t('http://jabber.org/protocol/muc#roominfo').up().up()
.c('field', {'type':'text-single', 'var':'muc#roominfo_description', 'label':'Description'})
.c('value').t('This is the description').up().up()
.c('field', {'type':'text-single', 'var':'muc#roominfo_occupants', 'label':'Number of participants'})
.c('value').t(0);
_converse.connection._dataRecv(test_utils.createRequest(features_stanza));
return test_utils.waitUntil(() => _.get(view.el.querySelector('.chatroom-description'), 'textContent'))
}).then(function () {
expect(view.el.querySelector('.chatroom-description').textContent).toBe('This is the description');
done();
});
}));
it("supports the /me command",
mock.initConverseWithPromises(
......@@ -1600,7 +1552,7 @@
});
}));
it("shows received groupchat subject messages",
it("shows the room topic in the header",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
......@@ -1618,6 +1570,7 @@
var chat_content = view.el.querySelector('.chat-content');
expect($(chat_content).find('.chat-event:last').text()).toBe('Topic set by ralphm');
expect($(chat_content).find('.chat-topic:last').text()).toBe(text);
expect(view.el.querySelector('.chatroom-description').textContent).toBe(text);
done();
});
}));
......
......@@ -991,7 +991,7 @@
to: this.model.get('jid'),
from: _converse.connection.jid,
type: "groupchat"
}).c("subject", {xmlns: "jabber:client"}).t(match[2]).tree()
}).c("subject", {xmlns: "jabber:client"}).t(match[2] || "").tree()
);
break;
case 'voice':
......@@ -1632,23 +1632,29 @@
// For translators: the %1$s and %2$s parts will get
// replaced by the user and topic text respectively
// Example: Topic set by JC Brand to: Hello World!
const subject = this.model.get('subject');
const subject = this.model.get('subject'),
message = subject.text ? __('Topic set by %1$s', subject.author) :
__('Topic cleared by %1$s', subject.author),
date = moment().format();
this.content.insertAdjacentHTML(
'beforeend',
tpl_info({
'data': '',
'isodate': moment().format(),
'isodate': date,
'extra_classes': 'chat-event',
'message': __('Topic set by %1$s', subject.author)
}));
this.content.insertAdjacentHTML(
'beforeend',
tpl_info({
'data': '',
'isodate': moment().format(),
'extra_classes': 'chat-topic',
'message': subject.text
'message': message
}));
if (subject.text) {
this.content.insertAdjacentHTML(
'beforeend',
tpl_info({
'data': '',
'isodate': date,
'extra_classes': 'chat-topic',
'message': subject.text
}));
}
this.scrollDown();
}
});
......
......@@ -921,13 +921,14 @@
sender = resource && Strophe.unescapeNode(resource) || '';
if (!this.handleMessageCorrection(stanza)) {
const subject = _.propertyOf(stanza.querySelector('subject'))('textContent');
if (subject) {
u.safeSave(this, {'subject': {'author': sender, 'text': subject}});
}
if (sender === '') {
return;
}
const subject_el = stanza.querySelector('subject');
if (subject_el) {
const subject = _.propertyOf(subject_el)('textContent') || '';
u.safeSave(this, {'subject': {'author': sender, 'text': subject}});
}
this.createMessage(stanza, original_stanza)
.then(msg => this.incrementUnreadMsgCounter(msg))
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
......
......@@ -7,7 +7,7 @@
{{{ o.Strophe.getNodeFromJid(o.jid) }}}@{{{ o.Strophe.getDomainFromJid(o.jid) }}}
{[ } ]}
</div>
<p class="chatroom-description">{{{ o.description }}}<p/>
<p class="chatroom-description" title="{{{o.description}}}">{{{o.description}}}<p/>
</div>
<div class="chatbox-buttons row no-gutters">
<a class="chatbox-btn close-chatbox-button fa fa-sign-out-alt" title="{{{o.info_close}}}"></a>
......
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