diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 23 | ||||
-rw-r--r-- | server/controllers/activitypub/inbox.ts | 14 | ||||
-rw-r--r-- | server/controllers/activitypub/outbox.ts | 13 | ||||
-rw-r--r-- | server/controllers/api/video-channel.ts | 23 |
4 files changed, 48 insertions, 25 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index c4e3cec6b..4e6bd5e25 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -20,7 +20,8 @@ import { | |||
20 | asyncMiddleware, | 20 | asyncMiddleware, |
21 | executeIfActivityPub, | 21 | executeIfActivityPub, |
22 | localAccountValidator, | 22 | localAccountValidator, |
23 | localVideoChannelValidator, | 23 | videoChannelsNameWithHostValidator, |
24 | ensureIsLocalChannel, | ||
24 | videosCustomGetValidator, | 25 | videosCustomGetValidator, |
25 | videosShareValidator | 26 | videosShareValidator |
26 | } from '../../middlewares' | 27 | } from '../../middlewares' |
@@ -123,24 +124,28 @@ activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity | |||
123 | ) | 124 | ) |
124 | 125 | ||
125 | activityPubClientRouter.get( | 126 | activityPubClientRouter.get( |
126 | [ '/video-channels/:name', '/video-channels/:name/videos', '/c/:name', '/c/:name/videos' ], | 127 | [ '/video-channels/:nameWithHost', '/video-channels/:nameWithHost/videos', '/c/:nameWithHost', '/c/:nameWithHost/videos' ], |
127 | executeIfActivityPub, | 128 | executeIfActivityPub, |
128 | asyncMiddleware(localVideoChannelValidator), | 129 | asyncMiddleware(videoChannelsNameWithHostValidator), |
130 | ensureIsLocalChannel, | ||
129 | videoChannelController | 131 | videoChannelController |
130 | ) | 132 | ) |
131 | activityPubClientRouter.get('/video-channels/:name/followers', | 133 | activityPubClientRouter.get('/video-channels/:nameWithHost/followers', |
132 | executeIfActivityPub, | 134 | executeIfActivityPub, |
133 | asyncMiddleware(localVideoChannelValidator), | 135 | asyncMiddleware(videoChannelsNameWithHostValidator), |
136 | ensureIsLocalChannel, | ||
134 | asyncMiddleware(videoChannelFollowersController) | 137 | asyncMiddleware(videoChannelFollowersController) |
135 | ) | 138 | ) |
136 | activityPubClientRouter.get('/video-channels/:name/following', | 139 | activityPubClientRouter.get('/video-channels/:nameWithHost/following', |
137 | executeIfActivityPub, | 140 | executeIfActivityPub, |
138 | asyncMiddleware(localVideoChannelValidator), | 141 | asyncMiddleware(videoChannelsNameWithHostValidator), |
142 | ensureIsLocalChannel, | ||
139 | asyncMiddleware(videoChannelFollowingController) | 143 | asyncMiddleware(videoChannelFollowingController) |
140 | ) | 144 | ) |
141 | activityPubClientRouter.get('/video-channels/:name/playlists', | 145 | activityPubClientRouter.get('/video-channels/:nameWithHost/playlists', |
142 | executeIfActivityPub, | 146 | executeIfActivityPub, |
143 | asyncMiddleware(localVideoChannelValidator), | 147 | asyncMiddleware(videoChannelsNameWithHostValidator), |
148 | ensureIsLocalChannel, | ||
144 | asyncMiddleware(videoChannelPlaylistsController) | 149 | asyncMiddleware(videoChannelPlaylistsController) |
145 | ) | 150 | ) |
146 | 151 | ||
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts index ece4edff0..5995b8f3a 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/controllers/activitypub/inbox.ts | |||
@@ -4,7 +4,14 @@ import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActi | |||
4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
5 | import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' | 5 | import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
7 | import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares' | 7 | import { |
8 | asyncMiddleware, | ||
9 | checkSignature, | ||
10 | ensureIsLocalChannel, | ||
11 | localAccountValidator, | ||
12 | signatureValidator, | ||
13 | videoChannelsNameWithHostValidator | ||
14 | } from '../../middlewares' | ||
8 | import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' | 15 | import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' |
9 | 16 | ||
10 | const inboxRouter = express.Router() | 17 | const inboxRouter = express.Router() |
@@ -23,10 +30,11 @@ inboxRouter.post('/accounts/:name/inbox', | |||
23 | asyncMiddleware(activityPubValidator), | 30 | asyncMiddleware(activityPubValidator), |
24 | inboxController | 31 | inboxController |
25 | ) | 32 | ) |
26 | inboxRouter.post('/video-channels/:name/inbox', | 33 | inboxRouter.post('/video-channels/:nameWithHost/inbox', |
27 | signatureValidator, | 34 | signatureValidator, |
28 | asyncMiddleware(checkSignature), | 35 | asyncMiddleware(checkSignature), |
29 | asyncMiddleware(localVideoChannelValidator), | 36 | asyncMiddleware(videoChannelsNameWithHostValidator), |
37 | ensureIsLocalChannel, | ||
30 | asyncMiddleware(activityPubValidator), | 38 | asyncMiddleware(activityPubValidator), |
31 | inboxController | 39 | inboxController |
32 | ) | 40 | ) |
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts index bdf9d138b..cdef8e969 100644 --- a/server/controllers/activitypub/outbox.ts +++ b/server/controllers/activitypub/outbox.ts | |||
@@ -1,15 +1,15 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { MActorLight } from '@server/types/models' | ||
2 | import { Activity } from '../../../shared/models/activitypub/activity' | 3 | import { Activity } from '../../../shared/models/activitypub/activity' |
3 | import { VideoPrivacy } from '../../../shared/models/videos' | 4 | import { VideoPrivacy } from '../../../shared/models/videos' |
4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' | 5 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' |
5 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
6 | import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send' | ||
7 | import { buildAudience } from '../../lib/activitypub/audience' | 7 | import { buildAudience } from '../../lib/activitypub/audience' |
8 | import { asyncMiddleware, localAccountValidator, localVideoChannelValidator } from '../../middlewares' | 8 | import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send' |
9 | import { asyncMiddleware, ensureIsLocalChannel, localAccountValidator, videoChannelsNameWithHostValidator } from '../../middlewares' | ||
10 | import { apPaginationValidator } from '../../middlewares/validators/activitypub' | ||
9 | import { VideoModel } from '../../models/video/video' | 11 | import { VideoModel } from '../../models/video/video' |
10 | import { activityPubResponse } from './utils' | 12 | import { activityPubResponse } from './utils' |
11 | import { MActorLight } from '@server/types/models' | ||
12 | import { apPaginationValidator } from '../../middlewares/validators/activitypub' | ||
13 | 13 | ||
14 | const outboxRouter = express.Router() | 14 | const outboxRouter = express.Router() |
15 | 15 | ||
@@ -19,9 +19,10 @@ outboxRouter.get('/accounts/:name/outbox', | |||
19 | asyncMiddleware(outboxController) | 19 | asyncMiddleware(outboxController) |
20 | ) | 20 | ) |
21 | 21 | ||
22 | outboxRouter.get('/video-channels/:name/outbox', | 22 | outboxRouter.get('/video-channels/:nameWithHost/outbox', |
23 | apPaginationValidator, | 23 | apPaginationValidator, |
24 | localVideoChannelValidator, | 24 | asyncMiddleware(videoChannelsNameWithHostValidator), |
25 | ensureIsLocalChannel, | ||
25 | asyncMiddleware(outboxController) | 26 | asyncMiddleware(outboxController) |
26 | ) | 27 | ) |
27 | 28 | ||
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index d1a1e6473..abb777e08 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -24,6 +24,7 @@ import { | |||
24 | asyncRetryTransactionMiddleware, | 24 | asyncRetryTransactionMiddleware, |
25 | authenticate, | 25 | authenticate, |
26 | commonVideosFiltersValidator, | 26 | commonVideosFiltersValidator, |
27 | ensureCanManageChannel, | ||
27 | optionalAuthenticate, | 28 | optionalAuthenticate, |
28 | paginationValidator, | 29 | paginationValidator, |
29 | setDefaultPagination, | 30 | setDefaultPagination, |
@@ -36,7 +37,7 @@ import { | |||
36 | videoPlaylistsSortValidator | 37 | videoPlaylistsSortValidator |
37 | } from '../../middlewares' | 38 | } from '../../middlewares' |
38 | import { | 39 | import { |
39 | ensureAuthUserOwnsChannelValidator, | 40 | ensureIsLocalChannel, |
40 | videoChannelsFollowersSortValidator, | 41 | videoChannelsFollowersSortValidator, |
41 | videoChannelsListValidator, | 42 | videoChannelsListValidator, |
42 | videoChannelsNameWithHostValidator, | 43 | videoChannelsNameWithHostValidator, |
@@ -74,7 +75,8 @@ videoChannelRouter.post('/:nameWithHost/avatar/pick', | |||
74 | authenticate, | 75 | authenticate, |
75 | reqAvatarFile, | 76 | reqAvatarFile, |
76 | asyncMiddleware(videoChannelsNameWithHostValidator), | 77 | asyncMiddleware(videoChannelsNameWithHostValidator), |
77 | ensureAuthUserOwnsChannelValidator, | 78 | ensureIsLocalChannel, |
79 | ensureCanManageChannel, | ||
78 | updateAvatarValidator, | 80 | updateAvatarValidator, |
79 | asyncMiddleware(updateVideoChannelAvatar) | 81 | asyncMiddleware(updateVideoChannelAvatar) |
80 | ) | 82 | ) |
@@ -83,7 +85,8 @@ videoChannelRouter.post('/:nameWithHost/banner/pick', | |||
83 | authenticate, | 85 | authenticate, |
84 | reqBannerFile, | 86 | reqBannerFile, |
85 | asyncMiddleware(videoChannelsNameWithHostValidator), | 87 | asyncMiddleware(videoChannelsNameWithHostValidator), |
86 | ensureAuthUserOwnsChannelValidator, | 88 | ensureIsLocalChannel, |
89 | ensureCanManageChannel, | ||
87 | updateBannerValidator, | 90 | updateBannerValidator, |
88 | asyncMiddleware(updateVideoChannelBanner) | 91 | asyncMiddleware(updateVideoChannelBanner) |
89 | ) | 92 | ) |
@@ -91,27 +94,33 @@ videoChannelRouter.post('/:nameWithHost/banner/pick', | |||
91 | videoChannelRouter.delete('/:nameWithHost/avatar', | 94 | videoChannelRouter.delete('/:nameWithHost/avatar', |
92 | authenticate, | 95 | authenticate, |
93 | asyncMiddleware(videoChannelsNameWithHostValidator), | 96 | asyncMiddleware(videoChannelsNameWithHostValidator), |
94 | ensureAuthUserOwnsChannelValidator, | 97 | ensureIsLocalChannel, |
98 | ensureCanManageChannel, | ||
95 | asyncMiddleware(deleteVideoChannelAvatar) | 99 | asyncMiddleware(deleteVideoChannelAvatar) |
96 | ) | 100 | ) |
97 | 101 | ||
98 | videoChannelRouter.delete('/:nameWithHost/banner', | 102 | videoChannelRouter.delete('/:nameWithHost/banner', |
99 | authenticate, | 103 | authenticate, |
100 | asyncMiddleware(videoChannelsNameWithHostValidator), | 104 | asyncMiddleware(videoChannelsNameWithHostValidator), |
101 | ensureAuthUserOwnsChannelValidator, | 105 | ensureIsLocalChannel, |
106 | ensureCanManageChannel, | ||
102 | asyncMiddleware(deleteVideoChannelBanner) | 107 | asyncMiddleware(deleteVideoChannelBanner) |
103 | ) | 108 | ) |
104 | 109 | ||
105 | videoChannelRouter.put('/:nameWithHost', | 110 | videoChannelRouter.put('/:nameWithHost', |
106 | authenticate, | 111 | authenticate, |
107 | asyncMiddleware(videoChannelsNameWithHostValidator), | 112 | asyncMiddleware(videoChannelsNameWithHostValidator), |
108 | ensureAuthUserOwnsChannelValidator, | 113 | ensureIsLocalChannel, |
114 | ensureCanManageChannel, | ||
109 | videoChannelsUpdateValidator, | 115 | videoChannelsUpdateValidator, |
110 | asyncRetryTransactionMiddleware(updateVideoChannel) | 116 | asyncRetryTransactionMiddleware(updateVideoChannel) |
111 | ) | 117 | ) |
112 | 118 | ||
113 | videoChannelRouter.delete('/:nameWithHost', | 119 | videoChannelRouter.delete('/:nameWithHost', |
114 | authenticate, | 120 | authenticate, |
121 | asyncMiddleware(videoChannelsNameWithHostValidator), | ||
122 | ensureIsLocalChannel, | ||
123 | ensureCanManageChannel, | ||
115 | asyncMiddleware(videoChannelsRemoveValidator), | 124 | asyncMiddleware(videoChannelsRemoveValidator), |
116 | asyncRetryTransactionMiddleware(removeVideoChannel) | 125 | asyncRetryTransactionMiddleware(removeVideoChannel) |
117 | ) | 126 | ) |
@@ -145,7 +154,7 @@ videoChannelRouter.get('/:nameWithHost/videos', | |||
145 | videoChannelRouter.get('/:nameWithHost/followers', | 154 | videoChannelRouter.get('/:nameWithHost/followers', |
146 | authenticate, | 155 | authenticate, |
147 | asyncMiddleware(videoChannelsNameWithHostValidator), | 156 | asyncMiddleware(videoChannelsNameWithHostValidator), |
148 | ensureAuthUserOwnsChannelValidator, | 157 | ensureCanManageChannel, |
149 | paginationValidator, | 158 | paginationValidator, |
150 | videoChannelsFollowersSortValidator, | 159 | videoChannelsFollowersSortValidator, |
151 | setDefaultSort, | 160 | setDefaultSort, |