mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 13:20:41 +01:00
Merge branch 'develop' into upgrades-refactor
re-added upgrade scripts from #5464
This commit is contained in:
@@ -46,7 +46,7 @@ var Upgrade = {
|
||||
},
|
||||
{
|
||||
version: 'master', // rename this to whenever the next NodeBB version is (non-breaking)
|
||||
upgrades: ['sound_settings', 'post_votes_zset'],
|
||||
upgrades: ['sound_settings', 'post_votes_zset', 'config_urls_update'],
|
||||
},
|
||||
{
|
||||
version: 'develop', // rename this to whatever the next NodeBB version is (breaking)
|
||||
|
||||
38
src/upgrades/config_urls_update.js
Normal file
38
src/upgrades/config_urls_update.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/* jslint node: true */
|
||||
|
||||
'use strict';
|
||||
|
||||
var db = require('../database');
|
||||
|
||||
var async = require('async');
|
||||
|
||||
module.exports = {
|
||||
name: 'User_friendly_upgrade_script_name',
|
||||
timestamp: Date.UTC(2017, 0, 1),
|
||||
method: function (callback) {
|
||||
async.waterfall([
|
||||
function (cb) {
|
||||
db.getObject('config', cb);
|
||||
},
|
||||
function (config, cb) {
|
||||
if (!config) {
|
||||
return cb();
|
||||
}
|
||||
|
||||
var keys = ['brand:favicon', 'brand:touchicon', 'og:image', 'brand:logo:url', 'defaultAvatar', 'profile:defaultCovers'];
|
||||
|
||||
keys.forEach(function (key) {
|
||||
var oldValue = config[key];
|
||||
|
||||
if (!oldValue || typeof oldValue !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
config[key] = oldValue.replace(/(?:\/assets)?\/(images|uploads)\//g, '/assets/$1/');
|
||||
});
|
||||
|
||||
db.setObject('config', config, cb);
|
||||
},
|
||||
], callback);
|
||||
},
|
||||
};
|
||||
@@ -10,7 +10,6 @@ module.exports = {
|
||||
name: 'Update global and user sound settings',
|
||||
timestamp: Date.UTC(2017, 1, 25),
|
||||
method: function (callback) {
|
||||
var user = require('../user');
|
||||
var meta = require('../meta');
|
||||
var batch = require('../batch');
|
||||
|
||||
@@ -20,14 +19,14 @@ module.exports = {
|
||||
'waterdrop-low.mp3': 'Default | Water drop (low)',
|
||||
};
|
||||
|
||||
db.getObject('settings:sounds', function (err, settings) {
|
||||
if (err || !settings) {
|
||||
return callback(err);
|
||||
}
|
||||
async.parallel([
|
||||
function (cb) {
|
||||
var keys = ['chat-incoming', 'chat-outgoing', 'notification'];
|
||||
|
||||
async.parallel([
|
||||
function (cb) {
|
||||
var keys = ['chat-incoming', 'chat-outgoing', 'notification'];
|
||||
db.getObject('settings:sounds', function (err, settings) {
|
||||
if (err || !settings) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
keys.forEach(function (key) {
|
||||
if (settings[key] && settings[key].indexOf(' | ') === -1) {
|
||||
@@ -36,29 +35,33 @@ module.exports = {
|
||||
});
|
||||
|
||||
meta.configs.setMultiple(settings, cb);
|
||||
},
|
||||
function (cb) {
|
||||
var keys = ['notificationSound', 'incomingChatSound', 'outgoingChatSound'];
|
||||
});
|
||||
},
|
||||
function (cb) {
|
||||
var keys = ['notificationSound', 'incomingChatSound', 'outgoingChatSound'];
|
||||
|
||||
batch.processSortedSet('users:joindate', function (ids, next) {
|
||||
async.each(ids, function (uid, next) {
|
||||
db.getObject('user:' + uid + ':settings', function (err, settings) {
|
||||
if (err || !settings) {
|
||||
return next(err);
|
||||
batch.processSortedSet('users:joindate', function (ids, next) {
|
||||
async.each(ids, function (uid, next) {
|
||||
db.getObject('user:' + uid + ':settings', function (err, settings) {
|
||||
if (err || !settings) {
|
||||
return next(err);
|
||||
}
|
||||
var newSettings = {};
|
||||
keys.forEach(function (key) {
|
||||
if (settings[key] && settings[key].indexOf(' | ') === -1) {
|
||||
newSettings[key] = map[settings[key]] || '';
|
||||
}
|
||||
|
||||
keys.forEach(function (key) {
|
||||
if (settings[key] && settings[key].indexOf(' | ') === -1) {
|
||||
settings[key] = map[settings[key]] || '';
|
||||
}
|
||||
});
|
||||
|
||||
user.saveSettings(uid, settings, next);
|
||||
});
|
||||
}, next);
|
||||
}, cb);
|
||||
},
|
||||
], callback);
|
||||
});
|
||||
|
||||
if (Object.keys(newSettings).length) {
|
||||
db.setObject('user:' + uid + ':settings', newSettings, next);
|
||||
} else {
|
||||
setImmediate(next);
|
||||
}
|
||||
});
|
||||
}, next);
|
||||
}, cb);
|
||||
},
|
||||
], callback);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user