@@ -45,7 +45,8 @@ export const sendTelegram = async ({
4545 appMaxPrice = MAX_DESIRED_APP_ORDER_PRICE ,
4646 workerpoolMaxPrice = MAX_DESIRED_WORKERPOOL_ORDER_PRICE ,
4747 protectedData,
48- bulkRequest,
48+ grantedAccess,
49+ maxProtectedDataPerTask,
4950 useVoucher = false ,
5051} : IExecConsumer &
5152 SubgraphConsumer &
@@ -65,19 +66,6 @@ export const sendTelegram = async ({
6566 . required ( )
6667 . label ( 'WorkerpoolAddressOrEns' )
6768 . validateSync ( workerpoolAddressOrEns ) ;
68-
69- if ( bulkRequest ) {
70- if ( ! bulkRequest . bulkRequest ) {
71- throw new Error ( 'bulkRequest is required' ) ;
72- }
73- const processBulkRequestResponse : ProcessBulkRequestResponse =
74- await dataProtector . processBulkRequest ( {
75- bulkRequest : bulkRequest . bulkRequest ,
76- useVoucher : vUseVoucher ,
77- workerpool : vWorkerpoolAddressOrEns ,
78- } ) ;
79- return processBulkRequestResponse ;
80- }
8169 const vSenderName = senderNameSchema ( )
8270 . label ( 'senderName' )
8371 . validateSync ( senderName ) ;
@@ -106,21 +94,6 @@ export const sendTelegram = async ({
10694 . label ( 'workerpoolMaxPrice' )
10795 . validateSync ( workerpoolMaxPrice ) ;
10896
109- const vDatasetAddress = addressOrEnsSchema ( )
110- . required ( )
111- . label ( 'protectedData' )
112- . validateSync ( protectedData ) ;
113- // Check protected data validity through subgraph
114- const isValidProtectedData = await checkProtectedDataValidity (
115- graphQLClient ,
116- vDatasetAddress
117- ) ;
118- if ( ! isValidProtectedData ) {
119- throw new Error (
120- 'This protected data does not contain "telegram_chatId:string" in its schema.'
121- ) ;
122- }
123-
12497 // Encrypt telegram content
12598 const telegramContentEncryptionKey = iexec . dataset . generateEncryptionKey ( ) ;
12699 const encryptedFile = await iexec . dataset
@@ -160,10 +133,50 @@ export const sendTelegram = async ({
160133 telegramContentEncryptionKey,
161134 } ) ,
162135 } ;
136+ // Bulk processing
137+ if ( grantedAccess ) {
138+ const vMaxProtectedDataPerTask = positiveNumberSchema ( )
139+ . label ( 'maxProtectedDataPerTask' )
140+ . validateSync ( maxProtectedDataPerTask ) ;
141+
142+ const bulkRequest = await dataProtector . prepareBulkRequest ( {
143+ app : vDappAddressOrENS ,
144+ appMaxPrice : vAppMaxPrice ,
145+ workerpoolMaxPrice : vWorkerpoolMaxPrice ,
146+ workerpool : vWorkerpoolAddressOrEns ,
147+ args : vLabel ,
148+ inputFiles : [ ] ,
149+ secrets,
150+ bulkOrders : grantedAccess ,
151+ maxProtectedDataPerTask : vMaxProtectedDataPerTask ,
152+ } ) ;
153+ const processBulkRequestResponse : ProcessBulkRequestResponse =
154+ await dataProtector . processBulkRequest ( {
155+ bulkRequest : bulkRequest . bulkRequest ,
156+ useVoucher : vUseVoucher ,
157+ workerpool : vWorkerpoolAddressOrEns ,
158+ } ) ;
159+ return processBulkRequestResponse ;
160+ }
161+
162+ // Single processing mode - protectedData is required
163+ const vDatasetAddress = addressOrEnsSchema ( )
164+ . required ( )
165+ . label ( 'protectedData' )
166+ . validateSync ( protectedData ) ;
167+ // Check protected data validity through subgraph
168+ const isValidProtectedData = await checkProtectedDataValidity (
169+ graphQLClient ,
170+ vDatasetAddress
171+ ) ;
172+ if ( ! isValidProtectedData ) {
173+ throw new Error (
174+ 'This protected data does not contain "telegram_chatId:string" in its schema.'
175+ ) ;
176+ }
163177
164178 // Use processProtectedData from dataprotector
165179 const result = await dataProtector . processProtectedData ( {
166- iexec,
167180 defaultWorkerpool : vWorkerpoolAddressOrEns ,
168181 protectedData : vDatasetAddress ,
169182 app : vDappAddressOrENS ,
0 commit comments