From 11d93c146d566b9b408175117e4dc70e083508a2 Mon Sep 17 00:00:00 2001 From: Debdut Chakraborty Date: Mon, 8 Jul 2024 14:53:23 +0530 Subject: [PATCH 1/4] fix: fcm function not using our serverFetch --- apps/meteor/app/push/server/fcm.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/meteor/app/push/server/fcm.ts b/apps/meteor/app/push/server/fcm.ts index 87ced6e130df..9b17e9c42691 100644 --- a/apps/meteor/app/push/server/fcm.ts +++ b/apps/meteor/app/push/server/fcm.ts @@ -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'; @@ -54,6 +54,8 @@ type FCMError = { }; }; +type FetchOptions = NonNullable[1]>; + /** * Send a push notification using Firebase Cloud Messaging (FCM). * implements the Firebase Cloud Messaging HTTP v1 API, and all of its retry logic, @@ -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 { +async function fetchWithRetry(url: string, _removeToken: () => void, options: FetchOptions, retries = 0): Promise { const MAX_RETRIES = 5; const response = await fetch(url, options); From 1dbe9011ce304229713a5b12149e0632d9eb662c Mon Sep 17 00:00:00 2001 From: Debdut Chakraborty Date: Mon, 8 Jul 2024 14:55:13 +0530 Subject: [PATCH 2/4] add changeset --- .changeset/fast-buttons-shake.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fast-buttons-shake.md diff --git a/.changeset/fast-buttons-shake.md b/.changeset/fast-buttons-shake.md new file mode 100644 index 000000000000..6281fc9941ec --- /dev/null +++ b/.changeset/fast-buttons-shake.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': minor +--- + +Fixed an issue where FCM actions did not respect environment's proxy settings From 5837d2377769592e64af872bc792a6f437b22f16 Mon Sep 17 00:00:00 2001 From: Debdut Chakraborty Date: Mon, 8 Jul 2024 19:59:19 +0530 Subject: [PATCH 3/4] export type from package --- apps/meteor/app/push/server/fcm.ts | 6 ++---- packages/server-fetch/src/index.ts | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/meteor/app/push/server/fcm.ts b/apps/meteor/app/push/server/fcm.ts index 9b17e9c42691..d10cb7000386 100644 --- a/apps/meteor/app/push/server/fcm.ts +++ b/apps/meteor/app/push/server/fcm.ts @@ -1,4 +1,4 @@ -import { serverFetch as fetch } from '@rocket.chat/server-fetch'; +import { serverFetch as fetch, ExtendedFetchOptions } from '@rocket.chat/server-fetch'; import EJSON from 'ejson'; import type { Response } from 'node-fetch'; @@ -54,8 +54,6 @@ type FCMError = { }; }; -type FetchOptions = NonNullable[1]>; - /** * Send a push notification using Firebase Cloud Messaging (FCM). * implements the Firebase Cloud Messaging HTTP v1 API, and all of its retry logic, @@ -67,7 +65,7 @@ type FetchOptions = NonNullable[1]>; * - 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: FetchOptions, retries = 0): Promise { +async function fetchWithRetry(url: string, _removeToken: () => void, options: ExtendedFetchOptions, retries = 0): Promise { const MAX_RETRIES = 5; const response = await fetch(url, options); diff --git a/packages/server-fetch/src/index.ts b/packages/server-fetch/src/index.ts index 2fcb9cb19bf5..a04343c1bd51 100644 --- a/packages/server-fetch/src/index.ts +++ b/packages/server-fetch/src/index.ts @@ -72,3 +72,5 @@ export function serverFetch(input: string, options?: ExtendedFetchOptions, allow } export { Response } from 'node-fetch'; + +export { ExtendedFetchOptions }; From f1161862441cc752b36b247e6aab9076499c7e8a Mon Sep 17 00:00:00 2001 From: Debdut Chakraborty Date: Mon, 8 Jul 2024 22:27:26 +0530 Subject: [PATCH 4/4] :/ --- apps/meteor/app/push/server/fcm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/app/push/server/fcm.ts b/apps/meteor/app/push/server/fcm.ts index d10cb7000386..6015780f118f 100644 --- a/apps/meteor/app/push/server/fcm.ts +++ b/apps/meteor/app/push/server/fcm.ts @@ -1,4 +1,4 @@ -import { serverFetch as fetch, ExtendedFetchOptions } from '@rocket.chat/server-fetch'; +import { serverFetch as fetch, type ExtendedFetchOptions } from '@rocket.chat/server-fetch'; import EJSON from 'ejson'; import type { Response } from 'node-fetch';