PeerTube/server/helpers/custom-validators/activitypub/video-channels.ts

31 lines
1.0 KiB
TypeScript
Raw Normal View History

2017-11-20 02:43:39 -06:00
import { isDateValid, isUUIDValid } from '../misc'
import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels'
import { isActivityPubUrlValid, isBaseActivityValid } from './misc'
function isVideoChannelUpdateActivityValid (activity: any) {
return isBaseActivityValid(activity, 'Update') &&
isVideoChannelObjectValid(activity.object)
}
function isVideoChannelDeleteActivityValid (activity: any) {
return isBaseActivityValid(activity, 'Delete')
}
function isVideoChannelObjectValid (videoChannel: any) {
return videoChannel.type === 'VideoChannel' &&
isActivityPubUrlValid(videoChannel.id) &&
isVideoChannelNameValid(videoChannel.name) &&
isVideoChannelDescriptionValid(videoChannel.content) &&
isDateValid(videoChannel.published) &&
isDateValid(videoChannel.updated) &&
isUUIDValid(videoChannel.uuid)
}
// ---------------------------------------------------------------------------
export {
isVideoChannelUpdateActivityValid,
isVideoChannelDeleteActivityValid,
isVideoChannelObjectValid
}