chetbox / boopjs

Formerly boopjs.com
https://chetbox.com
1 stars 0 forks source link

Release: Opt out of emails #313

Closed chetbox closed 8 years ago

chetbox commented 8 years ago

Migrated using script

db = require './db'

db.v2.users.scan
  FilterExpression: 'attribute_type(emails, :set)'
  ExpressionAttributeValues:
    ':set': 'SS'
.then (resp) ->
  resp.Items
.mapSeries (user) ->
  new_emails = user.emails.values.reduce (obj, address) ->
    obj[address] =
      verified: true
      primary: true
    obj
  , {}
  console.log user.username, new_emails
  db.v2.users.update
    Key: { id: user.id }
    UpdateExpression: 'SET emails = :emails'
    ExpressionAttributeValues:
      ':emails': new_emails
.then ->
  console.log 'Done.'