aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0140-actor-url.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-21 09:56:59 +0100
committerChocobozzz <me@florianbigard.com>2017-12-21 09:56:59 +0100
commit225a89c2afbbe53cf39ffa7ea0cd485095a1d5f5 (patch)
tree9dc8fa039e820229fd3ecb386d6f63bf02e16698 /server/initializers/migrations/0140-actor-url.ts
parent6725d05c5f71e0cdf0deba6692220b73e42e7ffa (diff)
downloadPeerTube-225a89c2afbbe53cf39ffa7ea0cd485095a1d5f5.tar.gz
PeerTube-225a89c2afbbe53cf39ffa7ea0cd485095a1d5f5.tar.zst
PeerTube-225a89c2afbbe53cf39ffa7ea0cd485095a1d5f5.zip
Sanitize url to not end with implicit ports
Diffstat (limited to 'server/initializers/migrations/0140-actor-url.ts')
-rw-r--r--server/initializers/migrations/0140-actor-url.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/server/initializers/migrations/0140-actor-url.ts b/server/initializers/migrations/0140-actor-url.ts
new file mode 100644
index 000000000..626f3c444
--- /dev/null
+++ b/server/initializers/migrations/0140-actor-url.ts
@@ -0,0 +1,42 @@
1import * as Sequelize from 'sequelize'
2import { DataType } from 'sequelize-typescript'
3import { createPrivateAndPublicKeys } from '../../helpers'
4import { CONFIG } from '../constants'
5
6async function up (utils: {
7 transaction: Sequelize.Transaction,
8 queryInterface: Sequelize.QueryInterface,
9 sequelize: Sequelize.Sequelize
10}): Promise<void> {
11 const toReplace = CONFIG.WEBSERVER.HOSTNAME + ':443'
12 const by = CONFIG.WEBSERVER.HOST
13 const replacer = column => `replace("${column}", '${toReplace}', '${by}')`
14
15 {
16 const query = `UPDATE video SET url = ${replacer('url')}`
17 await utils.sequelize.query(query)
18 }
19
20 {
21 const query = `
22 UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')},
23 "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')},
24 "followingUrl" = ${replacer('followingUrl')}
25 `
26 await utils.sequelize.query(query)
27 }
28
29 {
30 const query = `UPDATE server SET host = replace(host, ':443', '')`
31 await utils.sequelize.query(query)
32 }
33}
34
35function down (options) {
36 throw new Error('Not implemented.')
37}
38
39export {
40 up,
41 down
42}