Relax activity validation
This commit is contained in:
parent
b767c4a74a
commit
4550872bcc
|
@ -12,18 +12,19 @@ import { isFlagActivityValid } from './flag'
|
|||
import { isPlaylistObjectValid } from './playlist'
|
||||
|
||||
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)
|
||||
) ||
|
||||
(
|
||||
isActivityPubUrlValid(activity.id) &&
|
||||
exists(activity.actor) &&
|
||||
(isActivityPubUrlValid(activity.actor) || isActivityPubUrlValid(activity.actor.id))
|
||||
)
|
||||
)
|
||||
return isCollection(activity) || isActivity(activity)
|
||||
}
|
||||
|
||||
function isCollection (activity: any) {
|
||||
return (activity.type === 'Collection' || activity.type === 'OrderedCollection') &&
|
||||
validator.isInt(activity.totalItems, { min: 0 }) &&
|
||||
Array.isArray(activity.items)
|
||||
}
|
||||
|
||||
function isActivity (activity: any) {
|
||||
return isActivityPubUrlValid(activity.id) &&
|
||||
exists(activity.actor) &&
|
||||
(isActivityPubUrlValid(activity.actor) || isActivityPubUrlValid(activity.actor.id))
|
||||
}
|
||||
|
||||
const activityCheckers: { [ P in ActivityType ]: (activity: Activity) => boolean } = {
|
||||
|
|
Loading…
Reference in New Issue