aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts19
-rw-r--r--server/initializers/migrations/0150-avatar-cascade.ts28
2 files changed, 43 insertions, 4 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 3a5a557d4..50a29dc43 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -9,7 +9,7 @@ import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core
9 9
10// --------------------------------------------------------------------------- 10// ---------------------------------------------------------------------------
11 11
12const LAST_MIGRATION_VERSION = 145 12const LAST_MIGRATION_VERSION = 150
13 13
14// --------------------------------------------------------------------------- 14// ---------------------------------------------------------------------------
15 15
@@ -172,7 +172,10 @@ const CONSTRAINTS_FIELDS = {
172 ACTOR: { 172 ACTOR: {
173 PUBLIC_KEY: { min: 10, max: 5000 }, // Length 173 PUBLIC_KEY: { min: 10, max: 5000 }, // Length
174 PRIVATE_KEY: { min: 10, max: 5000 }, // Length 174 PRIVATE_KEY: { min: 10, max: 5000 }, // Length
175 URL: { min: 3, max: 2000 } // Length 175 URL: { min: 3, max: 2000 }, // Length
176 AVATAR: {
177 EXTNAME: [ '.png', '.jpeg', '.jpg' ]
178 }
176 }, 179 },
177 VIDEO_EVENTS: { 180 VIDEO_EVENTS: {
178 COUNT: { min: 0 } 181 COUNT: { min: 0 }
@@ -250,6 +253,12 @@ const VIDEO_MIMETYPE_EXT = {
250 'video/mp4': '.mp4' 253 'video/mp4': '.mp4'
251} 254}
252 255
256const AVATAR_MIMETYPE_EXT = {
257 'image/png': '.png',
258 'image/jpg': '.jpg',
259 'image/jpeg': '.jpg'
260}
261
253// --------------------------------------------------------------------------- 262// ---------------------------------------------------------------------------
254 263
255const SERVER_ACTOR_NAME = 'peertube' 264const SERVER_ACTOR_NAME = 'peertube'
@@ -291,7 +300,8 @@ const STATIC_PATHS = {
291 PREVIEWS: '/static/previews/', 300 PREVIEWS: '/static/previews/',
292 THUMBNAILS: '/static/thumbnails/', 301 THUMBNAILS: '/static/thumbnails/',
293 TORRENTS: '/static/torrents/', 302 TORRENTS: '/static/torrents/',
294 WEBSEED: '/static/webseed/' 303 WEBSEED: '/static/webseed/',
304 AVATARS: '/static/avatars/'
295} 305}
296 306
297// Cache control 307// Cache control
@@ -376,5 +386,6 @@ export {
376 VIDEO_PRIVACIES, 386 VIDEO_PRIVACIES,
377 VIDEO_LICENCES, 387 VIDEO_LICENCES,
378 VIDEO_RATE_TYPES, 388 VIDEO_RATE_TYPES,
379 VIDEO_MIMETYPE_EXT 389 VIDEO_MIMETYPE_EXT,
390 AVATAR_MIMETYPE_EXT
380} 391}
diff --git a/server/initializers/migrations/0150-avatar-cascade.ts b/server/initializers/migrations/0150-avatar-cascade.ts
new file mode 100644
index 000000000..821696717
--- /dev/null
+++ b/server/initializers/migrations/0150-avatar-cascade.ts
@@ -0,0 +1,28 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction,
5 queryInterface: Sequelize.QueryInterface,
6 sequelize: Sequelize.Sequelize
7}): Promise<void> {
8 await utils.queryInterface.removeConstraint('actor', 'actor_avatarId_fkey')
9
10 await utils.queryInterface.addConstraint('actor', [ 'avatarId' ], {
11 type: 'foreign key',
12 references: {
13 table: 'avatar',
14 field: 'id'
15 },
16 onDelete: 'set null',
17 onUpdate: 'CASCADE'
18 })
19}
20
21function down (options) {
22 throw new Error('Not implemented.')
23}
24
25export {
26 up,
27 down
28}