diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/accounts.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/jobs.ts | 7 | ||||
-rw-r--r-- | server/controllers/api/server/follows.ts | 6 | ||||
-rw-r--r-- | server/controllers/api/users.ts | 22 | ||||
-rw-r--r-- | server/controllers/api/videos/abuse.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/blacklist.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/channel.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/comment.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 6 |
9 files changed, 35 insertions, 26 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts index 3bc929db8..4dc0cc16d 100644 --- a/server/controllers/api/accounts.ts +++ b/server/controllers/api/accounts.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { getFormattedObjects } from '../../helpers/utils' | 2 | import { getFormattedObjects } from '../../helpers/utils' |
3 | import { asyncMiddleware, paginationValidator, setDefaultSort, setPagination } from '../../middlewares' | 3 | import { asyncMiddleware, paginationValidator, setDefaultSort, setDefaultPagination } from '../../middlewares' |
4 | import { accountsGetValidator, accountsSortValidator } from '../../middlewares/validators' | 4 | import { accountsGetValidator, accountsSortValidator } from '../../middlewares/validators' |
5 | import { AccountModel } from '../../models/account/account' | 5 | import { AccountModel } from '../../models/account/account' |
6 | 6 | ||
@@ -10,7 +10,7 @@ accountsRouter.get('/', | |||
10 | paginationValidator, | 10 | paginationValidator, |
11 | accountsSortValidator, | 11 | accountsSortValidator, |
12 | setDefaultSort, | 12 | setDefaultSort, |
13 | setPagination, | 13 | setDefaultPagination, |
14 | asyncMiddleware(listAccounts) | 14 | asyncMiddleware(listAccounts) |
15 | ) | 15 | ) |
16 | 16 | ||
diff --git a/server/controllers/api/jobs.ts b/server/controllers/api/jobs.ts index 180a3fca6..de37dea39 100644 --- a/server/controllers/api/jobs.ts +++ b/server/controllers/api/jobs.ts | |||
@@ -1,7 +1,10 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { UserRight } from '../../../shared/models/users' | 2 | import { UserRight } from '../../../shared/models/users' |
3 | import { getFormattedObjects } from '../../helpers/utils' | 3 | import { getFormattedObjects } from '../../helpers/utils' |
4 | import { asyncMiddleware, authenticate, ensureUserHasRight, jobsSortValidator, setDefaultSort, setPagination } from '../../middlewares' | 4 | import { |
5 | asyncMiddleware, authenticate, ensureUserHasRight, jobsSortValidator, setDefaultPagination, | ||
6 | setDefaultSort | ||
7 | } from '../../middlewares' | ||
5 | import { paginationValidator } from '../../middlewares/validators' | 8 | import { paginationValidator } from '../../middlewares/validators' |
6 | import { JobModel } from '../../models/job/job' | 9 | import { JobModel } from '../../models/job/job' |
7 | 10 | ||
@@ -13,7 +16,7 @@ jobsRouter.get('/', | |||
13 | paginationValidator, | 16 | paginationValidator, |
14 | jobsSortValidator, | 17 | jobsSortValidator, |
15 | setDefaultSort, | 18 | setDefaultSort, |
16 | setPagination, | 19 | setDefaultPagination, |
17 | asyncMiddleware(listJobs) | 20 | asyncMiddleware(listJobs) |
18 | ) | 21 | ) |
19 | 22 | ||
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 0fbcc4b80..40b62d977 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts | |||
@@ -10,7 +10,7 @@ import { getOrCreateActorAndServerAndModel } from '../../../lib/activitypub/acto | |||
10 | import { sendFollow, sendUndoFollow } from '../../../lib/activitypub/send' | 10 | import { sendFollow, sendUndoFollow } from '../../../lib/activitypub/send' |
11 | import { | 11 | import { |
12 | asyncMiddleware, authenticate, ensureUserHasRight, paginationValidator, removeFollowingValidator, setBodyHostsPort, setDefaultSort, | 12 | asyncMiddleware, authenticate, ensureUserHasRight, paginationValidator, removeFollowingValidator, setBodyHostsPort, setDefaultSort, |
13 | setPagination | 13 | setDefaultPagination |
14 | } from '../../../middlewares' | 14 | } from '../../../middlewares' |
15 | import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators' | 15 | import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators' |
16 | import { ActorModel } from '../../../models/activitypub/actor' | 16 | import { ActorModel } from '../../../models/activitypub/actor' |
@@ -22,7 +22,7 @@ serverFollowsRouter.get('/following', | |||
22 | paginationValidator, | 22 | paginationValidator, |
23 | followingSortValidator, | 23 | followingSortValidator, |
24 | setDefaultSort, | 24 | setDefaultSort, |
25 | setPagination, | 25 | setDefaultPagination, |
26 | asyncMiddleware(listFollowing) | 26 | asyncMiddleware(listFollowing) |
27 | ) | 27 | ) |
28 | 28 | ||
@@ -45,7 +45,7 @@ serverFollowsRouter.get('/followers', | |||
45 | paginationValidator, | 45 | paginationValidator, |
46 | followersSortValidator, | 46 | followersSortValidator, |
47 | setDefaultSort, | 47 | setDefaultSort, |
48 | setPagination, | 48 | setDefaultPagination, |
49 | asyncMiddleware(listFollowers) | 49 | asyncMiddleware(listFollowers) |
50 | ) | 50 | ) |
51 | 51 | ||
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index 0ca9b337a..aced4639e 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts | |||
@@ -13,7 +13,7 @@ import { sendUpdateUser } from '../../lib/activitypub/send' | |||
13 | import { createUserAccountAndChannel } from '../../lib/user' | 13 | import { createUserAccountAndChannel } from '../../lib/user' |
14 | import { | 14 | import { |
15 | asyncMiddleware, authenticate, ensureUserHasRight, ensureUserRegistrationAllowed, paginationValidator, setDefaultSort, | 15 | asyncMiddleware, authenticate, ensureUserHasRight, ensureUserRegistrationAllowed, paginationValidator, setDefaultSort, |
16 | setPagination, token, usersAddValidator, usersGetValidator, usersRegisterValidator, usersRemoveValidator, usersSortValidator, | 16 | setDefaultPagination, token, usersAddValidator, usersGetValidator, usersRegisterValidator, usersRemoveValidator, usersSortValidator, |
17 | usersUpdateMeValidator, usersUpdateValidator, usersVideoRatingValidator | 17 | usersUpdateMeValidator, usersUpdateValidator, usersVideoRatingValidator |
18 | } from '../../middlewares' | 18 | } from '../../middlewares' |
19 | import { usersUpdateMyAvatarValidator, videosSortValidator } from '../../middlewares/validators' | 19 | import { usersUpdateMyAvatarValidator, videosSortValidator } from '../../middlewares/validators' |
@@ -40,7 +40,7 @@ usersRouter.get('/me/videos', | |||
40 | paginationValidator, | 40 | paginationValidator, |
41 | videosSortValidator, | 41 | videosSortValidator, |
42 | setDefaultSort, | 42 | setDefaultSort, |
43 | setPagination, | 43 | setDefaultPagination, |
44 | asyncMiddleware(getUserVideos) | 44 | asyncMiddleware(getUserVideos) |
45 | ) | 45 | ) |
46 | 46 | ||
@@ -56,7 +56,7 @@ usersRouter.get('/', | |||
56 | paginationValidator, | 56 | paginationValidator, |
57 | usersSortValidator, | 57 | usersSortValidator, |
58 | setDefaultSort, | 58 | setDefaultSort, |
59 | setPagination, | 59 | setDefaultPagination, |
60 | asyncMiddleware(listUsers) | 60 | asyncMiddleware(listUsers) |
61 | ) | 61 | ) |
62 | 62 | ||
@@ -129,15 +129,19 @@ async function createUserRetryWrapper (req: express.Request, res: express.Respon | |||
129 | errorMessage: 'Cannot insert the user with many retries.' | 129 | errorMessage: 'Cannot insert the user with many retries.' |
130 | } | 130 | } |
131 | 131 | ||
132 | await retryTransactionWrapper(createUser, options) | 132 | const { user, account } = await retryTransactionWrapper(createUser, options) |
133 | 133 | ||
134 | // TODO : include Location of the new user -> 201 | 134 | return res.json({ |
135 | return res.type('json').status(204).end() | 135 | user: { |
136 | id: user.id, | ||
137 | uuid: account.uuid | ||
138 | } | ||
139 | }).end() | ||
136 | } | 140 | } |
137 | 141 | ||
138 | async function createUser (req: express.Request) { | 142 | async function createUser (req: express.Request) { |
139 | const body: UserCreate = req.body | 143 | const body: UserCreate = req.body |
140 | const user = new UserModel({ | 144 | const userToCreate = new UserModel({ |
141 | username: body.username, | 145 | username: body.username, |
142 | password: body.password, | 146 | password: body.password, |
143 | email: body.email, | 147 | email: body.email, |
@@ -147,9 +151,11 @@ async function createUser (req: express.Request) { | |||
147 | videoQuota: body.videoQuota | 151 | videoQuota: body.videoQuota |
148 | }) | 152 | }) |
149 | 153 | ||
150 | await createUserAccountAndChannel(user) | 154 | const { user, account } = await createUserAccountAndChannel(userToCreate) |
151 | 155 | ||
152 | logger.info('User %s with its channel and account created.', body.username) | 156 | logger.info('User %s with its channel and account created.', body.username) |
157 | |||
158 | return { user, account } | ||
153 | } | 159 | } |
154 | 160 | ||
155 | async function registerUserRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { | 161 | async function registerUserRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { |
diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts index 91594490b..61ff3af4f 100644 --- a/server/controllers/api/videos/abuse.ts +++ b/server/controllers/api/videos/abuse.ts | |||
@@ -6,7 +6,7 @@ import { getFormattedObjects } from '../../../helpers/utils' | |||
6 | import { sequelizeTypescript } from '../../../initializers' | 6 | import { sequelizeTypescript } from '../../../initializers' |
7 | import { sendVideoAbuse } from '../../../lib/activitypub/send' | 7 | import { sendVideoAbuse } from '../../../lib/activitypub/send' |
8 | import { | 8 | import { |
9 | asyncMiddleware, authenticate, ensureUserHasRight, paginationValidator, setDefaultSort, setPagination, videoAbuseReportValidator, | 9 | asyncMiddleware, authenticate, ensureUserHasRight, paginationValidator, setDefaultSort, setDefaultPagination, videoAbuseReportValidator, |
10 | videoAbusesSortValidator | 10 | videoAbusesSortValidator |
11 | } from '../../../middlewares' | 11 | } from '../../../middlewares' |
12 | import { AccountModel } from '../../../models/account/account' | 12 | import { AccountModel } from '../../../models/account/account' |
@@ -21,7 +21,7 @@ abuseVideoRouter.get('/abuse', | |||
21 | paginationValidator, | 21 | paginationValidator, |
22 | videoAbusesSortValidator, | 22 | videoAbusesSortValidator, |
23 | setDefaultSort, | 23 | setDefaultSort, |
24 | setPagination, | 24 | setDefaultPagination, |
25 | asyncMiddleware(listVideoAbuses) | 25 | asyncMiddleware(listVideoAbuses) |
26 | ) | 26 | ) |
27 | abuseVideoRouter.post('/:id/abuse', | 27 | abuseVideoRouter.post('/:id/abuse', |
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index c9087fd97..7eee460d4 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts | |||
@@ -3,7 +3,7 @@ import { BlacklistedVideo, UserRight } from '../../../../shared' | |||
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { getFormattedObjects } from '../../../helpers/utils' | 4 | import { getFormattedObjects } from '../../../helpers/utils' |
5 | import { | 5 | import { |
6 | asyncMiddleware, authenticate, blacklistSortValidator, ensureUserHasRight, paginationValidator, setBlacklistSort, setPagination, | 6 | asyncMiddleware, authenticate, blacklistSortValidator, ensureUserHasRight, paginationValidator, setBlacklistSort, setDefaultPagination, |
7 | videosBlacklistAddValidator, videosBlacklistRemoveValidator | 7 | videosBlacklistAddValidator, videosBlacklistRemoveValidator |
8 | } from '../../../middlewares' | 8 | } from '../../../middlewares' |
9 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | 9 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' |
@@ -23,7 +23,7 @@ blacklistRouter.get('/blacklist', | |||
23 | paginationValidator, | 23 | paginationValidator, |
24 | blacklistSortValidator, | 24 | blacklistSortValidator, |
25 | setBlacklistSort, | 25 | setBlacklistSort, |
26 | setPagination, | 26 | setDefaultPagination, |
27 | asyncMiddleware(listBlacklist) | 27 | asyncMiddleware(listBlacklist) |
28 | ) | 28 | ) |
29 | 29 | ||
diff --git a/server/controllers/api/videos/channel.ts b/server/controllers/api/videos/channel.ts index 2012575c8..8ec53d9ae 100644 --- a/server/controllers/api/videos/channel.ts +++ b/server/controllers/api/videos/channel.ts | |||
@@ -7,7 +7,7 @@ import { sequelizeTypescript } from '../../../initializers' | |||
7 | import { setAsyncActorKeys } from '../../../lib/activitypub' | 7 | import { setAsyncActorKeys } from '../../../lib/activitypub' |
8 | import { createVideoChannel } from '../../../lib/video-channel' | 8 | import { createVideoChannel } from '../../../lib/video-channel' |
9 | import { | 9 | import { |
10 | asyncMiddleware, authenticate, listVideoAccountChannelsValidator, paginationValidator, setDefaultSort, setPagination, | 10 | asyncMiddleware, authenticate, listVideoAccountChannelsValidator, paginationValidator, setDefaultSort, setDefaultPagination, |
11 | videoChannelsAddValidator, videoChannelsGetValidator, videoChannelsRemoveValidator, videoChannelsSortValidator, | 11 | videoChannelsAddValidator, videoChannelsGetValidator, videoChannelsRemoveValidator, videoChannelsSortValidator, |
12 | videoChannelsUpdateValidator | 12 | videoChannelsUpdateValidator |
13 | } from '../../../middlewares' | 13 | } from '../../../middlewares' |
@@ -20,7 +20,7 @@ videoChannelRouter.get('/channels', | |||
20 | paginationValidator, | 20 | paginationValidator, |
21 | videoChannelsSortValidator, | 21 | videoChannelsSortValidator, |
22 | setDefaultSort, | 22 | setDefaultSort, |
23 | setPagination, | 23 | setDefaultPagination, |
24 | asyncMiddleware(listVideoChannels) | 24 | asyncMiddleware(listVideoChannels) |
25 | ) | 25 | ) |
26 | 26 | ||
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index 3c2727530..f8a669e35 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts | |||
@@ -6,7 +6,7 @@ import { logger } from '../../../helpers/logger' | |||
6 | import { getFormattedObjects } from '../../../helpers/utils' | 6 | import { getFormattedObjects } from '../../../helpers/utils' |
7 | import { sequelizeTypescript } from '../../../initializers' | 7 | import { sequelizeTypescript } from '../../../initializers' |
8 | import { buildFormattedCommentTree, createVideoComment } from '../../../lib/video-comment' | 8 | import { buildFormattedCommentTree, createVideoComment } from '../../../lib/video-comment' |
9 | import { asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setPagination } from '../../../middlewares' | 9 | import { asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setDefaultPagination } from '../../../middlewares' |
10 | import { videoCommentThreadsSortValidator } from '../../../middlewares/validators' | 10 | import { videoCommentThreadsSortValidator } from '../../../middlewares/validators' |
11 | import { | 11 | import { |
12 | addVideoCommentReplyValidator, addVideoCommentThreadValidator, listVideoCommentThreadsValidator, listVideoThreadCommentsValidator, | 12 | addVideoCommentReplyValidator, addVideoCommentThreadValidator, listVideoCommentThreadsValidator, listVideoThreadCommentsValidator, |
@@ -21,7 +21,7 @@ videoCommentRouter.get('/:videoId/comment-threads', | |||
21 | paginationValidator, | 21 | paginationValidator, |
22 | videoCommentThreadsSortValidator, | 22 | videoCommentThreadsSortValidator, |
23 | setDefaultSort, | 23 | setDefaultSort, |
24 | setPagination, | 24 | setDefaultPagination, |
25 | asyncMiddleware(listVideoCommentThreadsValidator), | 25 | asyncMiddleware(listVideoCommentThreadsValidator), |
26 | asyncMiddleware(listVideoThreads) | 26 | asyncMiddleware(listVideoThreads) |
27 | ) | 27 | ) |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 6a7f1f184..c2fdb4f95 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -14,7 +14,7 @@ import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServer | |||
14 | import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' | 14 | import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' |
15 | import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler' | 15 | import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler' |
16 | import { | 16 | import { |
17 | asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setPagination, videosAddValidator, videosGetValidator, | 17 | asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setDefaultPagination, videosAddValidator, videosGetValidator, |
18 | videosRemoveValidator, videosSearchValidator, videosSortValidator, videosUpdateValidator | 18 | videosRemoveValidator, videosSearchValidator, videosSortValidator, videosUpdateValidator |
19 | } from '../../../middlewares' | 19 | } from '../../../middlewares' |
20 | import { TagModel } from '../../../models/video/tag' | 20 | import { TagModel } from '../../../models/video/tag' |
@@ -45,7 +45,7 @@ videosRouter.get('/', | |||
45 | paginationValidator, | 45 | paginationValidator, |
46 | videosSortValidator, | 46 | videosSortValidator, |
47 | setDefaultSort, | 47 | setDefaultSort, |
48 | setPagination, | 48 | setDefaultPagination, |
49 | asyncMiddleware(listVideos) | 49 | asyncMiddleware(listVideos) |
50 | ) | 50 | ) |
51 | videosRouter.get('/search', | 51 | videosRouter.get('/search', |
@@ -53,7 +53,7 @@ videosRouter.get('/search', | |||
53 | paginationValidator, | 53 | paginationValidator, |
54 | videosSortValidator, | 54 | videosSortValidator, |
55 | setDefaultSort, | 55 | setDefaultSort, |
56 | setPagination, | 56 | setDefaultPagination, |
57 | asyncMiddleware(searchVideos) | 57 | asyncMiddleware(searchVideos) |
58 | ) | 58 | ) |
59 | videosRouter.put('/:id', | 59 | videosRouter.put('/:id', |