@@ -5,7 +5,7 @@ import * as fs from "fs"
5
5
import { Timestamp } from "../firebase"
6
6
import { getNextDigestAt , getNotificationStartDate } from "./helpers"
7
7
import { startOfDay } from "date-fns"
8
- import { TestimonySubmissionNotificationFields } from "./types"
8
+ import { TestimonySubmissionNotificationFields , Profile } from "./types"
9
9
import {
10
10
BillDigest ,
11
11
NotificationEmailDigest ,
@@ -15,7 +15,6 @@ import {
15
15
import { prepareHandlebars } from "../email/handlebarsHelpers"
16
16
import { getAuth } from "firebase-admin/auth"
17
17
import { Frequency } from "../auth/types"
18
- import { Profile } from "../../../components/db/profile/types"
19
18
20
19
const NUM_BILLS_TO_DISPLAY = 4
21
20
const NUM_USERS_TO_DISPLAY = 4
@@ -51,8 +50,8 @@ const deliverEmailNotifications = async () => {
51
50
. get ( )
52
51
53
52
const emailPromises = profilesSnapshot . docs . map ( async profileDoc => {
54
- const user = profileDoc . data ( ) as Profile
55
- if ( ! user || ! user . notificationFrequency ) {
53
+ const profile = profileDoc . data ( ) as Profile
54
+ if ( ! profile || ! profile . notificationFrequency ) {
56
55
console . log (
57
56
`User ${ profileDoc . id } has no notificationFrequency - skipping`
58
57
)
@@ -70,7 +69,7 @@ const deliverEmailNotifications = async () => {
70
69
const digestData = await buildDigestData (
71
70
profileDoc . id ,
72
71
now ,
73
- user . notificationFrequency
72
+ profile . notificationFrequency
74
73
)
75
74
76
75
// If there are no new notifications, don't send an email
@@ -98,7 +97,7 @@ const deliverEmailNotifications = async () => {
98
97
console . log ( `Saved email message to user ${ profileDoc . id } ` )
99
98
}
100
99
101
- const nextDigestAt = getNextDigestAt ( user . notificationFrequency )
100
+ const nextDigestAt = getNextDigestAt ( profile . notificationFrequency )
102
101
await profileDoc . ref . update ( { nextDigestAt } )
103
102
104
103
console . log ( `Updated nextDigestAt for ${ profileDoc . id } to ${ nextDigestAt } ` )
0 commit comments