Skip to content

Commit

Permalink
Merge pull request #765 from podverse/develop
Browse files Browse the repository at this point in the history
Release v4.16.23
  • Loading branch information
mitchdowney authored Sep 11, 2024
2 parents 98edb3e + a76d85b commit 42cba67
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "podverse-api",
"version": "4.16.22",
"version": "4.16.23",
"description": "Data API, database migration scripts, and backend services for all Podverse models.",
"private": true,
"contributors": [
Expand Down
9 changes: 9 additions & 0 deletions src/lib/notifications/fcmGoogleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ import { config } from '~/config';
const fs = require('fs');

const keyFilePath = config.fcmGoogleApiPathToAuthJson;
console.log('keyFilePath', keyFilePath)
const key = JSON.parse(fs.readFileSync(keyFilePath, 'utf8'));
console.log('key', key)

const fcmGoogleApiPath = `https://fcm.googleapis.com/v1/projects/${key.project_id}/messages:send`
console.log('fcmGoogleApiPath', fcmGoogleApiPath)

export const sendFcmNewEpisodeDetectedNotification = async (options: SendNotificationOptions) => {
console.log('sendFcmNewEpisodeDetectedNotification', options)
const { podcastId, podcastShrunkImageUrl, podcastFullImageUrl, episodeFullImageUrl, episodeId } = options
const fcmTokens = await getFCMTokensForPodcastId(podcastId)
console.log('sendFcmNewEpisodeDetectedNotification fcmTokens', fcmTokens.length)
const podcastTitle = options.podcastTitle || 'Untitled Podcast'
const episodeTitle = options.episodeTitle || 'Untitled Episode'
const title = podcastTitle
Expand All @@ -37,8 +42,10 @@ export const sendFcmNewEpisodeDetectedNotification = async (options: SendNotific
}

export const sendFcmLiveItemLiveDetectedNotification = async (options: SendNotificationOptions) => {
console.log('sendFcmLiveItemLiveDetectedNotification', options)
const { podcastId, podcastShrunkImageUrl, podcastFullImageUrl, episodeFullImageUrl, episodeId } = options
const fcmTokens = await getFCMTokensForPodcastId(podcastId)
console.log('sendFcmLiveItemLiveDetectedNotification fcmTokens', fcmTokens.length)
const podcastTitle = options.podcastTitle || 'Untitled Podcast'
const episodeTitle = options.episodeTitle || 'Livestream starting'
const title = `LIVE: ${podcastTitle}`
Expand Down Expand Up @@ -73,11 +80,13 @@ export const sendFCMGoogleApiNotification = async (
episodeImage?: string,
episodeId?: string
) => {
console.log('sendFCMGoogleApiNotification', fcmTokens.length, title, podcastId)
const accessToken = await generateAccessToken()

if (!fcmTokens || fcmTokens.length === 0) return

for (const fcmToken of fcmTokens) {
console.log('fcmToken', fcmToken)
const imageUrl = episodeImage || podcastImage
try {
await request(fcmGoogleApiPath, {
Expand Down

0 comments on commit 42cba67

Please sign in to comment.