Skip to content

Node.js based forum software built for the modern web

feat: add client side filter:chat.send, closes #10729

Barış Soner Uşaklıb2da02d67678
diff --git a/public/src/client/chats/messages.js b/public/src/client/chats/messages.js
index 92cae2dc75..06ebd8f1a0 100644
--- a/public/src/client/chats/messages.js
+++ b/public/src/client/chats/messages.js
@@ -7,9 +7,9 @@ define('forum/chats/messages', [
], function (components, translator, Benchpress, hooks, bootbox, alerts, messagesModule, api) {
const messages = {};
- messages.sendMessage = function (roomId, inputEl) {
- const message = inputEl.val();
- const mid = inputEl.attr('data-mid');
+ messages.sendMessage = async function (roomId, inputEl) {
+ let message = inputEl.val();
+ let mid = inputEl.attr('data-mid');
if (!message.trim().length) {
return;
@@ -18,7 +18,10 @@ define('forum/chats/messages', [
inputEl.val('');
inputEl.removeAttr('data-mid');
messages.updateRemainingLength(inputEl.parent());
- hooks.fire('action:chat.sent', { roomId, message, mid });
+ const payload = { roomId, message, mid };
+ // TODO: move this to success callback of api.post/put call?
+ hooks.fire('action:chat.sent', payload);
+ ({ roomId, message, mid } = await hooks.fire('filter:chat.send', payload));
if (!mid) {
api.post(`/chats/${roomId}`, { message }).catch((err) => {