@@ -7,13 +7,18 @@ import { config } from '~/config';
7
7
const fs = require ( 'fs' ) ;
8
8
9
9
const keyFilePath = config . fcmGoogleApiPathToAuthJson ;
10
+ console . log ( 'keyFilePath' , keyFilePath )
10
11
const key = JSON . parse ( fs . readFileSync ( keyFilePath , 'utf8' ) ) ;
12
+ console . log ( 'key' , key )
11
13
12
14
const fcmGoogleApiPath = `https://fcm.googleapis.com/v1/projects/${ key . project_id } /messages:send`
15
+ console . log ( 'fcmGoogleApiPath' , fcmGoogleApiPath )
13
16
14
17
export const sendFcmNewEpisodeDetectedNotification = async ( options : SendNotificationOptions ) => {
18
+ console . log ( 'sendFcmNewEpisodeDetectedNotification' , options )
15
19
const { podcastId, podcastShrunkImageUrl, podcastFullImageUrl, episodeFullImageUrl, episodeId } = options
16
20
const fcmTokens = await getFCMTokensForPodcastId ( podcastId )
21
+ console . log ( 'sendFcmNewEpisodeDetectedNotification fcmTokens' , fcmTokens . length )
17
22
const podcastTitle = options . podcastTitle || 'Untitled Podcast'
18
23
const episodeTitle = options . episodeTitle || 'Untitled Episode'
19
24
const title = podcastTitle
@@ -37,8 +42,10 @@ export const sendFcmNewEpisodeDetectedNotification = async (options: SendNotific
37
42
}
38
43
39
44
export const sendFcmLiveItemLiveDetectedNotification = async ( options : SendNotificationOptions ) => {
45
+ console . log ( 'sendFcmLiveItemLiveDetectedNotification' , options )
40
46
const { podcastId, podcastShrunkImageUrl, podcastFullImageUrl, episodeFullImageUrl, episodeId } = options
41
47
const fcmTokens = await getFCMTokensForPodcastId ( podcastId )
48
+ console . log ( 'sendFcmLiveItemLiveDetectedNotification fcmTokens' , fcmTokens . length )
42
49
const podcastTitle = options . podcastTitle || 'Untitled Podcast'
43
50
const episodeTitle = options . episodeTitle || 'Livestream starting'
44
51
const title = `LIVE: ${ podcastTitle } `
@@ -73,11 +80,13 @@ export const sendFCMGoogleApiNotification = async (
73
80
episodeImage ?: string ,
74
81
episodeId ?: string
75
82
) => {
83
+ console . log ( 'sendFCMGoogleApiNotification' , fcmTokens . length , title , podcastId )
76
84
const accessToken = await generateAccessToken ( )
77
85
78
86
if ( ! fcmTokens || fcmTokens . length === 0 ) return
79
87
80
88
for ( const fcmToken of fcmTokens ) {
89
+ console . log ( 'fcmToken' , fcmToken )
81
90
const imageUrl = episodeImage || podcastImage
82
91
try {
83
92
await request ( fcmGoogleApiPath , {
0 commit comments