1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Don't show videos of remote instance after unfollow

This commit is contained in:
Chocobozzz 2018-01-18 10:53:54 +01:00
parent 1174a8479a
commit f05a1c30c1
No known key found for this signature in database
GPG key ID: 583A612D890159BE
38 changed files with 402 additions and 211 deletions

View file

@ -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) {