-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
962b7f7
commit fddb783
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
const async = require('async'); | ||
const db = require('../../database'); | ||
const user = require('../../user'); | ||
|
||
module.exports = { | ||
name: 'Delete username email history for deleted users', | ||
timestamp: Date.UTC(2019, 2, 25), | ||
method: async function (callback) { | ||
const progress = this.progress; | ||
var currentUid = 1; | ||
db.getObjectField('global', 'nextUid', function (err, nextUid) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
progress.total = nextUid; | ||
async.whilst(function () { | ||
return currentUid < nextUid; | ||
}, | ||
function (next) { | ||
progress.incr(); | ||
user.exists(currentUid, function (err, exists) { | ||
if (err) { | ||
return next(err); | ||
} | ||
if (exists) { | ||
currentUid += 1; | ||
return next(); | ||
} | ||
db.deleteAll(['user:' + currentUid + ':usernames', 'user:' + currentUid + ':emails'], function (err) { | ||
if (err) { | ||
return next(err); | ||
} | ||
currentUid += 1; | ||
next(); | ||
}); | ||
}); | ||
}, | ||
function (err) { | ||
callback(err); | ||
}); | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters