summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2020-06-17 12:41:58 -0100
committerMaxence Lange <maxence@artificial-owl.com>2020-06-17 12:41:58 -0100
commit745810e2b0b67b06da20dd5c53d938cbe02bfc06 (patch)
treebfdfef6a2f806bb810fe39488d2f8bebdd63c516
parent09a6aac9375b580cf9ee5f6407b5c1b78fc04959 (diff)
database & requests
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--appinfo/routes.php8
-rw-r--r--lib/Command/StreamDetails.php2
-rw-r--r--lib/Command/Timeline.php15
-rw-r--r--lib/Controller/LocalController.php2
-rw-r--r--lib/Cron/Cache.php10
-rw-r--r--lib/Db/StreamRequest.php5
-rw-r--r--lib/Exceptions/RequestContentException.php39
-rw-r--r--lib/Exceptions/RequestNetworkException.php39
-rw-r--r--lib/Exceptions/RequestResultNotJsonException.php39
-rw-r--r--lib/Exceptions/RequestResultSizeException.php39
-rw-r--r--lib/Exceptions/RequestServerException.php39
-rw-r--r--lib/Interfaces/Object/AnnounceInterface.php10
-rw-r--r--lib/Interfaces/Object/FollowInterface.php10
-rw-r--r--lib/Service/ActivityService.php47
-rw-r--r--lib/Service/CacheActorService.php15
-rw-r--r--lib/Service/CacheDocumentService.php13
-rw-r--r--lib/Service/CurlService.php315
-rw-r--r--lib/Service/DocumentService.php14
-rw-r--r--lib/Service/FollowService.php10
-rw-r--r--lib/Service/PostService.php10
-rw-r--r--lib/Service/SignatureService.php10
-rw-r--r--lib/Service/StreamQueueService.php10
-rw-r--r--lib/Service/StreamService.php31
-rw-r--r--package-lock.json3
24 files changed, 147 insertions, 588 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index b7e5d6e6..ad824468 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -52,16 +52,18 @@ return [
['name' => 'ActivityPub#actorAlias', 'url' => '/@{username}/', 'verb' => 'GET'],
['name' => 'ActivityPub#inbox', 'url' => '/@{username}/inbox', 'verb' => 'POST'],
['name' => 'ActivityPub#sharedInbox', 'url' => '/inbox', 'verb' => 'POST'],
- ['name' => 'ActivityPub#outbox', 'url' => '/@{username}/outbox', 'verb' => 'POST'],
+
+ ['name' => 'ActivityPub#outbox', 'url' => '/@{username}/outbox', 'verb' => 'GET'],
+ ['name' => 'ActivityPub#outbox', 'url' => '/@{username}/outbox', 'verb' => 'POST'], // Check if needed
['name' => 'ActivityPub#followers', 'url' => '/@{username}/followers', 'verb' => 'GET'],
['name' => 'ActivityPub#following', 'url' => '/@{username}/following', 'verb' => 'GET'],
+ ['name' => 'ActivityPub#displayPost', 'url' => '/@{username}/{token}', 'verb' => 'GET'],
+
['name' => 'OStatus#subscribe', 'url' => '/ostatus/follow/{uri}', 'verb' => 'GET'],
['name' => 'OStatus#followRemote', 'url' => '/api/v1/ostatus/followRemote/{local}', 'verb' => 'GET'],
['name' => 'OStatus#getLink', 'url' => '/api/v1/ostatus/link/{local}/{account}', 'verb' => 'GET'],
- ['name' => 'ActivityPub#displayPost', 'url' => '/@{username}/{token}', 'verb' => 'GET'],
-
['name' => 'Local#streamHome', 'url' => '/api/v1/stream/home', 'verb' => 'GET'],
['name' => 'Local#streamNotifications', 'url' => '/api/v1/stream/notifications', 'verb' => 'GET'],
['name' => 'Local#streamTimeline', 'url' => '/api/v1/stream/timeline', 'verb' => 'GET'],
diff --git a/lib/Command/StreamDetails.php b/lib/Command/StreamDetails.php
index f6e952b5..3d8a5956 100644
--- a/lib/Command/StreamDetails.php
+++ b/lib/Command/StreamDetails.php
@@ -138,7 +138,7 @@ class StreamDetails extends ExtendedBase {
$this->output->writeln('* <info>Direct</info>: ' . json_encode($direct, JSON_PRETTY_PRINT));
$this->output->writeln('* <info>Public</info>: ' . ($details->isPublic() ? 'true' : 'false'));
- $this->output->writeln('* <info>Federated</info>: ' . ($details->isFederated() ? 'true' : 'true'));
+ $this->output->writeln('* <info>Federated</info>: ' . ($details->isFederated() ? 'true' : 'false'));
}
}
diff --git a/lib/Command/Timeline.php b/lib/Command/Timeline.php
index 2379cb93..6dc5e1c8 100644
--- a/lib/Command/Timeline.php
+++ b/lib/Command/Timeline.php
@@ -139,7 +139,6 @@ class Timeline extends ExtendedBase {
}
-
/**
* @param Person $actor
* @param string $timeline
@@ -147,19 +146,25 @@ class Timeline extends ExtendedBase {
* @throws Exception
*/
private function displayStream(Person $actor, string $timeline) {
+ $this->streamRequest->setViewer($actor);
switch ($timeline) {
case 'home':
- $stream = $this->streamRequest->getTimelineHome($actor, 0, $this->count);
+ $stream = $this->streamRequest->getTimelineHome(0, $this->count);
$this->outputStreams($stream);
break;
case 'direct':
- $stream = $this->streamRequest->getTimelineDirect($actor, 0, $this->count);
+ $stream = $this->streamRequest->getTimelineDirect(0, $this->count);
$this->outputStreams($stream);
break;
case 'notifications':
- $stream = $this->streamRequest->getTimelineNotifications($actor, 0, $this->count);
+ $stream = $this->streamRequest->getTimelineNotifications(0, $this->count);
+ $this->outputStreams($stream);
+ break;
+
+ case 'liked':
+ $stream = $this->streamRequest->getTimelineLiked(0, $this->count);
$this->outputStreams($stream);
break;
@@ -175,7 +180,7 @@ class Timeline extends ExtendedBase {
default:
throw new Exception(
- 'Unknown timeline. Try home, direct, local, global, notification.'
+ 'Unknown timeline. Try home, direct, notifications, liked, local, global.'
);
}
}
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php
index b9f9b1bc..1021d334 100644
--- a/lib/Controller/LocalController.php
+++ b/lib/Controller/LocalController.php
@@ -400,7 +400,7 @@ class LocalController extends Controller {
public function streamNotifications($since = 0, int $limit = 5): DataResponse {
try {
$this->initViewer(true);
- $posts = $this->streamService->getStreamNotifications($this->viewer, $since, $limit);
+ $posts = $this->streamService->getStreamNotifications($since, $limit);
return $this->success($posts);
} catch (Exception $e) {
diff --git a/lib/Cron/Cache.php b/lib/Cron/Cache.php
index 9932e3c1..2552766f 100644
--- a/lib/Cron/Cache.php
+++ b/lib/Cron/Cache.php
@@ -36,10 +36,8 @@ use OC\BackgroundJob\TimedJob;
use OCA\Social\AppInfo\Application;
use OCA\Social\Service\AccountService;
use OCA\Social\Service\CacheActorService;
-use OCA\Social\Service\ConfigService;
use OCA\Social\Service\DocumentService;
use OCA\Social\Service\HashtagService;
-use OCA\Social\Service\MiscService;
use OCP\AppFramework\QueryException;
@@ -63,12 +61,6 @@ class Cache extends TimedJob {
/** @var HashtagService */
private $hashtagService;
- /** @var ConfigService */
- private $configService;
-
- /** @var MiscService */
- private $miscService;
-
/**
* Cache constructor.
@@ -91,8 +83,6 @@ class Cache extends TimedJob {
$this->cacheActorService = $c->query(CacheActorService::class);
$this->documentService = $c->query(DocumentService::class);
$this->hashtagService = $c->query(HashtagService::class);
- $this->configService = $c->query(ConfigService::class);
- $this->miscService = $c->query(MiscService::class);
$this->manageCache();
}
diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php
index db1480f4..fc54fc0e 100644
--- a/lib/Db/StreamRequest.php
+++ b/lib/Db/StreamRequest.php
@@ -396,16 +396,17 @@ class StreamRequest extends StreamRequestBuilder {
* - someone wants to follow you (not yet)
* - someone is following you (not yet)
*
- * @param Person $actor
* @param int $since
* @param int $limit
*
* @return Stream[]
* @throws DateTimeException
*/
- public function getTimelineNotifications(Person $actor, int $since = 0, int $limit = 5): array {
+ public function getTimelineNotifications(int $since = 0, int $limit = 5): array {
$qb = $this->getStreamSelectSql();
+ $actor = $qb->getViewer();
+
$qb->limitPaginate($since, $limit);
$qb->selectDestFollowing('sd', '');
diff --git a/lib/Exceptions/RequestContentException.php b/lib/Exceptions/RequestContentException.php
deleted file mode 100644
index f83a17a7..00000000
--- a/lib/Exceptions/RequestContentException.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-
-/**
- * Nextcloud - Social Support
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange <maxence@artificial-owl.com>
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-namespace OCA\Social\Exceptions;
-
-
-use Exception;
-
-
-class RequestContentException extends Exception {
-
-}
-
diff --git a/lib/Exceptions/RequestNetworkException.php b/lib/Exceptions/RequestNetworkException.php
deleted file mode 100644
index e80c2b71..00000000
--- a/lib/Exceptions/RequestNetworkException.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-
-/**
- * Nextcloud - Social Support
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange <maxence@artificial-owl.com>
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-namespace OCA\Social\Exceptions;
-
-
-use Exception;
-
-
-class RequestNetworkException extends Exception {
-
-}
-
diff --git a/lib/Exceptions/RequestResultNotJsonException.php b/lib/Exceptions/RequestResultNotJsonException.php
deleted file mode 100644
index 87785365..00000000
--- a/lib/Exceptions/RequestResultNotJsonException.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-
-/**
- * Nextcloud - Social Support
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange <maxence@artificial-owl.com>
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-namespace OCA\Social\Exceptions;
-
-
-use Exception;
-
-
-class RequestResultNotJsonException extends Exception {
-
-}
-
diff --git a/lib/Exceptions/RequestResultSizeException.php b/lib/Exceptions/RequestResultSizeException.php
deleted file mode 100644
index d20b589f..00000000
--- a/lib/Exceptions/RequestResultSizeException.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-
-/**
- * Nextcloud - Social Support
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange <maxence@artificial-owl.com>
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-namespace OCA\Social\Exceptions;
-
-
-use Exception;
-
-
-class RequestResultSizeException extends Exception {
-
-}
-
diff --git a/lib/Exceptions/RequestServerException.php b/lib/Exceptions/RequestServerException.php
deleted file mode 100644
index 34d629e0..00000000
--- a/lib/Exceptions/RequestServerException.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-
-/**
- * Nextcloud - Social Support
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange <maxence@artificial-owl.com>
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-namespace OCA\Social\Exceptions;
-
-
-use Exception;
-
-
-class RequestServerException extends Exception {
-
-}
-
diff --git a/lib/Interfaces/Object/AnnounceInterface.php b/lib/Interfaces/Object/AnnounceInterface.php
index ea2487be..92ac256e 100644
--- a/lib/Interfaces/Object/AnnounceInterface.php
+++ b/lib/Interfaces/Object/AnnounceInterface.php
@@ -44,11 +44,11 @@ use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\ItemNotFoundException;
use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\RedundancyLimitException;
-use OCA\Social\Exceptions\RequestContentException;
-use OCA\Social\Exceptions\RequestNetworkException;
-use OCA\Social\Exceptions\RequestResultNotJsonException;
-use OCA\Social\Exceptions\RequestResultSizeException;
-use OCA\Social\Exceptions\RequestServerException;
+use daita\MySmallPhpTools\Exceptions\RequestContentException;
+use daita\MySmallPhpTools\Exceptions\RequestNetworkException;
+use daita\MySmallPhpTools\Exceptions\RequestResultNotJsonException;
+use daita\MySmallPhpTools\Exceptions\RequestResultSizeException;
+use daita\MySmallPhpTools\Exceptions\RequestServerException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Exceptions\UnauthorizedFediverseException;
diff --git a/lib/Interfaces/Object/FollowInterface.php b/lib/Interfaces/Object/FollowInterface.php
index a72eeb02..47eea5bf 100644
--- a/lib/Interfaces/Object/FollowInterface.php
+++ b/lib/Interfaces/Object/FollowInterface.php
@@ -41,11 +41,11 @@ use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\ItemNotFoundException;
use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\RedundancyLimitException;
-use OCA\Social\Exceptions\RequestContentException;
-use OCA\Social\Exceptions\RequestNetworkException;
-use OCA\Social\Exceptions\RequestResultNotJsonException;
-use OCA\Social\Exceptions\RequestResultSizeException;
-use OCA\Social\Exceptions\RequestServerException;
+use daita\MySmallPhpTools\Exceptions\RequestContentException;
+use daita\MySmallPhpTools\Exceptions\RequestNetworkException;
+use daita\MySmallPhpTools\Exceptions\RequestResultNotJsonException;
+use daita\MySmallPhpTools\Exceptions\RequestResultSizeException;
+use daita\MySmallPhpTools\Exceptions\RequestServerException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Interfaces\IActivityPubInterface;
use OCA\Social\Interfaces\Internal\SocialAppNotificationInterface;
diff --git a/lib/Service/ActivityService.php b/lib/Service/ActivityService.php
index 8bf7707c..41372d98 100644
--- a/lib/Service/ActivityService.php
+++ b/lib/Service/ActivityService.php
@@ -30,6 +30,11 @@ declare(strict_types=1);
namespace OCA\Social\Service;
+use daita\MySmallPhpTools\Exceptions\RequestContentException;
+use daita\MySmallPhpTools\Exceptions\RequestNetworkException;
+use daita\MySmallPhpTools\Exceptions\RequestResultNotJsonException;
+use daita\MySmallPhpTools\Exceptions\RequestResultSizeException;
+use daita\MySmallPhpTools\Exceptions\RequestServerException;
use daita\MySmallPhpTools\Model\Request;
use daita\MySmallPhpTools\Traits\TArrayTools;
use Exception;
@@ -43,11 +48,6 @@ use OCA\Social\Exceptions\ItemAlreadyExistsException;
use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\NoHighPriorityRequestException;
use OCA\Social\Exceptions\QueueStatusException;
-use OCA\Social\Exceptions\RequestContentException;
-use OCA\Social\Exceptions\RequestNetworkException;
-use OCA\Social\Exceptions\RequestResultNotJsonException;
-use OCA\Social\Exceptions\RequestResultSizeException;
-use OCA\Social\Exceptions\RequestServerException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\UnauthorizedFediverseException;
use OCA\Social\Model\ActivityPub\ACore;
@@ -284,41 +284,20 @@ class ActivityService {
try {
$this->signatureService->signRequest($request, $queue);
- $this->curlService->request($request);
+ $this->curlService->retrieveJson($request);
$this->requestQueueService->endRequest($queue, true);
- } catch (UnauthorizedFediverseException $e) {
+ } catch (UnauthorizedFediverseException | RequestResultNotJsonException $e) {
$this->requestQueueService->endRequest($queue, true);
- } catch (RequestResultNotJsonException $e) {
- $this->requestQueueService->endRequest($queue, true);
- } catch (ActorDoesNotExistException $e) {
- $this->miscService->log(
- 'Error while managing request: ' . json_encode($request) . ' ' . $e->getMessage(), 1
- );
- $this->requestQueueService->deleteRequest($queue);
- } catch (RequestContentException $e) {
- $this->miscService->log(
- 'Error while managing request: ' . json_encode($request) . ' ' . $e->getMessage(), 1
- );
- $this->requestQueueService->deleteRequest($queue);
- } catch (RequestResultSizeException $e) {
+ } catch (ActorDoesNotExistException | RequestContentException | RequestResultSizeException $e) {
$this->miscService->log(
- 'Error while managing request: ' . json_encode($request) . ' ' . $e->getMessage(), 1
- );
- $this->requestQueueService->deleteRequest($queue);
- } catch (RequestServerException $e) {
- $this->miscService->log(
- 'Temporary error while managing request: RequestServerException - ' . json_encode(
- $request
- ) . ' - '
+ 'Error while managing request: ' . json_encode($request) . ' ' . get_class($e) . ': '
. $e->getMessage(), 1
);
- $this->requestQueueService->endRequest($queue, false);
- $this->failInstances[] = $host;
- } catch (RequestNetworkException $e) {
+ $this->requestQueueService->deleteRequest($queue);
+ } catch (RequestNetworkException | RequestServerException $e) {
$this->miscService->log(
- 'Temporary error while managing request: RequestNetworkException - ' . json_encode(
- $request
- ) . ' - ' . $e->getMessage(), 1
+ 'Temporary error while managing request: RequestServerException - ' . json_encode($request)
+ . ' - ' . get_class($e) . ': ' . $e->getMessage(), 1
);
$this->requestQueueService->endRequest($queue, false);
$this->failInstances[] = $host;
diff --git a/lib/Service/CacheActorService.php b/lib/Service/CacheActorService.php
index 9d5c143f..1b145215 100644
--- a/lib/Service/CacheActorService.php
+++ b/lib/Service/CacheActorService.php
@@ -31,6 +31,11 @@ namespace OCA\Social\Service;
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
+use daita\MySmallPhpTools\Exceptions\RequestContentException;
+use daita\MySmallPhpTools\Exceptions\RequestNetworkException;
+use daita\MySmallPhpTools\Exceptions\RequestResultNotJsonException;
+use daita\MySmallPhpTools\Exceptions\RequestResultSizeException;
+use daita\MySmallPhpTools\Exceptions\RequestServerException;
use daita\MySmallPhpTools\Traits\TArrayTools;
use Exception;
use OCA\Social\AP;
@@ -41,11 +46,6 @@ use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\ItemAlreadyExistsException;
use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\RedundancyLimitException;
-use OCA\Social\Exceptions\RequestContentException;
-use OCA\Social\Exceptions\RequestNetworkException;
-use OCA\Social\Exceptions\RequestResultNotJsonException;
-use OCA\Social\Exceptions\RequestResultSizeException;
-use OCA\Social\Exceptions\RequestServerException;
use OCA\Social\Exceptions\RetrieveAccountFormatException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\UnauthorizedFediverseException;
@@ -71,10 +71,6 @@ class CacheActorService {
private $miscService;
- /** @var Person */
- private $viewer = null;
-
-
/**
* CacheService constructor.
*
@@ -98,7 +94,6 @@ class CacheActorService {
* @param Person $viewer
*/
public function setViewer(Person $viewer) {
- $this->viewer = $viewer;
$this->cacheActorsRequest->setViewer($viewer);
}
diff --git a/lib/Service/CacheDocumentService.php b/lib/Service/CacheDocumentService.php
index 579d379b..0b7ef70e 100644
--- a/lib/Service/CacheDocumentService.php
+++ b/lib/Service/CacheDocumentService.php
@@ -31,6 +31,10 @@ namespace OCA\Social\Service;
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
+use daita\MySmallPhpTools\Exceptions\RequestContentException;
+use daita\MySmallPhpTools\Exceptions\RequestNetworkException;
+use daita\MySmallPhpTools\Exceptions\RequestResultSizeException;
+use daita\MySmallPhpTools\Exceptions\RequestServerException;
use daita\MySmallPhpTools\Model\Request;
use daita\MySmallPhpTools\Traits\TArrayTools;
use daita\MySmallPhpTools\Traits\TStringTools;
@@ -40,11 +44,6 @@ use Gumlet\ImageResizeException;
use OCA\Social\Exceptions\CacheContentException;
use OCA\Social\Exceptions\CacheContentMimeTypeException;
use OCA\Social\Exceptions\CacheDocumentDoesNotExistException;
-use OCA\Social\Exceptions\RequestContentException;
-use OCA\Social\Exceptions\RequestNetworkException;
-use OCA\Social\Exceptions\RequestResultNotJsonException;
-use OCA\Social\Exceptions\RequestResultSizeException;
-use OCA\Social\Exceptions\RequestServerException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\UnauthorizedFediverseException;
use OCA\Social\Model\ActivityPub\Object\Document;
@@ -122,7 +121,6 @@ class CacheDocumentService {
* @throws NotPermittedException
* @throws RequestContentException
* @throws RequestNetworkException
- * @throws RequestResultNotJsonException
* @throws RequestResultSizeException
* @throws RequestServerException
* @throws SocialAppConfigException
@@ -260,7 +258,6 @@ class CacheDocumentService {
* @throws MalformedArrayException
* @throws RequestContentException
* @throws RequestNetworkException
- * @throws RequestResultNotJsonException
* @throws RequestResultSizeException
* @throws RequestServerException
* @throws SocialAppConfigException
@@ -273,7 +270,7 @@ class CacheDocumentService {
$request->setAddress($url['host']);
$request->setProtocol($url['scheme']);
- $content = $this->curlService->request($request);
+ $content = $this->curlService->doRequest($request);
return $content;
}
diff --git a/lib/Service/CurlService.php b/lib/Service/CurlService.php
index 47d2f068..018b5de5 100644
--- a/lib/Service/CurlService.php
+++ b/lib/Service/CurlService.php
@@ -32,9 +32,15 @@ namespace OCA\Social\Service;
use daita\MySmallPhpTools\Exceptions\ArrayNotFoundException;
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
+use daita\MySmallPhpTools\Exceptions\RequestContentException;
+use daita\MySmallPhpTools\Exceptions\RequestNetworkException;
+use daita\MySmallPhpTools\Exceptions\RequestResultNotJsonException;
+use daita\MySmallPhpTools\Exceptions\RequestResultSizeException;
+use daita\MySmallPhpTools\Exceptions\RequestServerException;
use daita\MySmallPhpTools\Model\Request;
use daita\MySmallPhpTools\Traits\TArrayTools;
use daita\MySmallPhpTools\Traits\TPathTools;
+use daita\MySmallPhpTools\Traits\TRequest;
use Exception;
use OCA\Social\AP;
use OCA\Social\Exceptions\HostMetaException;
@@ -42,11 +48,6 @@ use OCA\Social\Exceptions\InvalidOriginException;
use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\RedundancyLimitException;
-use OCA\Social\Exceptions\RequestContentException;
-use OCA\Social\Exceptions\RequestNetworkException;
-use OCA\Social\Exceptions\RequestResultNotJsonException;
-use OCA\Social\Exceptions\RequestResultSizeException;
-use OCA\Social\Exceptions\RequestServerException;
use OCA\Social\Exceptions\RetrieveAccountFormatException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\UnauthorizedFediverseException;
@@ -57,6 +58,12 @@ class CurlService {
use TArrayTools;
use TPathTools;
+ use TRequest {
+ initRequestPost