Allow channel path to be customizable

We now allow server operators to customize the /r/ part of the channel links
The new config option in the template is commented and the config module validates and will terminate with status 78 if an improper value is used.
We've also dropped some old cruft and uses a more elegant method to assign CHANNEL.name

Resolves #668
This commit is contained in:
Xaekai 2017-06-16 00:16:59 -07:00
parent 00a65a1584
commit 6d4558c978
18 changed files with 71 additions and 75 deletions

View file

@ -114,6 +114,8 @@ function fixOldChandump(data) {
}
function migrate(src, dest, opts) {
const chanPath = Config.get('channel-path');
return src.listChannels().then(names => {
return Promise.reduce(names, (_, name) => {
// A long time ago there was a bug where CyTube would save a different
@ -143,11 +145,11 @@ function migrate(src, dest, opts) {
});
return dest.save(name, data);
}).then(() => {
console.log(`Migrated /r/${name}`);
console.log(`Migrated /${chanPath}/${name}`);
}).catch(ChannelNotFoundError, err => {
console.log(`Skipping /r/${name} (not present in the database)`);
console.log(`Skipping /${chanPath}/${name} (not present in the database)`);
}).catch(err => {
console.error(`Failed to migrate /r/${name}: ${err.stack}`);
console.error(`Failed to migrate /${chanPath}/${name}: ${err.stack}`);
});
}, 0);
});