From 005a918c6d2648ca8de2bcd7623023ed306c6cbc Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Mon, 10 Oct 2022 08:21:37 -0600 Subject: [PATCH] Switch to badges_awarded --- .../add-new-notification-preference.ts | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/functions/src/scripts/add-new-notification-preference.ts b/functions/src/scripts/add-new-notification-preference.ts index bbdb10d6..f72692f7 100644 --- a/functions/src/scripts/add-new-notification-preference.ts +++ b/functions/src/scripts/add-new-notification-preference.ts @@ -1,38 +1,24 @@ import * as admin from 'firebase-admin' import { initAdmin } from './script-init' -import { filterDefined } from 'common/lib/util/array' -import { getPrivateUser } from '../utils' +import { getAllPrivateUsers } from 'functions/src/utils' initAdmin() const firestore = admin.firestore() async function main() { - // const privateUsers = await getAllPrivateUsers() - const privateUsers = filterDefined([ - await getPrivateUser('ddSo9ALC15N9FAZdKdA2qE3iIvH3'), - ]) + const privateUsers = await getAllPrivateUsers() await Promise.all( privateUsers.map((privateUser) => { if (!privateUser.id) return Promise.resolve() - return firestore - .collection('private-users') - .doc(privateUser.id) - .update({ - notificationPreferences: { - ...privateUser.notificationPreferences, - badges_awarded: ['browser'], - }, - }) - if (privateUser.notificationPreferences.opt_out_all === undefined) { - console.log('updating opt out all', privateUser.id) + if (privateUser.notificationPreferences.badges_awarded === undefined) { return firestore .collection('private-users') .doc(privateUser.id) .update({ notificationPreferences: { ...privateUser.notificationPreferences, - opt_out_all: [], + badges_awarded: ['browser'], }, }) }