mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-16 13:30:23 +01:00
Compare commits
2 Commits
socket-not
...
v0.2.x
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9b9f090e4 | ||
|
|
b82a6fa888 |
@@ -2,7 +2,7 @@
|
||||
"name": "nodebb",
|
||||
"license": "GPLv3 or later",
|
||||
"description": "NodeBB Forum",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"homepage": "http://www.nodebb.org",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
275
src/upgrade.js
275
src/upgrade.js
@@ -7,6 +7,8 @@ var db = require('./database'),
|
||||
User = require('./user'),
|
||||
Topics = require('./topics'),
|
||||
Utils = require('../public/src/utils'),
|
||||
notifications = require('./notifications'),
|
||||
categories = require('./categories'),
|
||||
|
||||
Upgrade = {},
|
||||
|
||||
@@ -37,6 +39,279 @@ Upgrade.upgrade = function(callback) {
|
||||
next();
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = new Date(2013, 9, 3).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
async.series([
|
||||
function(next) {
|
||||
db.keys('uid:*:notifications:flag', function(err, keys) {
|
||||
if (keys.length > 0) {
|
||||
winston.info('[2013/10/03] Removing deprecated Notification Flags');
|
||||
async.each(keys, function(key, next) {
|
||||
db.delete(key, next);
|
||||
}, next);
|
||||
} else {
|
||||
winston.info('[2013/10/03] No Notification Flags found. Good.');
|
||||
next();
|
||||
}
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
winston.info('[2013/10/03] Updating Notifications');
|
||||
db.keys('uid:*:notifications:*', function(err, keys) {
|
||||
async.each(keys, function(key, next) {
|
||||
db.getSortedSetRange(key, 0, -1, function(err, nids) {
|
||||
async.each(nids, function(nid, next) {
|
||||
notifications.get(nid, null, function(notif_data) {
|
||||
if (notif_data) {
|
||||
db.sortedSetAdd(key, notif_data.datetime, nid, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
}, next);
|
||||
});
|
||||
}, next);
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
db.keys('notifications:*', function(err, keys) {
|
||||
if (keys.length > 0) {
|
||||
winston.info('[2013/10/03] Removing Notification Scores');
|
||||
async.each(keys, function(key, next) {
|
||||
if (key === 'notifications:next_nid') {
|
||||
return next();
|
||||
}
|
||||
|
||||
db.deleteObjectField(key, 'score', next);
|
||||
}, next);
|
||||
} else {
|
||||
winston.info('[2013/10/03] No Notification Scores found. Good.');
|
||||
next();
|
||||
}
|
||||
});
|
||||
}
|
||||
], next);
|
||||
} else {
|
||||
winston.info('[2013/10/03] Updates to Notifications skipped.');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = new Date(2013, 9, 23).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
db.keys('notifications:*', function(err, keys) {
|
||||
|
||||
keys = keys.filter(function(key) {
|
||||
if (key === 'notifications:next_nid') {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}).map(function(key) {
|
||||
return key.slice(14);
|
||||
});
|
||||
|
||||
winston.info('[2013/10/23] Adding existing notifications to set');
|
||||
|
||||
if(keys && Array.isArray(keys)) {
|
||||
async.each(keys, function(key, cb) {
|
||||
db.setAdd('notifications', key, cb);
|
||||
}, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
winston.info('[2013/10/23] Updates to Notifications skipped.');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = new Date(2013, 10, 11).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
db.setObjectField('config', 'postDelay', 10, function(err, success) {
|
||||
winston.info('[2013/11/11] Updated postDelay to 10 seconds.');
|
||||
next();
|
||||
});
|
||||
} else {
|
||||
winston.info('[2013/11/11] Update to postDelay skipped.');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = new Date(2013, 10, 22).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
db.keys('category:*', function(err, categories) {
|
||||
async.each(categories, function(categoryStr, next) {
|
||||
var hex;
|
||||
db.getObject(categoryStr, function(err, categoryObj) {
|
||||
switch(categoryObj.blockclass) {
|
||||
case 'category-purple':
|
||||
hex = '#ab1290';
|
||||
break;
|
||||
|
||||
case 'category-darkblue':
|
||||
hex = '#004c66';
|
||||
break;
|
||||
|
||||
case 'category-blue':
|
||||
hex = '#0059b2';
|
||||
break;
|
||||
|
||||
case 'category-darkgreen':
|
||||
hex = '#004000';
|
||||
break;
|
||||
|
||||
case 'category-orange':
|
||||
hex = '#ff7a4d';
|
||||
break;
|
||||
|
||||
default:
|
||||
hex = '#0059b2';
|
||||
break;
|
||||
}
|
||||
|
||||
db.setObjectField(categoryStr, 'bgColor', hex, next);
|
||||
db.deleteObjectField(categoryStr, 'blockclass');
|
||||
});
|
||||
}, function() {
|
||||
winston.info('[2013/11/22] Updated Category colours.');
|
||||
next();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
winston.info('[2013/11/22] Update to Category colours skipped.');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = new Date(2013, 10, 26).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
categories.getAllCategories(0, function(err, categories) {
|
||||
|
||||
function updateIcon(category, next) {
|
||||
var icon = '';
|
||||
if(category.icon === 'icon-lightbulb') {
|
||||
icon = 'fa-lightbulb-o';
|
||||
} else if(category.icon === 'icon-plus-sign') {
|
||||
icon = 'fa-plus';
|
||||
} else if(category.icon === 'icon-screenshot') {
|
||||
icon = 'fa-crosshairs';
|
||||
} else {
|
||||
icon = category.icon.replace('icon-', 'fa-');
|
||||
}
|
||||
|
||||
db.setObjectField('category:' + category.cid, 'icon', icon, next);
|
||||
}
|
||||
|
||||
async.each(categories.categories, updateIcon, function(err) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
winston.info('[2013/11/26] Updated Category icons.');
|
||||
next();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
winston.info('[2013/11/26] Update to Category icons skipped.');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
|
||||
function updateKeyToHash(key, next) {
|
||||
db.get(key, function(err, value) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if(value === null) {
|
||||
db.setObjectField('global', newKeys[key], initialValues[key], next);
|
||||
} else {
|
||||
db.setObjectField('global', newKeys[key], value, next);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
thisSchemaDate = new Date(2013, 11, 2).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
var keys = [
|
||||
'global:next_user_id',
|
||||
'next_topic_id',
|
||||
'next_gid',
|
||||
'notifications:next_nid',
|
||||
'global:next_category_id',
|
||||
'global:next_message_id',
|
||||
'global:next_post_id',
|
||||
'usercount',
|
||||
'totaltopiccount',
|
||||
'totalpostcount'
|
||||
];
|
||||
|
||||
var newKeys = {
|
||||
'global:next_user_id':'nextUid',
|
||||
'next_topic_id':'nextTid',
|
||||
'next_gid':'nextGid',
|
||||
'notifications:next_nid':'nextNid',
|
||||
'global:next_category_id':'nextCid',
|
||||
'global:next_message_id':'nextMid',
|
||||
'global:next_post_id':'nextPid',
|
||||
'usercount':'userCount',
|
||||
'totaltopiccount':'topicCount',
|
||||
'totalpostcount':'postCount'
|
||||
};
|
||||
|
||||
var initialValues = {
|
||||
'global:next_user_id': 1,
|
||||
'next_topic_id': 0,
|
||||
'next_gid': 1,
|
||||
'notifications:next_nid': 0,
|
||||
'global:next_category_id': 12,
|
||||
'global:next_message_id': 0,
|
||||
'global:next_post_id': 0,
|
||||
'usercount': 1,
|
||||
'totaltopiccount': 0,
|
||||
'totalpostcount': 0
|
||||
};
|
||||
|
||||
async.each(keys, updateKeyToHash, function(err) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
winston.info('[2013/12/2] Updated global keys to hash.');
|
||||
next();
|
||||
});
|
||||
|
||||
} else {
|
||||
winston.info('[2013/12/2] Update to global keys skipped');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = new Date(2013, 11, 11).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
|
||||
db.setObjectField('config', 'allowGuestSearching', '0', function(err){
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
winston.info('[2013/12/11] Updated guest search config.');
|
||||
next();
|
||||
});
|
||||
} else {
|
||||
winston.info('[2013/12/11] Update to guest search skipped');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = new Date(2013, 11, 31).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
|
||||
Reference in New Issue
Block a user