Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sendFCM function not using @rocket.chat/server-fetch #32739

Merged
merged 8 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fast-buttons-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Fixed an issue where FCM actions did not respect environment's proxy settings
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]>;
KevLehman marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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
Loading