Skip to content

Node.js based forum software built for the modern web

Merge branch 'master' into assets-images-upgrade

Barış Soner Uşaklı6222b55dd807
diff --cc src/upgrade.js
index bab54be08a,7f14d211d3..5453952979
--- a/src/upgrade.js
+++ b/src/upgrade.js
@@@ -347,76 -349,40 +346,80 @@@ Upgrade.upgrade = function (callback)
});
meta.configs.setMultiple(settings, cb);
- },
- 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);
- }
- var newSettings = {};
- keys.forEach(function (key) {
- if (settings[key] && settings[key].indexOf(' | ') === -1) {
- newSettings[key] = map[settings[key]] || '';
- }
- });
-
- if (Object.keys(newSettings).length) {
- db.setObject('user:' + uid + ':settings', newSettings, next);
- } else {
- setImmediate(next);
+ });
+ },
+ 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);
+ }
-
++ var newSettings = {};
+ keys.forEach(function (key) {
+ if (settings[key] && settings[key].indexOf(' | ') === -1) {
- settings[key] = map[settings[key]] || '';
++ newSettings[key] = map[settings[key]] || '';
}
});
-
- user.saveSettings(uid, settings, next);
- }, next);
- }, cb);
- },
- ], function (err) {
- if (err) {
- return next(err);
++
++ if (Object.keys(newSettings).length) {
++ user.saveSettings(uid, settings, next);
++ } else {
++ setImmediate(next);
++ }
+ });
+ }, next);
+ }, cb);
+ },
+ ], function (err) {
+ if (err) {
+ return next(err);
+ }
+ winston.info(schemaName + ' - done');
+ Upgrade.update(thisSchemaDate, next);
+ });
+ } else {
+ winston.info(schemaName + ' - skipped!');
+ next();
+ }
+ },
+ function (next) {
+ thisSchemaDate = Date.UTC(2017, 1, 28);
+ var schemaName = '[2017/2/28] Update urls in config to `/assets`';
+
+ if (schemaDate < thisSchemaDate) {
+ updatesMade = true;
+ winston.info(schemaName);
+ 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);
+ },
+ function (next) {
winston.info(schemaName + ' - done');
Upgrade.update(thisSchemaDate, next);
- });
- });
+ },
+ ], next);
} else {
winston.info(schemaName + ' - skipped!');
next();