1919use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
2020use OCP \AppFramework \Http \Attribute \UserRateLimit ;
2121use OCP \AppFramework \Http \DataResponse ;
22- use OCP \AppFramework \Http \StreamGeneratorResponse ;
22+ use OCP \AppFramework \Http \StreamTraversableResponse ;
2323use OCP \AppFramework \OCSController ;
2424use OCP \Contacts \ContactsImportOptions ;
2525use OCP \Contacts \IManager ;
@@ -53,7 +53,7 @@ public function __construct(
5353 * @param string $data contacts data
5454 * @param string|null $user system user id
5555 *
56- * @return StreamGeneratorResponse <Http::STATUS_OK, array{Content-Type:'application/x-ndjson'}> | DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED, array{error?: non-empty-string}, array{}>
56+ * @return StreamTraversableResponse <Http::STATUS_OK, array{Content-Type:'application/x-ndjson'}> | DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED, array{error?: non-empty-string}, array{}>
5757 *
5858 * 200: NDJSON stream of import event objects
5959 * 400: invalid parameters
@@ -62,7 +62,7 @@ public function __construct(
6262 #[ApiRoute(verb: 'POST ' , url: '/import ' , root: '/contacts ' )]
6363 #[UserRateLimit(limit: 10 , period: 3600 )]
6464 #[NoAdminRequired]
65- public function import (string $ transaction , string $ target , array $ options , string $ data , ?string $ user = null ): DataResponse |StreamGeneratorResponse {
65+ public function import (string $ transaction , string $ target , array $ options , string $ data , ?string $ user = null ): DataResponse |StreamTraversableResponse {
6666 $ addressBookId = $ target ;
6767 $ format = isset ($ options ['format ' ]) ? $ options ['format ' ] : null ;
6868 $ validation = isset ($ options ['validation ' ]) ? (int )$ options ['validation ' ] : null ;
@@ -141,6 +141,6 @@ public function import(string $transaction, string $target, array $options, stri
141141 }
142142 })();
143143
144- return new StreamGeneratorResponse ($ stream , ' application/x-ndjson ' );
144+ return new StreamTraversableResponse ($ stream , Http:: STATUS_OK , [ ' Content-Type ' => ' application/x-ndjson '] );
145145 }
146146}
0 commit comments