mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 09:26:14 -04:00
chat: Give chatNewMessage
hook access to the raw message object
This commit is contained in:
parent
fc5a3f553d
commit
2597b940f4
4 changed files with 30 additions and 1 deletions
|
@ -131,6 +131,7 @@ exports.chat = (() => {
|
|||
authorName: msg.userName != null ? msg.userName : html10n.get('pad.userlist.unnamed'),
|
||||
author: msg.userId,
|
||||
text: padutils.escapeHtmlWithClickableLinks(msg.text, '_blank'),
|
||||
message: msg,
|
||||
sticky: false,
|
||||
timestamp: msg.time,
|
||||
timeStr: (() => {
|
||||
|
|
|
@ -60,5 +60,24 @@ describe('chat hooks', function () {
|
|||
]);
|
||||
});
|
||||
}
|
||||
|
||||
it('message is an object', async function () {
|
||||
await Promise.all([
|
||||
checkHook('chatNewMessage', ({message}) => {
|
||||
expect(message).to.be.an('object');
|
||||
}),
|
||||
helper.sendChatMessage(`${this.test.title}{enter}`),
|
||||
]);
|
||||
});
|
||||
|
||||
it('message.text is not processed', async function () {
|
||||
const msg = '<script>alert("foo");</script> https://etherpad.org';
|
||||
await Promise.all([
|
||||
checkHook('chatNewMessage', ({message: {text}}) => {
|
||||
expect(text).to.equal(`${msg}\n`);
|
||||
}),
|
||||
helper.sendChatMessage(`${msg}{enter}`),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue