Skip to content

Instantly share code, notes, and snippets.

@NicolasGeraud
Created October 11, 2018 08:33
Show Gist options
  • Save NicolasGeraud/0a085c47fe48c7660df7689031cf411c to your computer and use it in GitHub Desktop.
Save NicolasGeraud/0a085c47fe48c7660df7689031cf411c to your computer and use it in GitHub Desktop.
unanonymize user emails
db.users.find().forEach(
function(user) {
if (user.email && user.email.endsWith(".anon")) {
var newEmail = user.email.slice(0, user.email.length - 5)
print(user.email + " => " + newEmail);
db.users.updateOne(
{ _id: user._id },
{ $set:{ 'email': newEmail } },
{ upsert: false });
}
});
db.genericnotificationconfigs.find({'notifier': 'default-email'}).forEach(
function(notif) {
if (notif.config && notif.config.endsWith(".anon")) {
var newEmail = notif.config.slice(0, notif.config.length - 5)
print(notif.config + " => " + newEmail);
db.genericnotificationconfigs.updateOne(
{ _id: notif._id },
{ $set:{ 'config': newEmail } },
{ upsert: false });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment