return fd
}
+function lineFeedToHtml (obj: object, keyToNormalize: string) {
+ return immutableAssign(obj, {
+ [keyToNormalize]: obj[keyToNormalize].replace(/\r?\n|\r/g, '<br />')
+ })
+}
+
export {
viewportHeight,
getParameterByName,
isInSmallView,
isInMobileView,
immutableAssign,
- objectToFormData
+ objectToFormData,
+ lineFeedToHtml
}
private init () {
this.sanitizedCommentHTML = sanitizeHtml(this.comment.text, {
- allowedTags: [ 'p', 'span' ]
+ allowedTags: [ 'p', 'span', 'br' ]
})
this.newParentComments = this.parentComments.concat([ this.comment ])
import { Injectable } from '@angular/core'
import 'rxjs/add/operator/catch'
import 'rxjs/add/operator/map'
+import { immutableAssign, lineFeedToHtml } from '@app/shared/misc/utils'
import { Observable } from 'rxjs/Observable'
import { ResultList } from '../../../../../../shared/models'
import {
addCommentThread (videoId: number | string, comment: VideoCommentCreate) {
const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads'
+ const normalizedComment = lineFeedToHtml(comment, 'text')
- return this.authHttp.post(url, comment)
+ return this.authHttp.post(url, normalizedComment)
.map(data => this.extractVideoComment(data['comment']))
.catch(this.restExtractor.handleError)
}
addCommentReply (videoId: number | string, inReplyToCommentId: number, comment: VideoCommentCreate) {
const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comments/' + inReplyToCommentId
+ const normalizedComment = lineFeedToHtml(comment, 'text')
- return this.authHttp.post(url, comment)
+ return this.authHttp.post(url, normalizedComment)
.map(data => this.extractVideoComment(data['comment']))
.catch(this.restExtractor.handleError)
}
body('text').custom(isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking addVideoCommentThread parameters.', { parameters: req.params })
+ logger.debug('Checking addVideoCommentThread parameters.', { parameters: req.params, body: req.body })
if (areValidationErrors(req, res)) return
if (!await isVideoExist(req.params.videoId, res)) return
body('text').custom(isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking addVideoCommentReply parameters.', { parameters: req.params })
+ logger.debug('Checking addVideoCommentReply parameters.', { parameters: req.params, body: req.body })
if (areValidationErrors(req, res)) return
if (!await isVideoExist(req.params.videoId, res)) return