Skip to content

Node.js based forum software built for the modern web

fix \uff0e in emails

barisusaklic6a05930aac1
diff --git a/src/upgrade.js b/src/upgrade.js
index c6574ab574..0d6e0a8312 100644
--- a/src/upgrade.js
+++ b/src/upgrade.js
@@ -21,7 +21,7 @@ var db = require('./database'),
schemaDate, thisSchemaDate,
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
- latestSchema = Date.UTC(2015, 4, 7);
+ latestSchema = Date.UTC(2015, 4, 8);
Upgrade.check = function(callback) {
db.get('schemaDate', function(err, value) {
@@ -1008,6 +1008,39 @@ Upgrade.upgrade = function(callback) {
winston.info('[2015/05/07] Upgrading uid mappings to sorted set skipped');
next();
}
+ },
+ function(next) {
+ if (schemaDate < thisSchemaDate) {
+ updatesMade = true;
+ winston.info('[2015/05/08] Fixing emails');
+
+ db.getSortedSetRangeWithScores('email:uid', 0, -1, function(err, users) {
+ if (err) {
+ return next(err);
+ }
+
+ var newEmail = user.value.replace(/\uff0E/g, '.');
+ if (newEmail === user.value) {
+ return next();
+ }
+ async.series([
+ async.apply(db.sortedSetRemove, 'email:uid', user.value),
+ async.apply(db.sortedSetAdd, 'email:uid', user.score, newEmail)
+ ], next);
+
+ }, function(err) {
+ if (err) {
+ return next(err);
+ }
+ winston.info('[2015/05/08] Fixing emails done');
+ Upgrade.update(thisSchemaDate, next);
+ });
+ });
+
+ } else {
+ winston.info('[2015/05/08] Fixing emails skipped');
+ next();
+ }
}
// Add new schema updates here