fix \uff0e in emails

v1.18.x
barisusakli 10 years ago
parent 7b550b13b9
commit c6a05930aa

@ -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

Loading…
Cancel
Save