From 225a89c2afbbe53cf39ffa7ea0cd485095a1d5f5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 21 Dec 2017 09:56:59 +0100 Subject: Sanitize url to not end with implicit ports --- server/initializers/migrations/0140-actor-url.ts | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 server/initializers/migrations/0140-actor-url.ts (limited to 'server/initializers/migrations') 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 @@ +import * as Sequelize from 'sequelize' +import { DataType } from 'sequelize-typescript' +import { createPrivateAndPublicKeys } from '../../helpers' +import { CONFIG } from '../constants' + +async function up (utils: { + transaction: Sequelize.Transaction, + queryInterface: Sequelize.QueryInterface, + sequelize: Sequelize.Sequelize +}): Promise { + const toReplace = CONFIG.WEBSERVER.HOSTNAME + ':443' + const by = CONFIG.WEBSERVER.HOST + const replacer = column => `replace("${column}", '${toReplace}', '${by}')` + + { + const query = `UPDATE video SET url = ${replacer('url')}` + await utils.sequelize.query(query) + } + + { + const query = ` + UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')}, + "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')}, + "followingUrl" = ${replacer('followingUrl')} + ` + await utils.sequelize.query(query) + } + + { + const query = `UPDATE server SET host = replace(host, ':443', '')` + await utils.sequelize.query(query) + } +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3