Skip to content

Commit

Permalink
[IMPROVE] Check Livechat message length through REST API endpoint (#2…
Browse files Browse the repository at this point in the history
…0366)

* Changed broken link for english

* checking msg len in api call

* Revert "Changed broken link for english"

This reverts commit 5c6e64c.

* lint fixes

* if condn changes

Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com>
  • Loading branch information
yash-rajpal and renatobecker authored Feb 15, 2021
1 parent 4f05c55 commit 7eae419
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/livechat/server/api/v1/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 7eae419

Please sign in to comment.