diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-19 11:01:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-19 11:01:34 +0200 |
commit | 0883b3245bf0deb9106c4041e9afbd3521b79280 (patch) | |
tree | fcb73005e0b31a3b763ee5d22d5fc39c2da89907 /server/initializers/migrations/0205-user-nsfw-policy.ts | |
parent | 04ed10b21e8e1339514faae0bb690e4d97c23b0a (diff) | |
download | PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.tar.gz PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.tar.zst PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.zip |
Add ability to choose what policy we have for NSFW videos
There is a global instance setting and a per user setting
Diffstat (limited to 'server/initializers/migrations/0205-user-nsfw-policy.ts')
-rw-r--r-- | server/initializers/migrations/0205-user-nsfw-policy.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/server/initializers/migrations/0205-user-nsfw-policy.ts b/server/initializers/migrations/0205-user-nsfw-policy.ts new file mode 100644 index 000000000..d0f6e8962 --- /dev/null +++ b/server/initializers/migrations/0205-user-nsfw-policy.ts | |||
@@ -0,0 +1,46 @@ | |||
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 | |||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.ENUM('do_not_list', 'blur', 'display'), | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('user', 'nsfwPolicy', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE "user" SET "nsfwPolicy" = \'do_not_list\'' | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const query = 'UPDATE "user" SET "nsfwPolicy" = \'display\' WHERE "displayNSFW" = true' | ||
25 | await utils.sequelize.query(query) | ||
26 | } | ||
27 | |||
28 | { | ||
29 | const query = 'ALTER TABLE "user" ALTER COLUMN "nsfwPolicy" SET NOT NULL' | ||
30 | await utils.sequelize.query(query) | ||
31 | } | ||
32 | |||
33 | { | ||
34 | await utils.queryInterface.removeColumn('user', 'displayNSFW') | ||
35 | } | ||
36 | |||
37 | } | ||
38 | |||
39 | function down (options) { | ||
40 | throw new Error('Not implemented.') | ||
41 | } | ||
42 | |||
43 | export { | ||
44 | up, | ||
45 | down | ||
46 | } | ||