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