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:
@@ -7,9 +7,9 @@ define('forum/chats/messages', [
|
|||||||
], function (components, translator, Benchpress, hooks, bootbox, alerts, messagesModule, api) {
|
], function (components, translator, Benchpress, hooks, bootbox, alerts, messagesModule, api) {
|
||||||
const messages = {};
|
const messages = {};
|
||||||
|
|
||||||
messages.sendMessage = function (roomId, inputEl) {
|
messages.sendMessage = async function (roomId, inputEl) {
|
||||||
const message = inputEl.val();
|
let message = inputEl.val();
|
||||||
const mid = inputEl.attr('data-mid');
|
let mid = inputEl.attr('data-mid');
|
||||||
|
|
||||||
if (!message.trim().length) {
|
if (!message.trim().length) {
|
||||||
return;
|
return;
|
||||||
@@ -18,7 +18,10 @@ define('forum/chats/messages', [
|
|||||||
inputEl.val('');
|
inputEl.val('');
|
||||||
inputEl.removeAttr('data-mid');
|
inputEl.removeAttr('data-mid');
|
||||||
messages.updateRemainingLength(inputEl.parent());
|
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) {
|
if (!mid) {
|
||||||
api.post(`/chats/${roomId}`, { message }).catch((err) => {
|
api.post(`/chats/${roomId}`, { message }).catch((err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user