@@ -22,20 +22,14 @@ import {
22
22
AuthorizedHttp2Client , Http2SessionHandler , Http2RequestConfig ,
23
23
} from '../utils/api-request' ;
24
24
import { createFirebaseError , getErrorCode } from './messaging-errors-internal' ;
25
- import { SubRequest , BatchRequestClient } from './batch-request-internal' ;
26
25
import { getSdkVersion } from '../utils/index' ;
27
- import { SendResponse , BatchResponse } from './messaging-api' ;
26
+ import { SendResponse } from './messaging-api' ;
28
27
29
28
30
29
// FCM backend constants
31
30
const FIREBASE_MESSAGING_TIMEOUT = 15000 ;
32
- const FIREBASE_MESSAGING_BATCH_URL = 'https://fcm.googleapis.com/batch' ;
33
31
const FIREBASE_MESSAGING_HTTP_METHOD : HttpMethod = 'POST' ;
34
32
const FIREBASE_MESSAGING_HEADERS = {
35
- 'X-Firebase-Client' : `fire-admin-node/${ getSdkVersion ( ) } ` ,
36
- 'X-Goog-Api-Client' : `gl-node/${ process . versions . node } fire-admin/${ getSdkVersion ( ) } `
37
- } ;
38
- const LEGACY_FIREBASE_MESSAGING_HEADERS = {
39
33
'X-Firebase-Client' : `fire-admin-node/${ getSdkVersion ( ) } ` ,
40
34
'X-Goog-Api-Client' : `gl-node/${ process . versions . node } fire-admin/${ getSdkVersion ( ) } ` ,
41
35
'access_token_auth' : 'true' ,
@@ -48,7 +42,6 @@ const LEGACY_FIREBASE_MESSAGING_HEADERS = {
48
42
export class FirebaseMessagingRequestHandler {
49
43
private readonly httpClient : AuthorizedHttpClient ;
50
44
private readonly http2Client : AuthorizedHttp2Client ;
51
- private readonly batchClient : BatchRequestClient ;
52
45
53
46
/**
54
47
* @param app - The app used to fetch access tokens to sign API requests.
@@ -57,8 +50,6 @@ export class FirebaseMessagingRequestHandler {
57
50
constructor ( app : App ) {
58
51
this . httpClient = new AuthorizedHttpClient ( app as FirebaseApp ) ;
59
52
this . http2Client = new AuthorizedHttp2Client ( app as FirebaseApp ) ;
60
- this . batchClient = new BatchRequestClient (
61
- this . httpClient , FIREBASE_MESSAGING_BATCH_URL , FIREBASE_MESSAGING_HEADERS ) ;
62
53
}
63
54
64
55
/**
@@ -74,7 +65,7 @@ export class FirebaseMessagingRequestHandler {
74
65
method : FIREBASE_MESSAGING_HTTP_METHOD ,
75
66
url : `https://${ host } ${ path } ` ,
76
67
data : requestData ,
77
- headers : LEGACY_FIREBASE_MESSAGING_HEADERS ,
68
+ headers : FIREBASE_MESSAGING_HEADERS ,
78
69
timeout : FIREBASE_MESSAGING_TIMEOUT ,
79
70
} ;
80
71
return this . httpClient . send ( request ) . then ( ( response ) => {
@@ -116,7 +107,7 @@ export class FirebaseMessagingRequestHandler {
116
107
method : FIREBASE_MESSAGING_HTTP_METHOD ,
117
108
url : `https://${ host } ${ path } ` ,
118
109
data : requestData ,
119
- headers : LEGACY_FIREBASE_MESSAGING_HEADERS ,
110
+ headers : FIREBASE_MESSAGING_HEADERS ,
120
111
timeout : FIREBASE_MESSAGING_TIMEOUT ,
121
112
} ;
122
113
return this . httpClient . send ( request ) . then ( ( response ) => {
@@ -146,7 +137,7 @@ export class FirebaseMessagingRequestHandler {
146
137
method : FIREBASE_MESSAGING_HTTP_METHOD ,
147
138
url : `https://${ host } ${ path } ` ,
148
139
data : requestData ,
149
- headers : LEGACY_FIREBASE_MESSAGING_HEADERS ,
140
+ headers : FIREBASE_MESSAGING_HEADERS ,
150
141
timeout : FIREBASE_MESSAGING_TIMEOUT ,
151
142
http2SessionHandler : http2SessionHandler
152
143
} ;
@@ -162,35 +153,6 @@ export class FirebaseMessagingRequestHandler {
162
153
} ) ;
163
154
}
164
155
165
- /**
166
- * Sends the given array of sub requests as a single batch to FCM, and parses the result into
167
- * a `BatchResponse` object.
168
- *
169
- * @param requests - An array of sub requests to send.
170
- * @returns A promise that resolves when the send operation is complete.
171
- */
172
- public sendBatchRequest ( requests : SubRequest [ ] ) : Promise < BatchResponse > {
173
- return this . batchClient . send ( requests )
174
- . then ( ( responses : RequestResponse [ ] ) => {
175
- return responses . map ( ( part : RequestResponse ) => {
176
- return this . buildSendResponse ( part ) ;
177
- } ) ;
178
- } ) . then ( ( responses : SendResponse [ ] ) => {
179
- const successCount : number = responses . filter ( ( resp ) => resp . success ) . length ;
180
- return {
181
- responses,
182
- successCount,
183
- failureCount : responses . length - successCount ,
184
- } ;
185
- } ) . catch ( ( err ) => {
186
- if ( err instanceof RequestResponseError ) {
187
- throw createFirebaseError ( err ) ;
188
- }
189
- // Re-throw the error if it already has the proper format.
190
- throw err ;
191
- } ) ;
192
- }
193
-
194
156
private buildSendResponse ( response : RequestResponse ) : SendResponse {
195
157
const result : SendResponse = {
196
158
success : response . status === 200 ,
0 commit comments