aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-18 10:53:54 +0100
committerChocobozzz <me@florianbigard.com>2018-01-18 15:42:20 +0100
commitf05a1c30c15d2ae35c11e241ca039a72eeb7d6ad (patch)
tree6d90c0de5dd3ad506e738d447e4f396951ed5624 /server/controllers/api/users.ts
parent1174a8479ab9ee47b3305d668fe757435057a298 (diff)
downloadPeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.gz
PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.zst
PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.zip
Don't show videos of remote instance after unfollow
Diffstat (limited to 'server/controllers/api/users.ts')
-rw-r--r--server/controllers/api/users.ts22
1 files changed, 14 insertions, 8 deletions
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'
13import { createUserAccountAndChannel } from '../../lib/user' 13import { createUserAccountAndChannel } from '../../lib/user'
14import { 14import {
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'
19import { usersUpdateMyAvatarValidator, videosSortValidator } from '../../middlewares/validators' 19import { 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
138async function createUser (req: express.Request) { 142async 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
155async function registerUserRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { 161async function registerUserRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) {