From f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Jan 2018 10:53:54 +0100 Subject: Don't show videos of remote instance after unfollow --- server/controllers/api/users.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'server/controllers/api/users.ts') 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' import { createUserAccountAndChannel } from '../../lib/user' import { asyncMiddleware, authenticate, ensureUserHasRight, ensureUserRegistrationAllowed, paginationValidator, setDefaultSort, - setPagination, token, usersAddValidator, usersGetValidator, usersRegisterValidator, usersRemoveValidator, usersSortValidator, + setDefaultPagination, token, usersAddValidator, usersGetValidator, usersRegisterValidator, usersRemoveValidator, usersSortValidator, usersUpdateMeValidator, usersUpdateValidator, usersVideoRatingValidator } from '../../middlewares' import { usersUpdateMyAvatarValidator, videosSortValidator } from '../../middlewares/validators' @@ -40,7 +40,7 @@ usersRouter.get('/me/videos', paginationValidator, videosSortValidator, setDefaultSort, - setPagination, + setDefaultPagination, asyncMiddleware(getUserVideos) ) @@ -56,7 +56,7 @@ usersRouter.get('/', paginationValidator, usersSortValidator, setDefaultSort, - setPagination, + setDefaultPagination, asyncMiddleware(listUsers) ) @@ -129,15 +129,19 @@ async function createUserRetryWrapper (req: express.Request, res: express.Respon errorMessage: 'Cannot insert the user with many retries.' } - await retryTransactionWrapper(createUser, options) + const { user, account } = await retryTransactionWrapper(createUser, options) - // TODO : include Location of the new user -> 201 - return res.type('json').status(204).end() + return res.json({ + user: { + id: user.id, + uuid: account.uuid + } + }).end() } async function createUser (req: express.Request) { const body: UserCreate = req.body - const user = new UserModel({ + const userToCreate = new UserModel({ username: body.username, password: body.password, email: body.email, @@ -147,9 +151,11 @@ async function createUser (req: express.Request) { videoQuota: body.videoQuota }) - await createUserAccountAndChannel(user) + const { user, account } = await createUserAccountAndChannel(userToCreate) logger.info('User %s with its channel and account created.', body.username) + + return { user, account } } async function registerUserRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { -- cgit v1.2.3