aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-26 15:49:57 +0100
committerChocobozzz <me@florianbigard.com>2018-01-26 15:49:57 +0100
commit4ba3b8ea1be85d95a508ac479f26b96ceea15971 (patch)
treef76de3c6ec591cf885e5000f0e369aab883f3d95 /server/initializers
parent7859b5800c08c15f3380fb3a7e267ce1b3f2df9f (diff)
downloadPeerTube-4ba3b8ea1be85d95a508ac479f26b96ceea15971.tar.gz
PeerTube-4ba3b8ea1be85d95a508ac479f26b96ceea15971.tar.zst
PeerTube-4ba3b8ea1be85d95a508ac479f26b96ceea15971.zip
Don't rehost announced video activities
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts5
-rw-r--r--server/initializers/migrations/0185-video-share-url.ts38
2 files changed, 42 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 329d0ffe8..a88f9642c 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -12,7 +12,7 @@ let config: IConfig = require('config')
12 12
13// --------------------------------------------------------------------------- 13// ---------------------------------------------------------------------------
14 14
15const LAST_MIGRATION_VERSION = 180 15const LAST_MIGRATION_VERSION = 185
16 16
17// --------------------------------------------------------------------------- 17// ---------------------------------------------------------------------------
18 18
@@ -196,6 +196,9 @@ const CONSTRAINTS_FIELDS = {
196 VIDEO_COMMENTS: { 196 VIDEO_COMMENTS: {
197 TEXT: { min: 2, max: 3000 }, // Length 197 TEXT: { min: 2, max: 3000 }, // Length
198 URL: { min: 3, max: 2000 } // Length 198 URL: { min: 3, max: 2000 } // Length
199 },
200 VIDEO_SHARE: {
201 URL: { min: 3, max: 2000 } // Length
199 } 202 }
200} 203}
201 204
diff --git a/server/initializers/migrations/0185-video-share-url.ts b/server/initializers/migrations/0185-video-share-url.ts
new file mode 100644
index 000000000..f7eeb0878
--- /dev/null
+++ b/server/initializers/migrations/0185-video-share-url.ts
@@ -0,0 +1,38 @@
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 {
9 const query = 'DELETE FROM "videoShare" s1 ' +
10 'USING (SELECT MIN(id) as id, "actorId", "videoId" FROM "videoShare" GROUP BY "actorId", "videoId" HAVING COUNT(*) > 1) s2 ' +
11 'WHERE s1."actorId" = s2."actorId" AND s1."videoId" = s2."videoId" AND s1.id <> s2.id'
12 await utils.sequelize.query(query)
13 }
14
15 {
16 const data = {
17 type: Sequelize.STRING,
18 allowNull: true,
19 defaultValue: null
20 }
21 await utils.queryInterface.addColumn('videoShare', 'url', data)
22
23 const query = `UPDATE "videoShare" SET "url" = (SELECT "url" FROM "video" WHERE "id" = "videoId") || '/announces/' || "actorId"`
24 await utils.sequelize.query(query)
25
26 data.allowNull = false
27 await utils.queryInterface.changeColumn('videoShare', 'url', data)
28 }
29}
30
31function down (options) {
32 throw new Error('Not implemented.')
33}
34
35export {
36 up,
37 down
38}