aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/activitypub/activity.ts4
-rw-r--r--server/helpers/custom-validators/activitypub/index.ts1
-rw-r--r--server/helpers/custom-validators/activitypub/videos.ts2
-rw-r--r--server/helpers/custom-validators/activitypub/view.ts13
4 files changed, 18 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/helpers/custom-validators/activitypub/activity.ts
index 9305e092c..66e557d39 100644
--- a/server/helpers/custom-validators/activitypub/activity.ts
+++ b/server/helpers/custom-validators/activitypub/activity.ts
@@ -11,6 +11,7 @@ import {
11 isVideoTorrentDeleteActivityValid, 11 isVideoTorrentDeleteActivityValid,
12 isVideoTorrentUpdateActivityValid 12 isVideoTorrentUpdateActivityValid
13} from './videos' 13} from './videos'
14import { isViewActivityValid } from './view'
14 15
15function isRootActivityValid (activity: any) { 16function isRootActivityValid (activity: any) {
16 return Array.isArray(activity['@context']) && 17 return Array.isArray(activity['@context']) &&
@@ -55,7 +56,8 @@ export {
55 56
56function checkCreateActivity (activity: any) { 57function checkCreateActivity (activity: any) {
57 return isVideoChannelCreateActivityValid(activity) || 58 return isVideoChannelCreateActivityValid(activity) ||
58 isVideoFlagValid(activity) 59 isVideoFlagValid(activity) ||
60 isViewActivityValid(activity)
59} 61}
60 62
61function checkAddActivity (activity: any) { 63function checkAddActivity (activity: any) {
diff --git a/server/helpers/custom-validators/activitypub/index.ts b/server/helpers/custom-validators/activitypub/index.ts
index 6685b269f..f8dfae4ff 100644
--- a/server/helpers/custom-validators/activitypub/index.ts
+++ b/server/helpers/custom-validators/activitypub/index.ts
@@ -5,3 +5,4 @@ export * from './signature'
5export * from './undo' 5export * from './undo'
6export * from './video-channels' 6export * from './video-channels'
7export * from './videos' 7export * from './videos'
8export * from './view'
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts
index faeedd3df..55e79c4e8 100644
--- a/server/helpers/custom-validators/activitypub/videos.ts
+++ b/server/helpers/custom-validators/activitypub/videos.ts
@@ -52,7 +52,7 @@ function isVideoTorrentObjectValid (video: any) {
52 setValidRemoteTags(video) && 52 setValidRemoteTags(video) &&
53 isRemoteIdentifierValid(video.category) && 53 isRemoteIdentifierValid(video.category) &&
54 isRemoteIdentifierValid(video.licence) && 54 isRemoteIdentifierValid(video.licence) &&
55 isRemoteIdentifierValid(video.language) && 55 (!video.language || isRemoteIdentifierValid(video.language)) &&
56 isVideoViewsValid(video.views) && 56 isVideoViewsValid(video.views) &&
57 isVideoNSFWValid(video.nsfw) && 57 isVideoNSFWValid(video.nsfw) &&
58 isDateValid(video.published) && 58 isDateValid(video.published) &&
diff --git a/server/helpers/custom-validators/activitypub/view.ts b/server/helpers/custom-validators/activitypub/view.ts
new file mode 100644
index 000000000..7a3aca6f5
--- /dev/null
+++ b/server/helpers/custom-validators/activitypub/view.ts
@@ -0,0 +1,13 @@
1import { isActivityPubUrlValid, isBaseActivityValid } from './misc'
2
3function isViewActivityValid (activity: any) {
4 return isBaseActivityValid(activity, 'Create') &&
5 activity.object.type === 'View' &&
6 isActivityPubUrlValid(activity.object.actor) &&
7 isActivityPubUrlValid(activity.object.object)
8}
9// ---------------------------------------------------------------------------
10
11export {
12 isViewActivityValid
13}