mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-11-22 08:46:54 -06:00
Add email to pods
This commit is contained in:
parent
3266ad7cf8
commit
4793c343fd
@ -35,6 +35,10 @@ export class FriendListComponent {
|
||||
title: 'Host',
|
||||
sort: false
|
||||
},
|
||||
email: {
|
||||
title: 'Email',
|
||||
sort: false
|
||||
},
|
||||
score: {
|
||||
title: 'Score',
|
||||
sort: false
|
||||
|
@ -2,5 +2,6 @@ export interface Friend {
|
||||
id: string;
|
||||
host: string;
|
||||
score: number;
|
||||
email: string;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
@ -22,3 +22,6 @@ storage:
|
||||
previews: 'previews/'
|
||||
thumbnails: 'thumbnails/'
|
||||
torrents: 'torrents/'
|
||||
|
||||
admin:
|
||||
email: 'admin@example.com'
|
||||
|
@ -23,3 +23,6 @@ storage:
|
||||
previews: 'previews/'
|
||||
thumbnails: 'thumbnails/'
|
||||
torrents: 'torrents/'
|
||||
|
||||
admin:
|
||||
email: 'admin@example.com'
|
||||
|
@ -15,3 +15,6 @@ storage:
|
||||
logs: 'test1/logs/'
|
||||
thumbnails: 'test1/thumbnails/'
|
||||
torrents: 'test1/torrents/'
|
||||
|
||||
admin:
|
||||
email: 'admin1@example.com'
|
||||
|
@ -15,3 +15,6 @@ storage:
|
||||
logs: 'test2/logs/'
|
||||
thumbnails: 'test2/thumbnails/'
|
||||
torrents: 'test2/torrents/'
|
||||
|
||||
admin:
|
||||
email: 'admin2@example.com'
|
||||
|
@ -15,3 +15,6 @@ storage:
|
||||
logs: 'test3/logs/'
|
||||
thumbnails: 'test3/thumbnails/'
|
||||
torrents: 'test3/torrents/'
|
||||
|
||||
admin:
|
||||
email: 'admin3@example.com'
|
||||
|
@ -15,3 +15,6 @@ storage:
|
||||
logs: 'test4/logs/'
|
||||
thumbnails: 'test4/thumbnails/'
|
||||
torrents: 'test4/torrents/'
|
||||
|
||||
admin:
|
||||
email: 'admin4@example.com'
|
||||
|
@ -15,3 +15,6 @@ storage:
|
||||
logs: 'test5/logs/'
|
||||
thumbnails: 'test5/thumbnails/'
|
||||
torrents: 'test5/torrents/'
|
||||
|
||||
admin:
|
||||
email: 'admin5@example.com'
|
||||
|
@ -15,3 +15,6 @@ storage:
|
||||
logs: 'test6/logs/'
|
||||
thumbnails: 'test6/thumbnails/'
|
||||
torrents: 'test6/torrents/'
|
||||
|
||||
admin:
|
||||
email: 'admin6@example.com'
|
||||
|
@ -4,6 +4,7 @@ const express = require('express')
|
||||
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')
|
||||
@ -80,7 +81,7 @@ function addPods (req, res, next) {
|
||||
], function (err, cert) {
|
||||
if (err) return next(err)
|
||||
|
||||
return res.json({ cert: cert })
|
||||
return res.json({ cert: cert, email: constants.CONFIG.ADMIN.EMAIL })
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,8 @@ function checkMissedConfig () {
|
||||
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 = []
|
||||
|
||||
|
@ -54,6 +54,9 @@ const CONFIG = {
|
||||
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
|
||||
@ -92,7 +95,7 @@ const FRIEND_SCORE = {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const LAST_MIGRATION_VERSION = 0
|
||||
const LAST_MIGRATION_VERSION = 5
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
20
server/initializers/migrations/0005-email-pod.js
Normal file
20
server/initializers/migrations/0005-email-pod.js
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
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.')
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
// /*
|
||||
// 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.')
|
||||
// }
|
@ -64,7 +64,7 @@ function getMigrationScripts (callback) {
|
||||
}
|
||||
|
||||
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)
|
||||
@ -78,7 +78,12 @@ function executeMigration (actualVersion, entity, callback) {
|
||||
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)
|
||||
|
@ -245,6 +245,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) {
|
||||
method: 'POST',
|
||||
json: {
|
||||
host: constants.CONFIG.WEBSERVER.HOST,
|
||||
email: constants.CONFIG.ADMIN.EMAIL,
|
||||
publicKey: cert
|
||||
}
|
||||
}
|
||||
@ -257,7 +258,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) {
|
||||
}
|
||||
|
||||
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 })
|
||||
|
@ -40,7 +40,8 @@ function makeFriends (req, res, next) {
|
||||
}
|
||||
|
||||
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 })
|
||||
|
||||
|
@ -32,6 +32,10 @@ module.exports = function (sequelize, DataTypes) {
|
||||
isInt: true,
|
||||
max: constants.FRIEND_SCORE.MAX
|
||||
}
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING(400),
|
||||
allowNull: false
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -71,6 +75,7 @@ function toFormatedJSON () {
|
||||
const json = {
|
||||
id: this.id,
|
||||
host: this.host,
|
||||
email: this.email,
|
||||
score: this.score,
|
||||
createdAt: this.createdAt
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ describe('Test basic friends', function () {
|
||||
|
||||
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
|
||||
|
||||
@ -113,6 +114,7 @@ describe('Test basic friends', function () {
|
||||
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user