[IMPROVE] Check Livechat message length through REST API endpoint (#20366)

* Changed broken link for english

* checking msg len in api call

* Revert "Changed broken link for english"

This reverts commit 5c6e64cbe1.

* lint fixes

* if condn changes

Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com>
pull/20773/head^2
yash-rajpal 5 years ago committed by GitHub
parent 4f05c55948
commit 7eae419660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/livechat/server/api/v1/message.js

@ -9,6 +9,7 @@ import { loadMessageHistory } from '../../../../lib';
import { findGuest, findRoom, normalizeHttpHeaderData } from '../lib/livechat';
import { Livechat } from '../../lib/Livechat';
import { normalizeMessageFileUpload } from '../../../../utils/server/functions/normalizeMessageFileUpload';
import { settings } from '../../../../settings/server';
API.v1.addRoute('livechat/message', {
post() {
@ -40,6 +41,10 @@ API.v1.addRoute('livechat/message', {
throw new Meteor.Error('room-closed');
}
if (settings.get('Livechat_enable_message_character_limit') && msg.length > parseInt(settings.get('Livechat_message_character_limit'))) {
throw new Meteor.Error('message-length-exceeds-character-limit');
}
const _id = this.bodyParams._id || Random.id();
const sendMessage = {

Loading…
Cancel
Save