Skip to content

Commit 287e874

Browse files
committed
using nc19request to broadcast the frame
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent e6993c9 commit 287e874

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

lib/Service/SharingFrameService.php

+18-21
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
namespace OCA\Circles\Service;
2828

2929

30+
use daita\MySmallPhpTools\Model\Nextcloud\NC19Request;
31+
use daita\MySmallPhpTools\Model\Request;
32+
use daita\MySmallPhpTools\Traits\Nextcloud\TNC19Request;
3033
use Exception;
3134
use OCA\Circles\Api\v1\Circles;
32-
use OCA\Circles\AppInfo\Application;
3335
use OCA\Circles\Db\CirclesRequest;
3436
use OCA\Circles\Db\FederatedLinksRequest;
3537
use OCA\Circles\Db\SharingFrameRequest;
@@ -50,6 +52,10 @@
5052

5153
class SharingFrameService {
5254

55+
56+
use TNC19Request;
57+
58+
5359
/** @var string */
5460
private $userId;
5561

@@ -297,32 +303,23 @@ public function receiveFrame($token, $uniqueId, SharingFrame $frame) {
297303
* @return bool
298304
* @throws Exception
299305
*/
300-
public function initiateShare($circleUniqueId, $frameUniqueId) {
301-
$args = [
302-
'circleId' => $circleUniqueId,
303-
'frameId' => $frameUniqueId
304-
];
305-
306-
$client = $this->clientService->newClient();
307-
$addr = $this->configService->getLocalAddress() . \OC::$WEBROOT;
308-
$opts = [
309-
'body' => $args,
310-
'timeout' => Application::CLIENT_TIMEOUT,
311-
'connect_timeout' => Application::CLIENT_TIMEOUT
312-
];
313-
314-
if ($this->configService->getAppValue(ConfigService::CIRCLES_SELF_SIGNED) === '1') {
315-
$opts['verify'] = false;
316-
}
306+
public function initiateShare(string $circleUniqueId, string $frameUniqueId) {
307+
$route = $this->urlGenerator->linkToRouteAbsolute('circles.Shares.initShareDelivery');
308+
$request = new NC19Request('', Request::TYPE_POST);
309+
$this->configService->configureRequest($request);
310+
$request->setProtocols(['https', 'http']);
311+
$request->addData('circleId', $circleUniqueId);
312+
$request->addData('frameId', $frameUniqueId);
313+
$request->setAddressFromUrl($route);
317314

318315
try {
319-
$client->post($this->generatePayloadDeliveryURL($addr), $opts);
316+
$this->doRequest($request);
320317

321318
return true;
322319
} catch (Exception $e) {
323320
$this->miscService->log(
324-
'fail to initialise circle share to ' . $addr . ' for circle ' . $circleUniqueId . ' - '
325-
. json_encode($opts) . ' - ' . $e->getMessage(), 3
321+
'fail to initialise circle share with request ' . json_encode($request) . ' - '
322+
. $e->getMessage(), 3
326323
);
327324
throw $e;
328325
}

0 commit comments

Comments
 (0)