mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: add client side filter:chat.send, closes #10729
This commit is contained in:
committed by
Julian Lam
parent
56372fb618
commit
b2da02d676
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user