mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Continue activitypub
This commit is contained in:
parent
e4f97babf7
commit
0d0e8dd090
27 changed files with 1039 additions and 1086 deletions
34
server/helpers/custom-validators/activitypub/activity.ts
Normal file
34
server/helpers/custom-validators/activitypub/activity.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import * as validator from 'validator'
|
||||
import {
|
||||
isVideoChannelCreateActivityValid,
|
||||
isVideoTorrentAddActivityValid,
|
||||
isVideoTorrentUpdateActivityValid,
|
||||
isVideoChannelUpdateActivityValid
|
||||
} from './videos'
|
||||
|
||||
function isRootActivityValid (activity: any) {
|
||||
return Array.isArray(activity['@context']) &&
|
||||
(
|
||||
(activity.type === 'Collection' || activity.type === 'OrderedCollection') &&
|
||||
validator.isInt(activity.totalItems, { min: 0 }) &&
|
||||
Array.isArray(activity.items)
|
||||
) ||
|
||||
(
|
||||
validator.isURL(activity.id) &&
|
||||
validator.isURL(activity.actor)
|
||||
)
|
||||
}
|
||||
|
||||
function isActivityValid (activity: any) {
|
||||
return isVideoTorrentAddActivityValid(activity) ||
|
||||
isVideoChannelCreateActivityValid(activity) ||
|
||||
isVideoTorrentUpdateActivityValid(activity) ||
|
||||
isVideoChannelUpdateActivityValid(activity)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
isRootActivityValid,
|
||||
isActivityValid
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue