diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/activitypub/inbox.ts | 2 | ||||
-rw-r--r-- | server/controllers/activitypub/outbox.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/users.ts | 11 | ||||
-rw-r--r-- | server/initializers/constants.ts | 5 | ||||
-rw-r--r-- | server/middlewares/validators/users.ts | 3 | ||||
-rw-r--r-- | server/models/server/server.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-comment.ts | 2 | ||||
-rw-r--r-- | server/tests/api/fixtures/avatar-resized.png | bin | 0 -> 2420 bytes | |||
-rw-r--r-- | server/tests/api/users/users.ts | 2 |
9 files changed, 19 insertions, 10 deletions
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts index bfcb7b369..8d65639f8 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/controllers/activitypub/inbox.ts | |||
@@ -16,7 +16,7 @@ inboxRouter.post('/inbox', | |||
16 | asyncMiddleware(inboxController) | 16 | asyncMiddleware(inboxController) |
17 | ) | 17 | ) |
18 | 18 | ||
19 | inboxRouter.post('/account/:name/inbox', | 19 | inboxRouter.post('/accounts/:name/inbox', |
20 | signatureValidator, | 20 | signatureValidator, |
21 | asyncMiddleware(checkSignature), | 21 | asyncMiddleware(checkSignature), |
22 | localAccountValidator, | 22 | localAccountValidator, |
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts index 01ba253c6..620f9ee83 100644 --- a/server/controllers/activitypub/outbox.ts +++ b/server/controllers/activitypub/outbox.ts | |||
@@ -11,7 +11,7 @@ import { VideoModel } from '../../models/video/video' | |||
11 | 11 | ||
12 | const outboxRouter = express.Router() | 12 | const outboxRouter = express.Router() |
13 | 13 | ||
14 | outboxRouter.get('/account/:name/outbox', | 14 | outboxRouter.get('/accounts/:name/outbox', |
15 | localAccountValidator, | 15 | localAccountValidator, |
16 | asyncMiddleware(outboxController) | 16 | asyncMiddleware(outboxController) |
17 | ) | 17 | ) |
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index 57b98b84a..6c24434f2 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts | |||
@@ -1,12 +1,13 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { extname, join } from 'path' | 2 | import { extname, join } from 'path' |
3 | import * as sharp from 'sharp' | ||
3 | import * as uuidv4 from 'uuid/v4' | 4 | import * as uuidv4 from 'uuid/v4' |
4 | import { UserCreate, UserRight, UserRole, UserUpdate, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../shared' | 5 | import { UserCreate, UserRight, UserRole, UserUpdate, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../shared' |
5 | import { renamePromise } from '../../helpers/core-utils' | 6 | import { renamePromise, unlinkPromise } from '../../helpers/core-utils' |
6 | import { retryTransactionWrapper } from '../../helpers/database-utils' | 7 | import { retryTransactionWrapper } from '../../helpers/database-utils' |
7 | import { logger } from '../../helpers/logger' | 8 | import { logger } from '../../helpers/logger' |
8 | import { createReqFiles, getFormattedObjects } from '../../helpers/utils' | 9 | import { createReqFiles, getFormattedObjects } from '../../helpers/utils' |
9 | import { AVATAR_MIMETYPE_EXT, CONFIG, sequelizeTypescript } from '../../initializers' | 10 | import { AVATAR_MIMETYPE_EXT, AVATARS_SIZE, CONFIG, sequelizeTypescript } from '../../initializers' |
10 | import { createUserAccountAndChannel } from '../../lib/user' | 11 | import { createUserAccountAndChannel } from '../../lib/user' |
11 | import { | 12 | import { |
12 | asyncMiddleware, authenticate, ensureUserHasRight, ensureUserRegistrationAllowed, paginationValidator, setPagination, setUsersSort, | 13 | asyncMiddleware, authenticate, ensureUserHasRight, ensureUserRegistrationAllowed, paginationValidator, setPagination, setUsersSort, |
@@ -239,7 +240,11 @@ async function updateMyAvatar (req: express.Request, res: express.Response, next | |||
239 | const avatarName = uuidv4() + extension | 240 | const avatarName = uuidv4() + extension |
240 | const destination = join(avatarDir, avatarName) | 241 | const destination = join(avatarDir, avatarName) |
241 | 242 | ||
242 | await renamePromise(source, destination) | 243 | await sharp(source) |
244 | .resize(AVATARS_SIZE.width, AVATARS_SIZE.height) | ||
245 | .toFile(destination) | ||
246 | |||
247 | await unlinkPromise(source) | ||
243 | 248 | ||
244 | const { avatar } = await sequelizeTypescript.transaction(async t => { | 249 | const { avatar } = await sequelizeTypescript.transaction(async t => { |
245 | const avatar = await AvatarModel.create({ | 250 | const avatar = await AvatarModel.create({ |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index aefb91537..d9b21b389 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -316,6 +316,10 @@ const PREVIEWS_SIZE = { | |||
316 | width: 560, | 316 | width: 560, |
317 | height: 315 | 317 | height: 315 |
318 | } | 318 | } |
319 | const AVATARS_SIZE = { | ||
320 | width: 120, | ||
321 | height: 120 | ||
322 | } | ||
319 | 323 | ||
320 | const EMBED_SIZE = { | 324 | const EMBED_SIZE = { |
321 | width: 560, | 325 | width: 560, |
@@ -355,6 +359,7 @@ CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WE | |||
355 | 359 | ||
356 | export { | 360 | export { |
357 | API_VERSION, | 361 | API_VERSION, |
362 | AVATARS_SIZE, | ||
358 | ACCEPT_HEADERS, | 363 | ACCEPT_HEADERS, |
359 | BCRYPT_SALT_SIZE, | 364 | BCRYPT_SALT_SIZE, |
360 | CACHE, | 365 | CACHE, |
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 7de3e442c..d22a745b4 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -12,7 +12,6 @@ import { isSignupAllowed } from '../../helpers/utils' | |||
12 | import { CONSTRAINTS_FIELDS } from '../../initializers' | 12 | import { CONSTRAINTS_FIELDS } from '../../initializers' |
13 | import { UserModel } from '../../models/account/user' | 13 | import { UserModel } from '../../models/account/user' |
14 | import { areValidationErrors } from './utils' | 14 | import { areValidationErrors } from './utils' |
15 | import Multer = require('multer') | ||
16 | 15 | ||
17 | const usersAddValidator = [ | 16 | const usersAddValidator = [ |
18 | body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), | 17 | body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), |
@@ -105,7 +104,7 @@ const usersUpdateMyAvatarValidator = [ | |||
105 | ), | 104 | ), |
106 | 105 | ||
107 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 106 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
108 | logger.debug('Checking usersUpdateMyAvatarValidator parameters', { parameters: req.body }) | 107 | logger.debug('Checking usersUpdateMyAvatarValidator parameters', { files: req.files }) |
109 | 108 | ||
110 | if (areValidationErrors(req, res)) return | 109 | if (areValidationErrors(req, res)) return |
111 | 110 | ||
diff --git a/server/models/server/server.ts b/server/models/server/server.ts index 122e5f74f..d35aa0ca4 100644 --- a/server/models/server/server.ts +++ b/server/models/server/server.ts | |||
@@ -27,7 +27,7 @@ export class ServerModel extends Model<ServerModel> { | |||
27 | @AllowNull(false) | 27 | @AllowNull(false) |
28 | @Default(SERVERS_SCORE.BASE) | 28 | @Default(SERVERS_SCORE.BASE) |
29 | @IsInt | 29 | @IsInt |
30 | @Max(SERVERS_SCORE.max) | 30 | @Max(SERVERS_SCORE.MAX) |
31 | @Column | 31 | @Column |
32 | score: number | 32 | score: number |
33 | 33 | ||
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 829022a51..63675c20b 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -214,7 +214,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
214 | 214 | ||
215 | static listThreadCommentsForApi (videoId: number, threadId: number) { | 215 | static listThreadCommentsForApi (videoId: number, threadId: number) { |
216 | const query = { | 216 | const query = { |
217 | order: [ [ 'createdAt', 'DESC' ] ], | 217 | order: [ [ 'createdAt', 'ASC' ] ], |
218 | where: { | 218 | where: { |
219 | videoId, | 219 | videoId, |
220 | [ Sequelize.Op.or ]: [ | 220 | [ Sequelize.Op.or ]: [ |
diff --git a/server/tests/api/fixtures/avatar-resized.png b/server/tests/api/fixtures/avatar-resized.png new file mode 100644 index 000000000..e05fc07ce --- /dev/null +++ b/server/tests/api/fixtures/avatar-resized.png | |||
Binary files differ | |||
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 3390b2d56..f7e5972d3 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -352,7 +352,7 @@ describe('Test users', function () { | |||
352 | const res = await getMyUserInformation(server.url, accessTokenUser) | 352 | const res = await getMyUserInformation(server.url, accessTokenUser) |
353 | const user = res.body | 353 | const user = res.body |
354 | 354 | ||
355 | const test = await testVideoImage(server.url, 'avatar', user.account.avatar.path, '.png') | 355 | const test = await testVideoImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') |
356 | expect(test).to.equal(true) | 356 | expect(test).to.equal(true) |
357 | }) | 357 | }) |
358 | 358 | ||