diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-29 19:10:13 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-29 19:10:13 +0100 |
commit | c5911fd347c76e8bdc05ea9f3ee9efed4a58c236 (patch) | |
tree | b8d287daca6c45305090cbec9da97d1155f275bd /server/initializers | |
parent | 8b0d42ee372de6589796be26b83e5bffb1b69cdf (diff) | |
download | PeerTube-c5911fd347c76e8bdc05ea9f3ee9efed4a58c236.tar.gz PeerTube-c5911fd347c76e8bdc05ea9f3ee9efed4a58c236.tar.zst PeerTube-c5911fd347c76e8bdc05ea9f3ee9efed4a58c236.zip |
Begin to add avatar to actors
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 19 | ||||
-rw-r--r-- | server/initializers/migrations/0150-avatar-cascade.ts | 28 |
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 | ||
12 | const LAST_MIGRATION_VERSION = 145 | 12 | const 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 | ||
256 | const AVATAR_MIMETYPE_EXT = { | ||
257 | 'image/png': '.png', | ||
258 | 'image/jpg': '.jpg', | ||
259 | 'image/jpeg': '.jpg' | ||
260 | } | ||
261 | |||
253 | // --------------------------------------------------------------------------- | 262 | // --------------------------------------------------------------------------- |
254 | 263 | ||
255 | const SERVER_ACTOR_NAME = 'peertube' | 264 | const 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 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async 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 | |||
21 | function down (options) { | ||
22 | throw new Error('Not implemented.') | ||
23 | } | ||
24 | |||
25 | export { | ||
26 | up, | ||
27 | down | ||
28 | } | ||