title: 'Host',
sort: false
},
+ email: {
+ title: 'Email',
+ sort: false
+ },
score: {
title: 'Score',
sort: false
id: string;
host: string;
score: number;
+ email: string;
createdAt: Date;
}
previews: 'previews/'
thumbnails: 'thumbnails/'
torrents: 'torrents/'
+
+admin:
+ email: 'admin@example.com'
previews: 'previews/'
thumbnails: 'thumbnails/'
torrents: 'torrents/'
+
+admin:
+ email: 'admin@example.com'
logs: 'test1/logs/'
thumbnails: 'test1/thumbnails/'
torrents: 'test1/torrents/'
+
+admin:
+ email: 'admin1@example.com'
logs: 'test2/logs/'
thumbnails: 'test2/thumbnails/'
torrents: 'test2/torrents/'
+
+admin:
+ email: 'admin2@example.com'
logs: 'test3/logs/'
thumbnails: 'test3/thumbnails/'
torrents: 'test3/torrents/'
+
+admin:
+ email: 'admin3@example.com'
logs: 'test4/logs/'
thumbnails: 'test4/thumbnails/'
torrents: 'test4/torrents/'
+
+admin:
+ email: 'admin4@example.com'
logs: 'test5/logs/'
thumbnails: 'test5/thumbnails/'
torrents: 'test5/torrents/'
+
+admin:
+ email: 'admin5@example.com'
logs: 'test6/logs/'
thumbnails: 'test6/thumbnails/'
torrents: 'test6/torrents/'
+
+admin:
+ email: 'admin6@example.com'
const waterfall = require('async/waterfall')
const db = require('../../initializers/database')
+const constants = require('../../initializers/constants')
const logger = require('../../helpers/logger')
const peertubeCrypto = require('../../helpers/peertube-crypto')
const utils = require('../../helpers/utils')
], function (err, cert) {
if (err) return next(err)
- return res.json({ cert: cert })
+ return res.json({ cert: cert, email: constants.CONFIG.ADMIN.EMAIL })
})
}
const required = [ 'listen.port',
'webserver.https', 'webserver.hostname', 'webserver.port',
'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password',
- 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews'
+ 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews',
+ 'admin.email'
]
const miss = []
WS: config.get('webserver.https') === true ? 'wss' : 'ws',
HOSTNAME: config.get('webserver.hostname'),
PORT: config.get('webserver.port')
+ },
+ ADMIN: {
+ EMAIL: config.get('admin.email')
}
}
CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
// ---------------------------------------------------------------------------
-const LAST_MIGRATION_VERSION = 0
+const LAST_MIGRATION_VERSION = 5
// ---------------------------------------------------------------------------
--- /dev/null
+/*
+ This is just an example.
+*/
+
+// utils = { transaction, queryInterface }
+exports.up = function (utils, callback) {
+ const q = utils.queryInterface
+ const Sequelize = utils.Sequelize
+
+ const data = {
+ type: Sequelize.STRING(400),
+ allowNull: false
+ }
+
+ q.addColumn('Pods', 'email', data, { transaction: utils.transaction }).asCallback(callback)
+}
+
+exports.down = function (options, callback) {
+ throw new Error('Not implemented.')
+}
+++ /dev/null
-// /*
-// This is just an example.
-// */
-
-// const db = require('../database')
-
-// // options contains the transaction
-// exports.up = function (options, callback) {
-// db.Application.create({ migrationVersion: 42 }, { transaction: options.transaction }).asCallback(callback)
-// }
-
-// exports.down = function (options, callback) {
-// throw new Error('Not implemented.')
-// }
}
function executeMigration (actualVersion, entity, callback) {
- const versionScript = entity.version
+ const versionScript = parseInt(entity.version)
// Do not execute old migration scripts
if (versionScript <= actualVersion) return callback(null)
db.sequelize.transaction().asCallback(function (err, t) {
if (err) return callback(err)
- migrationScript.up({ transaction: t }, function (err) {
+ const options = {
+ transaction: t,
+ queryInterface: db.sequelize.getQueryInterface(),
+ Sequelize: db.Sequelize
+ }
+ migrationScript.up(options, function (err) {
if (err) {
t.rollback()
return callback(err)
method: 'POST',
json: {
host: constants.CONFIG.WEBSERVER.HOST,
+ email: constants.CONFIG.ADMIN.EMAIL,
publicKey: cert
}
}
}
if (res.statusCode === 200) {
- const podObj = db.Pod.build({ host: pod.host, publicKey: body.cert })
+ const podObj = db.Pod.build({ host: pod.host, publicKey: body.cert, email: body.email })
podObj.save().asCallback(function (err, podCreated) {
if (err) {
logger.error('Cannot add friend %s pod.', pod.host, { error: err })
}
function podsAdd (req, res, next) {
- req.checkBody('host', 'Should have an host').isHostValid()
+ req.checkBody('host', 'Should have a host').isHostValid()
+ req.checkBody('email', 'Should have an email').isEmail()
req.checkBody('publicKey', 'Should have a public key').notEmpty()
logger.debug('Checking podsAdd parameters', { parameters: req.body })
isInt: true,
max: constants.FRIEND_SCORE.MAX
}
+ },
+ email: {
+ type: DataTypes.STRING(400),
+ allowNull: false
}
},
{
const json = {
id: this.id,
host: this.host,
+ email: this.email,
score: this.score,
createdAt: this.createdAt
}
const pod = result[0]
expect(pod.host).to.equal(servers[2].host)
+ expect(pod.email).to.equal('admin3@example.com')
expect(pod.score).to.equal(20)
expect(miscsUtils.dateIsValid(pod.createdAt)).to.be.true
const pod = result[0]
expect(pod.host).to.equal(servers[1].host)
+ expect(pod.email).to.equal('admin2@example.com')
expect(pod.score).to.equal(20)
expect(miscsUtils.dateIsValid(pod.createdAt)).to.be.true