11import * as functions from "firebase-functions"
2- import * as admin from "firebase-admin"
32import * as handlebars from "handlebars"
43import * as fs from "fs"
5- import { Timestamp } from "../firebase"
4+ import { auth , db , Timestamp } from "../firebase"
65import { getNextDigestAt , getNotificationStartDate } from "./helpers"
76import { startOfDay } from "date-fns"
87import { TestimonySubmissionNotificationFields , Profile } from "./types"
@@ -13,17 +12,13 @@ import {
1312 UserDigest
1413} from "./emailTypes"
1514import { prepareHandlebars } from "../email/handlebarsHelpers"
16- import { getAuth } from "firebase-admin/auth"
1715import { Frequency } from "../auth/types"
1816
1917const NUM_BILLS_TO_DISPLAY = 4
2018const NUM_USERS_TO_DISPLAY = 4
2119const NUM_TESTIMONIES_TO_DISPLAY = 6
2220const EMAIL_TEMPLATE_PATH = "../email/digestEmail.handlebars"
2321
24- // Get a reference to the Firestore database
25- const db = admin . firestore ( )
26- const auth = getAuth ( )
2722const path = require ( "path" )
2823
2924const getVerifiedUserEmail = async ( uid : string ) => {
@@ -103,7 +98,9 @@ const deliverEmailNotifications = async () => {
10398 batch . update ( profileDoc . ref , { nextDigestAt } )
10499 await batch . commit ( )
105100
106- console . log ( `Updated nextDigestAt for ${ profileDoc . id } to ${ nextDigestAt } ` )
101+ console . log (
102+ `Updated nextDigestAt for ${ profileDoc . id } to ${ nextDigestAt ?. toDate ( ) } `
103+ )
107104 } )
108105
109106 // Wait for all email documents to be created
0 commit comments