Skip to content

Commit

Permalink
fix: fcm function not using our serverFetch
Browse files Browse the repository at this point in the history
  • Loading branch information
debdutdeb committed Jul 8, 2024
1 parent aafd7da commit a295d81
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/meteor/app/push/server/fcm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { serverFetch as fetch } from '@rocket.chat/server-fetch';
import EJSON from 'ejson';
import fetch from 'node-fetch';
import type { RequestInit, Response } from 'node-fetch';
import type { Response } from 'node-fetch';

import type { PendingPushNotification } from './definition';
import { logger } from './logger';
Expand Down Expand Up @@ -54,6 +54,8 @@ type FCMError = {
};
};

type FetchOptions = NonNullable<Parameters<typeof fetch>[1]>;

/**
* Send a push notification using Firebase Cloud Messaging (FCM).
* implements the Firebase Cloud Messaging HTTP v1 API, and all of its retry logic,
Expand All @@ -65,7 +67,7 @@ type FCMError = {
* - For 429 errors: retry after waiting for the duration set in the retry-after header. If no retry-after header is set, default to 60 seconds.
* - For 500 errors: retry with exponential backoff.
*/
async function fetchWithRetry(url: string, _removeToken: () => void, options: RequestInit, retries = 0): Promise<Response> {
async function fetchWithRetry(url: string, _removeToken: () => void, options: FetchOptions, retries = 0): Promise<Response> {
const MAX_RETRIES = 5;
const response = await fetch(url, options);

Expand Down

0 comments on commit a295d81

Please sign in to comment.