2017-12-22 02:14:50 -06:00
|
|
|
import * as validator from 'validator'
|
|
|
|
import { exists, isDateValid } from '../misc'
|
|
|
|
import { isActivityPubUrlValid, isBaseActivityValid } from './misc'
|
|
|
|
|
|
|
|
function isVideoCommentCreateActivityValid (activity: any) {
|
|
|
|
return isBaseActivityValid(activity, 'Create') &&
|
|
|
|
isVideoCommentObjectValid(activity.object)
|
|
|
|
}
|
|
|
|
|
|
|
|
function isVideoCommentObjectValid (comment: any) {
|
|
|
|
return comment.type === 'Note' &&
|
|
|
|
isActivityPubUrlValid(comment.id) &&
|
|
|
|
isCommentContentValid(comment.content) &&
|
|
|
|
isActivityPubUrlValid(comment.inReplyTo) &&
|
|
|
|
isDateValid(comment.published) &&
|
|
|
|
isActivityPubUrlValid(comment.url)
|
|
|
|
}
|
|
|
|
|
2018-01-04 04:19:16 -06:00
|
|
|
function isVideoCommentDeleteActivityValid (activity: any) {
|
|
|
|
return isBaseActivityValid(activity, 'Delete')
|
|
|
|
}
|
|
|
|
|
2017-12-22 02:14:50 -06:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
2018-01-04 04:19:16 -06:00
|
|
|
isVideoCommentCreateActivityValid,
|
|
|
|
isVideoCommentDeleteActivityValid
|
2017-12-22 02:14:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function isCommentContentValid (content: any) {
|
|
|
|
return exists(content) && validator.isLength('' + content, { min: 1 })
|
|
|
|
}
|