kopia lustrzana https://github.com/nextcloud/social
database & requests
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/912/head
rodzic
09a6aac937
commit
745810e2b0
|
@ -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'],
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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', '');
|
||||
|
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
} catch (ActorDoesNotExistException | RequestContentException | RequestResultSizeException $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) {
|
||||
$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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 as initRequestPostOrig;
|
||||
initRequestGet as initRequestGetOrig;
|
||||
retrieveJson as retrieveJsonOrig;
|
||||
doRequest as doRequestOrig;
|
||||
}
|
||||
|
||||
|
||||
const ASYNC_REQUEST_TOKEN = '/async/request/{token}';
|
||||
|
@ -73,13 +80,6 @@ class CurlService {
|
|||
private $miscService;
|
||||
|
||||
|
||||
/** @var int */
|
||||
private $maxDownloadSize = 0;
|
||||
|
||||
/** @var bool */
|
||||
private $maxDownloadSizeReached = false;
|
||||
|
||||
|
||||
/**
|
||||
* CurlService constructor.
|
||||
*
|
||||
|
@ -93,6 +93,9 @@ class CurlService {
|
|||
$this->configService = $configService;
|
||||
$this->fediverseService = $fediverseService;
|
||||
$this->miscService = $miscService;
|
||||
|
||||
$maxDlSize = $this->configService->getAppValue(ConfigService::SOCIAL_MAX_SIZE) * (1024 * 1024);
|
||||
$this->setMaxDownloadSize($maxDlSize);
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,15 +134,8 @@ class CurlService {
|
|||
$request = new Request($path);
|
||||
$request->addData('resource', 'acct:' . $account);
|
||||
$request->setAddress($host);
|
||||
|
||||
try {
|
||||
$result = $this->request($request);
|
||||
} catch (RequestNetworkException $e) {
|
||||
if ($e->getCode() === CURLE_COULDNT_CONNECT) {
|
||||
$request->setProtocol('http');
|
||||
$result = $this->request($request);
|
||||
} else throw $e;
|
||||
}
|
||||
$request->setProtocols(['https', 'http']);
|
||||
$result = $this->retrieveJson($request);
|
||||
|
||||
$subject = $this->get('subject', $result, '');
|
||||
list($type, $temp) = explode(':', $subject, 2);
|
||||
|
@ -162,7 +158,7 @@ class CurlService {
|
|||
$request->setAddress($host);
|
||||
|
||||
try {
|
||||
$result = $this->request($request);
|
||||
$result = $this->retrieveJson($request);
|
||||
} catch (Exception $e) {
|
||||
$this->miscService->log(
|
||||
'hostMeta Exception - ' . get_class($e) . ' - ' . $e->getMessage(), 0
|
||||
|
@ -237,14 +233,13 @@ class CurlService {
|
|||
* @throws UnauthorizedFediverseException
|
||||
*/
|
||||
public function retrieveObject($id): array {
|
||||
|
||||
$url = parse_url($id);
|
||||
$this->mustContains(['path', 'host', 'scheme'], $url);
|
||||
$request = new Request($url['path'], Request::TYPE_GET);
|
||||
$request->setAddress($url['host']);
|
||||
$request->setProtocol($url['scheme']);
|
||||
|
||||
$result = $this->request($request);
|
||||
$result = $this->retrieveJson($request);
|
||||
if (is_array($result)) {
|
||||
$result['_host'] = $request->getAddress();
|
||||
}
|
||||
|
@ -256,60 +251,46 @@ class CurlService {
|
|||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
* @return array
|
||||
* @throws SocialAppConfigException
|
||||
* @throws UnauthorizedFediverseException
|
||||
* @throws RequestContentException
|
||||
* @throws RequestNetworkException
|
||||
* @throws RequestResultNotJsonException
|
||||
* @throws RequestResultSizeException
|
||||
* @throws RequestServerException
|
||||
*/
|
||||
public function retrieveJson(Request $request): array {
|
||||
try {
|
||||
$result = $this->retrieveJsonOrig($request);
|
||||
} catch (RequestResultSizeException | RequestResultNotJsonException $e) {
|
||||
$this->miscService->log(
|
||||
'[!!] request: ' . json_encode($request) . ' - content-type: '
|
||||
. $request->getContentType() . ' - ' . $e->getMessage(), 1
|
||||
);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
* @throws SocialAppConfigException
|
||||
* @throws UnauthorizedFediverseException
|
||||
* @throws RequestContentException
|
||||
* @throws RequestNetworkException
|
||||
* @throws RequestResultSizeException
|
||||
* @throws RequestServerException
|
||||
*/
|
||||
public function request(Request $request) {
|
||||
public function doRequest(Request $request) {
|
||||
$this->fediverseService->authorized($request->getAddress());
|
||||
|
||||
$this->maxDownloadSizeReached = false;
|
||||
$this->assignUserAgent($request);
|
||||
|
||||
$curl = $this->initRequest($request);
|
||||
|
||||
$this->initRequestGet($request);
|
||||
$this->initRequestPost($curl, $request);
|
||||
$this->initRequestPut($curl, $request);
|
||||
$this->initRequestDelete($curl, $request);
|
||||
|
||||
$this->initRequestHeaders($curl, $request);
|
||||
|
||||
$result = curl_exec($curl);
|
||||
|
||||
if ($this->maxDownloadSizeReached === true) {
|
||||
throw new RequestResultSizeException();
|
||||
}
|
||||
$this->parseRequestResult($curl, $request);
|
||||
|
||||
if ($request->isBinary()) {
|
||||
$this->miscService->log('[>>] request (binary): ' . json_encode($request), 1);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$this->miscService->log(
|
||||
'[>>] request: ' . json_encode($request) . ' - content-type: '
|
||||
. $request->getContentType() . ' - result: ' . $result, 1
|
||||
);
|
||||
|
||||
if (strpos($request->getContentType(), 'application/xrd') === 0) {
|
||||
$xml = simplexml_load_string($result);
|
||||
$result = json_encode($xml, JSON_UNESCAPED_SLASHES);
|
||||
$this->miscService->log('XRD conversion to JSON: ' . $result, 1);
|
||||
}
|
||||
|
||||
$result = json_decode((string)$result, true);
|
||||
if (is_array($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
throw new RequestResultNotJsonException();
|
||||
return $this->doRequestOrig($request);
|
||||
}
|
||||
|
||||
|
||||
|
@ -340,7 +321,7 @@ class CurlService {
|
|||
$request->setProtocol(parse_url($address, PHP_URL_SCHEME));
|
||||
|
||||
try {
|
||||
$this->request($request);
|
||||
$this->retrieveJson($request);
|
||||
} catch (RequestResultNotJsonException $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->miscService->log(
|
||||
|
@ -353,73 +334,8 @@ class CurlService {
|
|||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
private function initRequest(Request $request) {
|
||||
|
||||
$curl = $this->generateCurlRequest($request);
|
||||
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent());
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $request->getTimeout());
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $request->getTimeout());
|
||||
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_BINARYTRANSFER, $request->isBinary());
|
||||
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
$this->maxDownloadSize =
|
||||
$this->configService->getAppValue(ConfigService::SOCIAL_MAX_SIZE) * (1024 * 1024);
|
||||
curl_setopt($curl, CURLOPT_BUFFERSIZE, 128);
|
||||
curl_setopt($curl, CURLOPT_NOPROGRESS, false);
|
||||
curl_setopt(
|
||||
/**
|
||||
* @param $downloadSize
|
||||
* @param int $downloaded
|
||||
* @param $uploadSize
|
||||
* @param int $uploaded
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
$curl, CURLOPT_PROGRESSFUNCTION,
|
||||
function($downloadSize, int $downloaded, $uploadSize, int $uploaded) {
|
||||
if ($downloaded > $this->maxDownloadSize) {
|
||||
$this->maxDownloadSizeReached = true;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
|
||||
return $curl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
private function generateCurlRequest(Request $request) {
|
||||
$url = $request->getProtocol() . '://' . $request->getAddress() . $request->getParsedUrl();
|
||||
if ($request->getType() !== Request::TYPE_GET) {
|
||||
$curl = curl_init($url);
|
||||
} else {
|
||||
$curl = curl_init($url . '?' . $request->getUrlData());
|
||||
}
|
||||
|
||||
return $curl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*/
|
||||
private function initRequestGet(Request $request) {
|
||||
protected function initRequestGet(Request $request) {
|
||||
if ($request->getType() !== Request::TYPE_GET) {
|
||||
return;
|
||||
}
|
||||
|
@ -430,6 +346,8 @@ class CurlService {
|
|||
$request->addHeader(
|
||||
'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
|
||||
);
|
||||
|
||||
$this->initRequestGetOrig($request);
|
||||
}
|
||||
|
||||
|
||||
|
@ -437,7 +355,7 @@ class CurlService {
|
|||
* @param resource $curl
|
||||
* @param Request $request
|
||||
*/
|
||||
private function initRequestPost($curl, Request $request) {
|
||||
protected function initRequestPost($curl, Request $request) {
|
||||
if ($request->getType() !== Request::TYPE_POST) {
|
||||
return;
|
||||
}
|
||||
|
@ -446,132 +364,7 @@ class CurlService {
|
|||
'Content-Type: application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
|
||||
);
|
||||
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getDataBody());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param resource $curl
|
||||
* @param Request $request
|
||||
*/
|
||||
private function initRequestPut($curl, Request $request) {
|
||||
if ($request->getType() !== Request::TYPE_PUT) {
|
||||
return;
|
||||
}
|
||||
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getDataBody());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param resource $curl
|
||||
* @param Request $request
|
||||
*/
|
||||
private function initRequestDelete($curl, Request $request) {
|
||||
if ($request->getType() !== Request::TYPE_DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getDataBody());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param resource $curl
|
||||
* @param Request $request
|
||||
*/
|
||||
private function initRequestHeaders($curl, Request $request) {
|
||||
$headers = $request->getHeaders();
|
||||
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param resource $curl
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws RequestContentException
|
||||
* @throws RequestServerException
|
||||
* @throws RequestNetworkException
|
||||
*/
|
||||
private function parseRequestResult($curl, Request &$request) {
|
||||
$this->parseRequestResultCurl($curl, $request);
|
||||
|
||||
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
$type = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
|
||||
$request->setContentType((is_null($type) || is_bool($type)) ? '' : $type);
|
||||
$request->setResultCode($code);
|
||||
|
||||
$this->parseRequestResultCode301($code, $request);
|
||||
$this->parseRequestResultCode4xx($code, $request);
|
||||
$this->parseRequestResultCode5xx($code, $request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param resource $curl
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws RequestNetworkException
|
||||
*/
|
||||
private function parseRequestResultCurl($curl, Request $request) {
|
||||
$errno = curl_errno($curl);
|
||||
if ($errno > 0) {
|
||||
throw new RequestNetworkException(
|
||||
$errno . ' - ' . curl_error($curl) . ' - ' . json_encode(
|
||||
$request, JSON_UNESCAPED_SLASHES
|
||||
), $errno
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $code
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws RequestContentException
|
||||
*/
|
||||
private function parseRequestResultCode301($code, Request $request) {
|
||||
if ($code === 301) {
|
||||
throw new RequestContentException(
|
||||
'301 - ' . json_encode($request, JSON_UNESCAPED_SLASHES)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $code
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws RequestContentException
|
||||
*/
|
||||
private function parseRequestResultCode4xx(int $code, Request $request) {
|
||||
if ($code === 404 || $code === 410) {
|
||||
throw new RequestContentException(
|
||||
$code . ' - ' . json_encode($request, JSON_UNESCAPED_SLASHES)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $code
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws RequestServerException
|
||||
*/
|
||||
private function parseRequestResultCode5xx(int $code, Request $request) {
|
||||
if ($code === 500) {
|
||||
throw new RequestServerException(
|
||||
$code . ' - ' . json_encode($request, JSON_UNESCAPED_SLASHES)
|
||||
);
|
||||
}
|
||||
$this->initRequestPostOrig($curl, $request);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,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 Exception;
|
||||
use OCA\Social\AP;
|
||||
use OCA\Social\Db\ActorsRequest;
|
||||
|
@ -42,11 +47,6 @@ use OCA\Social\Exceptions\CacheContentMimeTypeException;
|
|||
use OCA\Social\Exceptions\CacheDocumentDoesNotExistException;
|
||||
use OCA\Social\Exceptions\ItemAlreadyExistsException;
|
||||
use OCA\Social\Exceptions\ItemUnknownException;
|
||||
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\Exceptions\UrlCloudException;
|
||||
|
@ -122,7 +122,6 @@ class DocumentService {
|
|||
* @return Document
|
||||
* @throws CacheDocumentDoesNotExistException
|
||||
* @throws MalformedArrayException
|
||||
* @throws RequestResultNotJsonException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
public function cacheRemoteDocument(string $id, bool $public = false) {
|
||||
|
@ -217,10 +216,9 @@ class DocumentService {
|
|||
* @throws CacheContentException
|
||||
* @throws CacheDocumentDoesNotExistException
|
||||
* @throws MalformedArrayException
|
||||
* @throws RequestResultNotJsonException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
public function getFromCache(string $id, string &$mimeType = '', bool $public = false) {
|
||||
public function getFromCache(string $id, string &$mimeType = '', bool $public = false): ISimpleFile {
|
||||
$document = $this->cacheRemoteDocument($id, $public);
|
||||
$mimeType = $document->getMimeType();
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ 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 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\RetrieveAccountFormatException;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\UnauthorizedFediverseException;
|
||||
|
|
|
@ -38,11 +38,11 @@ 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 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;
|
||||
|
|
|
@ -46,11 +46,11 @@ use OCA\Social\Exceptions\InvalidResourceException;
|
|||
use OCA\Social\Exceptions\ItemUnknownException;
|
||||
use OCA\Social\Exceptions\LinkedDataSignatureMissingException;
|
||||
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\SignatureException;
|
||||
use OCA\Social\Exceptions\SignatureIsGoneException;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
|
|
|
@ -42,11 +42,11 @@ use OCA\Social\Exceptions\ItemUnknownException;
|
|||
use OCA\Social\Exceptions\StreamNotFoundException;
|
||||
use OCA\Social\Exceptions\QueueStatusException;
|
||||
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\UnauthorizedFediverseException;
|
||||
use OCA\Social\Model\ActivityPub\Object\Note;
|
||||
|
|
|
@ -30,18 +30,19 @@ declare(strict_types=1);
|
|||
namespace OCA\Social\Service;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\DateTimeException;
|
||||
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 Exception;
|
||||
use OCA\Social\Db\StreamRequest;
|
||||
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\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\StreamNotFoundException;
|
||||
use OCA\Social\Exceptions\UnauthorizedFediverseException;
|
||||
|
@ -81,10 +82,6 @@ class StreamService {
|
|||
private $miscService;
|
||||
|
||||
|
||||
/** @var Person */
|
||||
private $viewer = null;
|
||||
|
||||
|
||||
/**
|
||||
* NoteService constructor.
|
||||
*
|
||||
|
@ -118,7 +115,6 @@ class StreamService {
|
|||
* @param Person $viewer
|
||||
*/
|
||||
public function setViewer(Person $viewer) {
|
||||
$this->viewer = $viewer;
|
||||
$this->streamRequest->setViewer($viewer);
|
||||
}
|
||||
|
||||
|
@ -149,7 +145,7 @@ class StreamService {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function assignStream(Stream &$stream) {
|
||||
public function assignStream(Stream $stream) {
|
||||
$stream->convertPublished();
|
||||
}
|
||||
|
||||
|
@ -384,7 +380,6 @@ class StreamService {
|
|||
*
|
||||
* @return Stream
|
||||
* @throws StreamNotFoundException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
public function getStreamById(string $id, bool $asViewer = false): Stream {
|
||||
return $this->streamRequest->getStreamById($id, $asViewer);
|
||||
|
@ -399,14 +394,15 @@ class StreamService {
|
|||
*
|
||||
* @return Stream[]
|
||||
* @throws StreamNotFoundException
|
||||
* @throws DateTimeException
|
||||
*/
|
||||
public function getRepliesByParentId(string $id, int $since = 0, int $limit = 5, bool $asViewer = false): array {
|
||||
public function getRepliesByParentId(string $id, int $since = 0, int $limit = 5, bool $asViewer = false
|
||||
): array {
|
||||
return $this->streamRequest->getRepliesByParentId($id, $since, $limit, $asViewer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Person $actor
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
|
@ -419,15 +415,14 @@ class StreamService {
|
|||
|
||||
|
||||
/**
|
||||
* @param Person $actor
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Note[]
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getStreamNotifications(Person $actor, int $since = 0, int $limit = 5): array {
|
||||
return $this->streamRequest->getTimelineNotifications($actor, $since, $limit);
|
||||
public function getStreamNotifications(int $since = 0, int $limit = 5): array {
|
||||
return $this->streamRequest->getTimelineNotifications($since, $limit);
|
||||
}
|
||||
|
||||
|
||||
|
@ -445,7 +440,6 @@ class StreamService {
|
|||
|
||||
|
||||
/**
|
||||
* @param Person $actor
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
|
@ -470,7 +464,6 @@ class StreamService {
|
|||
|
||||
|
||||
/**
|
||||
* @param Person $actor
|
||||
* @param string $hashtag
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
|
|
|
@ -10083,7 +10083,8 @@
|
|||
"jquery": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz",
|
||||
"integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg=="
|
||||
"integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==",
|
||||
"optional": true
|
||||
},
|
||||
"js-base64": {
|
||||
"version": "2.5.1",
|
||||
|
|
Ładowanie…
Reference in New Issue