Merge branch 'master' into DepauMD

This commit is contained in:
Davide Depau 2018-09-28 03:00:10 +02:00
commit 3cb4d825c1
2 changed files with 11 additions and 2 deletions

View file

@ -104,7 +104,8 @@ module.exports = {
baseURL: undefined,
clientID: undefined,
clientSecret: undefined,
scope: undefined
scope: undefined,
version: 'v4'
},
mattermost: {
baseURL: undefined,

View file

@ -32,6 +32,9 @@ var response = {
errorBadRequest: function (res) {
responseError(res, '400', 'Bad Request', 'something not right.')
},
errorTooLong: function (res) {
responseError(res, '413', 'Payload Too Large', 'Shorten your note!')
},
errorInternalError: function (res) {
responseError(res, '500', 'Internal Error', 'wtf.')
},
@ -145,7 +148,12 @@ function responseCodiMD (res, note) {
function newNote (req, res, next) {
var owner = null
var body = req.body ? req.body : ''
var body = ''
if (req.body && req.body.length > config.documentMaxLength) {
return response.errorTooLong(res)
} else if (req.body) {
body = req.body
}
body = body.replace(/[\r]/g, '')
if (req.isAuthenticated()) {
owner = req.user.id