1
1
import * as functions from "firebase-functions"
2
- import * as admin from "firebase-admin"
3
2
import * as handlebars from "handlebars"
4
3
import * as fs from "fs"
5
- import { Timestamp } from "../firebase"
4
+ import { auth , db , Timestamp } from "../firebase"
6
5
import { getNextDigestAt , getNotificationStartDate } from "./helpers"
7
6
import { startOfDay } from "date-fns"
8
7
import { TestimonySubmissionNotificationFields , Profile } from "./types"
@@ -13,17 +12,13 @@ import {
13
12
UserDigest
14
13
} from "./emailTypes"
15
14
import { prepareHandlebars } from "../email/handlebarsHelpers"
16
- import { getAuth } from "firebase-admin/auth"
17
15
import { Frequency } from "../auth/types"
18
16
19
17
const NUM_BILLS_TO_DISPLAY = 4
20
18
const NUM_USERS_TO_DISPLAY = 4
21
19
const NUM_TESTIMONIES_TO_DISPLAY = 6
22
20
const EMAIL_TEMPLATE_PATH = "../email/digestEmail.handlebars"
23
21
24
- // Get a reference to the Firestore database
25
- const db = admin . firestore ( )
26
- const auth = getAuth ( )
27
22
const path = require ( "path" )
28
23
29
24
const getVerifiedUserEmail = async ( uid : string ) => {
@@ -103,7 +98,9 @@ const deliverEmailNotifications = async () => {
103
98
batch . update ( profileDoc . ref , { nextDigestAt } )
104
99
await batch . commit ( )
105
100
106
- console . log ( `Updated nextDigestAt for ${ profileDoc . id } to ${ nextDigestAt } ` )
101
+ console . log (
102
+ `Updated nextDigestAt for ${ profileDoc . id } to ${ nextDigestAt ?. toDate ( ) } `
103
+ )
107
104
} )
108
105
109
106
// Wait for all email documents to be created
0 commit comments