summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appinfo/routes.php12
-rw-r--r--lib/Command/QueueProcess.php59
-rw-r--r--lib/Command/QueueStatus.php14
-rw-r--r--lib/Controller/QueueController.php16
-rw-r--r--lib/Cron/Queue.php6
-rw-r--r--lib/Db/CoreRequestBuilder.php2
-rw-r--r--lib/Db/NotesRequestBuilder.php5
-rw-r--r--lib/Db/RequestQueueRequest.php20
-rw-r--r--lib/Db/RequestQueueRequestBuilder.php10
-rw-r--r--lib/Migration/Version0002Date20190121153145.php152
-rw-r--r--lib/Model/RequestQueue.php27
-rw-r--r--lib/Service/ActivityService.php32
-rw-r--r--lib/Service/CurlService.php4
-rw-r--r--lib/Service/RequestQueueService.php (renamed from lib/Service/QueueService.php)4
14 files changed, 274 insertions, 89 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index dc309c09..7c056217 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -38,10 +38,10 @@ return [
'routes' => [
['name' => 'Navigation#navigate', 'url' => '/', 'verb' => 'GET'],
['name' => 'Navigation#test', 'url' => '/test', 'verb' => 'GET'],
-
[
'name' => 'Navigation#timeline', 'url' => '/timeline/{path}', 'verb' => 'GET',
- 'requirements' => ['path' => '.+'], 'defaults' => ['path' => '']
+ 'requirements' => ['path' => '.+'],
+ 'defaults' => ['path' => '']
],
['name' => 'Navigation#documentGet', 'url' => '/document/get', 'verb' => 'GET'],
['name' => 'Navigation#documentGetPublic', 'url' => '/document/public', 'verb' => 'GET'],
@@ -84,12 +84,8 @@ return [
['name' => 'Local#documentsCache', 'url' => '/api/v1/documents/cache', 'verb' => 'POST'],
- ['name' => 'Queue#asyncWithToken', 'url' => CurlService::ASYNC_TOKEN, 'verb' => 'POST'],
-
- [
- 'name' => 'Config#setCloudAddress', 'url' => '/api/v1/config/cloudAddress',
- 'verb' => 'POST'
- ],
+ ['name' => 'Queue#asyncForRequest', 'url' => CurlService::ASYNC_REQUEST_TOKEN, 'verb' => 'POST'],
+ ['name' => 'Config#setCloudAddress', 'url' => '/api/v1/config/cloudAddress', 'verb' => 'POST']
]
];
diff --git a/lib/Command/QueueProcess.php b/lib/Command/QueueProcess.php
index 20ea8f14..69006183 100644
--- a/lib/Command/QueueProcess.php
+++ b/lib/Command/QueueProcess.php
@@ -36,7 +36,8 @@ use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Service\ActivityService;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\MiscService;
-use OCA\Social\Service\QueueService;
+use OCA\Social\Service\RequestQueueService;
+use OCA\Social\Service\StreamQueueService;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -47,8 +48,11 @@ class QueueProcess extends Base {
/** @var ActivityService */
private $activityService;
- /** @var QueueService */
- private $queueService;
+ /** @var StreamQueueService */
+ private $streamQueueService;
+
+ /** @var RequestQueueService */
+ private $requestQueueService;
/** @var ConfigService */
private $configService;
@@ -61,18 +65,21 @@ class QueueProcess extends Base {
* NoteCreate constructor.
*
* @param ActivityService $activityService
- * @param QueueService $queueService
+ * @param RequestQueueService $requestQueueService
+ * @param StreamQueueService $streamQueueService
* @param ConfigService $configService
* @param MiscService $miscService
*/
public function __construct(
- ActivityService $activityService, QueueService $queueService, ConfigService $configService,
+ ActivityService $activityService, RequestQueueService $requestQueueService,
+ StreamQueueService $streamQueueService, ConfigService $configService,
MiscService $miscService
) {
parent::__construct();
$this->activityService = $activityService;
- $this->queueService = $queueService;
+ $this->requestQueueService = $requestQueueService;
+ $this->streamQueueService = $streamQueueService;
$this->configService = $configService;
$this->miscService = $miscService;
}
@@ -94,14 +101,24 @@ class QueueProcess extends Base {
*/
protected function execute(InputInterface $input, OutputInterface $output) {
- $requests = $this->queueService->getRequestStandby($total = 0);
+ $output->writeLn('processing requests queue');
+ $this->processRequestQueue($output);
+
+ $output->writeLn('processing stream queue');
+ $this->processStreamQueue($output);
+ }
+
+
+ private function processRequestQueue(OutputInterface $output) {
+ $total = 0;
+ $requests = $this->requestQueueService->getRequestStandby($total);
- $output->writeLn('found a total of ' . $total . ' requests in the queue');
+ $output->writeLn('- found a total of ' . $total . ' requests in the queue');
if ($total === 0) {
return;
}
- $output->writeLn(sizeof($requests) . ' are processable at this time');
+ $output->writeLn('- ' . sizeof($requests) . ' are processable at this time');
if (sizeof($requests) === 0) {
return;
}
@@ -119,5 +136,27 @@ class QueueProcess extends Base {
$output->writeLn('done');
}
-}
+ private function processStreamQueue(OutputInterface $output) {
+ $total = 0;
+ $items = $this->streamQueueService->getRequestStandby($total);
+
+ $output->writeLn('- found a total of ' . $total . ' not cached object in the queue');
+ if ($total === 0) {
+ return;
+ }
+
+ $output->writeLn('- ' . sizeof($items) . ' are processable at this time');
+ if (sizeof($items) === 0) {
+ return;
+ }
+
+ foreach ($items as $item) {
+ $output->write('.');
+ $this->streamQueueService->manageStreamQueue($item);
+ }
+
+ $output->writeLn('done');
+ }
+
+}
diff --git a/lib/Command/QueueStatus.php b/lib/Command/QueueStatus.php
index 932b7ea2..baa85c0b 100644
--- a/lib/Command/QueueStatus.php
+++ b/lib/Command/QueueStatus.php
@@ -34,7 +34,7 @@ use Exception;
use OC\Core\Command\Base;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\MiscService;
-use OCA\Social\Service\QueueService;
+use OCA\Social\Service\RequestQueueService;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -46,8 +46,8 @@ class QueueStatus extends Base {
/** @var ConfigService */
private $configService;
- /** @var QueueService */
- private $queueService;
+ /** @var RequestQueueService */
+ private $requestQueueService;
/** @var MiscService */
private $miscService;
@@ -56,16 +56,16 @@ class QueueStatus extends Base {
/**
* NoteCreate constructor.
*
- * @param QueueService $queueService
+ * @param RequestQueueService $requestQueueService
* @param ConfigService $configService
* @param MiscService $miscService
*/
public function __construct(
- QueueService $queueService, ConfigService $configService, MiscService $miscService
+ RequestQueueService $requestQueueService, ConfigService $configService, MiscService $miscService
) {
parent::__construct();
- $this->queueService = $queueService;
+ $this->requestQueueService = $requestQueueService;
$this->configService = $configService;
$this->miscService = $miscService;
}
@@ -98,7 +98,7 @@ class QueueStatus extends Base {
throw new Exception('As of today, --token is mandatory');
}
- $requests = $this->queueService->getRequestFromToken($token);
+ $requests = $this->requestQueueService->getRequestFromToken($token);
foreach ($requests as $request) {
$output->writeLn(json_encode($request));
diff --git a/lib/Controller/QueueController.php b/lib/Controller/QueueController.php
index 4fd4c10f..f562ee64 100644
--- a/lib/Controller/QueueController.php
+++ b/lib/Controller/QueueController.php
@@ -36,7 +36,7 @@ use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Model\RequestQueue;
use OCA\Social\Service\ActivityService;
use OCA\Social\Service\MiscService;
-use OCA\Social\Service\QueueService;
+use OCA\Social\Service\RequestQueueService;
use OCP\AppFramework\Controller;
use OCP\IRequest;
@@ -51,8 +51,8 @@ class QueueController extends Controller {
use TAsync;
- /** @var QueueService */
- private $queueService;
+ /** @var RequestQueueService */
+ private $requestQueueService;
/** @var ActivityService */
private $activityService;
@@ -65,17 +65,17 @@ class QueueController extends Controller {
* QueueController constructor.
*
* @param IRequest $request
- * @param QueueService $queueService
+ * @param RequestQueueService $requestQueueService
* @param ActivityService $activityService
* @param MiscService $miscService
*/
public function __construct(
- IRequest $request, QueueService $queueService, ActivityService $activityService,
+ IRequest $request, RequestQueueService $requestQueueService, ActivityService $activityService,
MiscService $miscService
) {
parent::__construct(Application::APP_NAME, $request);
- $this->queueService = $queueService;
+ $this->requestQueueService = $requestQueueService;
$this->activityService = $activityService;
$this->miscService = $miscService;
}
@@ -87,8 +87,8 @@ class QueueController extends Controller {
*
* @param string $token
*/
- public function asyncWithToken(string $token) {
- $requests = $this->queueService->getRequestFromToken($token, RequestQueue::STATUS_STANDBY);
+ public function asyncForRequest(string $token) {
+ $requests = $this->requestQueueService->getRequestFromToken($token, RequestQueue::STATUS_STANDBY);
if (!empty($requests)) {
$this->async();
diff --git a/lib/Cron/Queue.php b/lib/Cron/Queue.php
index 21f15fdb..02c1e232 100644
--- a/lib/Cron/Queue.php
+++ b/lib/Cron/Queue.php
@@ -36,7 +36,7 @@ use OCA\Social\AppInfo\Application;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Service\ActivityService;
use OCA\Social\Service\MiscService;
-use OCA\Social\Service\QueueService;
+use OCA\Social\Service\RequestQueueService;
use OCP\AppFramework\QueryException;
@@ -51,7 +51,7 @@ class Queue extends TimedJob {
/** @var ActivityService */
private $activityService;
- /** @var QueueService */
+ /** @var RequestQueueService */
private $queueService;
/** @var MiscService */
@@ -75,7 +75,7 @@ class Queue extends TimedJob {
$app = new Application();
$c = $app->getContainer();
- $this->queueService = $c->query(QueueService::class);
+ $this->queueService = $c->query(RequestQueueService::class);
$this->activityService = $c->query(ActivityService::class);
$this->miscService = $c->query(MiscService::class);
diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php
index 6adc41c8..c6c7dbb5 100644
--- a/lib/Db/CoreRequestBuilder.php
+++ b/lib/Db/CoreRequestBuilder.php
@@ -63,6 +63,8 @@ class CoreRequestBuilder {
const TABLE_CACHE_ACTORS = 'social_cache_actors';
const TABLE_CACHE_DOCUMENTS = 'social_cache_documents';
+ const TABLE_QUEUE_STREAM = 'social_queue_stream';
+
/** @var IDBConnection */
protected $dbConnection;
diff --git a/lib/Db/NotesRequestBuilder.php b/lib/Db/NotesRequestBuilder.php
index 5d770ddd..6719ad59 100644
--- a/lib/Db/NotesRequestBuilder.php
+++ b/lib/Db/NotesRequestBuilder.php
@@ -82,9 +82,8 @@ class NotesRequestBuilder extends CoreRequestBuilder {
/** @noinspection PhpMethodParametersCountMismatchInspection */
$qb->select(
'sn.id', 'sn.type', 'sn.to', 'sn.to_array', 'sn.cc', 'sn.bcc', 'sn.content',
- 'sn.summary',
- 'sn.published', 'sn.published_time', 'sn.attributed_to', 'sn.in_reply_to', 'sn.source',
- 'sn.local', 'sn.instances', 'sn.creation'
+ 'sn.summary', 'sn.published', 'sn.published_time', 'sn.cache', 'sn.attributed_to',
+ 'sn.in_reply_to', 'sn.source', 'sn.local', 'sn.instances', 'sn.creation'
)
->from(self::TABLE_SERVER_NOTES, 'sn');
diff --git a/lib/Db/RequestQueueRequest.php b/lib/Db/RequestQueueRequest.php
index fbfa127e..5608da07 100644
--- a/lib/Db/RequestQueueRequest.php
+++ b/lib/Db/RequestQueueRequest.php
@@ -63,7 +63,7 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
* @param RequestQueue $queue
*/
public function create(RequestQueue $queue) {
- $qb = $this->getQueueInsertSql();
+ $qb = $this->getRequestQueueInsertSql();
$qb->setValue('token', $qb->createNamedParameter($queue->getToken()))
->setValue('author', $qb->createNamedParameter($queue->getAuthor()))
->setValue('activity', $qb->createNamedParameter($queue->getActivity()))
@@ -85,14 +85,14 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
* @return RequestQueue[]
*/
public function getStandby(): array {
- $qb = $this->getQueueSelectSql();
+ $qb = $this->getRequestQueueSelectSql();
$this->limitToStatus($qb, RequestQueue::STATUS_STANDBY);
$qb->orderBy('id', 'asc');
$requests = [];
$cursor = $qb->execute();
while ($data = $cursor->fetch()) {
- $requests[] = $this->parseQueueSelectSql($data);
+ $requests[] = $this->parseRequestQueueSelectSql($data);
}
$cursor->closeCursor();
@@ -109,7 +109,7 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
* @return RequestQueue[]
*/
public function getFromToken(string $token, int $status = -1): array {
- $qb = $this->getQueueSelectSql();
+ $qb = $this->getRequestQueueSelectSql();
$this->limitToToken($qb, $token);
if ($status > -1) {
@@ -121,7 +121,7 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
$requests = [];
$cursor = $qb->execute();
while ($data = $cursor->fetch()) {
- $requests[] = $this->parseQueueSelectSql($data);
+ $requests[] = $this->parseRequestQueueSelectSql($data);
}
$cursor->closeCursor();
@@ -135,7 +135,7 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
* @throws QueueStatusException
*/
public function setAsRunning(RequestQueue &$queue) {
- $qb = $this->getQueueUpdateSql();
+ $qb = $this->getRequestQueueUpdateSql();
$qb->set('status', $qb->createNamedParameter(RequestQueue::STATUS_RUNNING))
->set(
'last',
@@ -160,7 +160,7 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
* @throws QueueStatusException
*/
public function setAsSuccess(RequestQueue &$queue) {
- $qb = $this->getQueueUpdateSql();
+ $qb = $this->getRequestQueueUpdateSql();
$qb->set('status', $qb->createNamedParameter(RequestQueue::STATUS_SUCCESS));
$this->limitToId($qb, $queue->getId());
$this->limitToStatus($qb, RequestQueue::STATUS_RUNNING);
@@ -176,12 +176,12 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
/**
- * @param RequestQueue $queue >ll
+ * @param RequestQueue $queue
*
* @throws QueueStatusException
*/
public function setAsFailure(RequestQueue &$queue) {
- $qb = $this->getQueueUpdateSql();
+ $qb = $this->getRequestQueueUpdateSql();
$func = $qb->func();
$expr = $qb->expr();
@@ -201,7 +201,7 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
public function delete(RequestQueue $queue) {
- $qb = $this->getQueueDeleteSql();
+ $qb = $this->getRequestQueueDeleteSql();
$this->limitToId($qb, $queue->getId());
$qb->execute();
diff --git a/lib/Db/RequestQueueRequestBuilder.php b/lib/Db/RequestQueueRequestBuilder.php
index 41060f80..b3a59150 100644
--- a/lib/Db/RequestQueueRequestBuilder.php
+++ b/lib/Db/RequestQueueRequestBuilder.php
@@ -45,7 +45,7 @@ class RequestQueueRequestBuilder extends CoreRequestBuilder {
*
* @return IQueryBuilder
*/
- protected function getQueueInsertSql(): IQueryBuilder {
+ protected function getRequestQueueInsertSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder();
$qb->insert(self::TABLE_REQUEST_QUEUE);
@@ -58,7 +58,7 @@ class RequestQueueRequestBuilder extends CoreRequestBuilder {
*
* @return IQueryBuilder
*/
- protected function getQueueUpdateSql(): IQueryBuilder {
+ protected function getRequestQueueUpdateSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder();
$qb->update(self::TABLE_REQUEST_QUEUE);
@@ -71,7 +71,7 @@ class RequestQueueRequestBuilder extends CoreRequestBuilder {
*
* @return IQueryBuilder
*/
- protected function getQueueSelectSql(): IQueryBuilder {
+ protected function getRequestQueueSelectSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder();
/** @noinspection PhpMethodParametersCountMismatchInspection */
@@ -92,7 +92,7 @@ class RequestQueueRequestBuilder extends CoreRequestBuilder {
*
* @return IQueryBuilder
*/
- protected function getQueueDeleteSql(): IQueryBuilder {
+ protected function getRequestQueueDeleteSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder();
$qb->delete(self::TABLE_REQUEST_QUEUE);
@@ -105,7 +105,7 @@ class RequestQueueRequestBuilder extends CoreRequestBuilder {
*
* @return RequestQueue
*/
- protected function parseQueueSelectSql($data): RequestQueue {
+ protected function parseRequestQueueSelectSql($data): RequestQueue {
$queue = new RequestQueue();
$queue->importFromDatabase($data);
diff --git a/lib/Migration/Version0002Date20190121153145.php b/lib/Migration/Version0002Date20190121153145.php
new file mode 100644
index 00000000..7958e793
--- /dev/null
+++ b/lib/Migration/Version0002Date20190121153145.php
@@ -0,0 +1,152 @@
+<?php
+declare(strict_types=1);
+
+
+/**
+ * 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\Migration;
+
+
+use Closure;
+use Doctrine\DBAL\DBALException;
+use Doctrine\DBAL\Schema\SchemaException;
+use Doctrine\DBAL\Types\Type;
+use OCA\Social\Db\CoreRequestBuilder;
+use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+
+/**
+ * Class Version0001Date20190121153145
+ *
+ * @package OCA\Social\Migration
+ */
+class Version0002Date20190121153145 extends SimpleMigrationStep {
+
+
+ /** @var IDBConnection */
+ private $connection;
+
+
+ /**
+ * @param IDBConnection $connection
+ */
+ public function __construct(IDBConnection $connection) {
+ $this->connection = $connection;
+ }
+
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ *
+ * @return ISchemaWrapper
+ * @throws SchemaException
+ * @throws DBALException
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options
+ ): ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_NOTES);
+ if (!$table->hasColumn('cache')) {
+ $table->addColumn('cache', Type::TEXT, ['notnull' => false]);
+ }
+
+ $table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_NOTES);
+ if (!$table->hasColumn('activity_id')) {
+ $table->addColumn('activity_id', Type::STRING, ['notnull' => false, 'length' => 255]);
+ }
+
+ if (!$schema->hasTable(CoreRequestBuilder::TABLE_QUEUE_STREAM)) {
+ $table = $schema->createTable(CoreRequestBuilder::TABLE_QUEUE_STREAM);
+ $table->addColumn(
+ 'id', 'bigint', [
+ 'autoincrement' => true,
+ 'notnull' => true,
+ 'length' => 11,
+ 'unsigned' => true,
+ ]
+ );
+ $table->addColumn(
+ 'token', 'string', [
+ 'notnull' => true,
+ 'length' => 63,
+ ]
+ );
+ $table->addColumn(
+ 'stream_id', 'string', [
+ 'notnull' => true,
+ 'length' => 255,
+ ]
+ );
+ $table->addColumn(
+ 'type', 'string', [
+ 'notnull' => true,
+ 'length' => 31,
+ ]
+ );
+ $table->addColumn(
+ 'status', 'smallint', [
+ 'notnull' => false,
+ 'length' => 1,
+ 'default' => 0,
+ ]
+ );
+ $table->addColumn(
+ 'tries', 'smallint', [
+ 'notnull' => false,
+ 'length' => 2,
+ 'default' => 0,
+ ]
+ );
+ $table->addColumn(
+ 'last', 'datetime', [
+ 'notnull' => false,
+ ]
+ );
+ $table->setPrimaryKey(['id']);
+ }
+
+ return $schema;
+ }
+
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ */
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
+ }
+
+}
+
diff --git a/lib/Model/RequestQueue.php b/lib/Model/RequestQueue.php
index afe0c1f5..63f24e00 100644
--- a/lib/Model/RequestQueue.php
+++ b/lib/Model/RequestQueue.php
@@ -32,6 +32,7 @@ namespace OCA\Social\Model;
use daita\MySmallPhpTools\Traits\TArrayTools;
+use daita\MySmallPhpTools\Traits\TStringTools;
use DateTime;
use JsonSerializable;
@@ -45,6 +46,7 @@ class RequestQueue implements JsonSerializable {
use TArrayTools;
+ use TStringTools;
const STATUS_STANDBY = 0;
@@ -138,6 +140,16 @@ class RequestQueue implements JsonSerializable {
return $this;
}
+ /**
+ * @return RequestQueue
+ */
+ public function resetToken(): RequestQueue {
+ $uuid = $this->uuid();
+ $this->setToken($uuid);
+
+ return $this;
+ }
+
/**
* @return string
@@ -159,21 +171,6 @@ class RequestQueue implements JsonSerializable {
/**
- * @return RequestQueue
- */
- public function resetToken(): RequestQueue {
- $uuid = sprintf(
- '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff),
- mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
- mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
- );
-
- $this->setToken($uuid);
-
- return $this;
- }
-
- /**
* @return string
*/
public function getActivity(): string {
diff --git a/lib/Service/ActivityService.php b/lib/Service/ActivityService.php
index d89c5195..7c8dbc93 100644
--- a/lib/Service/ActivityService.php
+++ b/lib/Service/ActivityService.php
@@ -76,8 +76,8 @@ class ActivityService {
/** @var SignatureService */
private $signatureService;
- /** @var QueueService */
- private $queueService;
+ /** @var RequestQueueService */
+ private $requestQueueService;
/** @var AccountService */
private $accountService;
@@ -102,7 +102,7 @@ class ActivityService {
* @param NotesRequest $notesRequest
* @param FollowsRequest $followsRequest
* @param SignatureService $signatureService
- * @param QueueService $queueService
+ * @param RequestQueueService $requestQueueService
* @param AccountService $accountService
* @param CurlService $curlService
* @param ConfigService $configService
@@ -110,13 +110,13 @@ class ActivityService {
*/
public function __construct(
NotesRequest $notesRequest, FollowsRequest $followsRequest,
- SignatureService $signatureService, QueueService $queueService,
+ SignatureService $signatureService, RequestQueueService $requestQueueService,
AccountService $accountService, CurlService $curlService, ConfigService $configService,
MiscService $miscService
) {
$this->notesRequest = $notesRequest;
$this->followsRequest = $followsRequest;
- $this->queueService = $queueService;
+ $this->requestQueueService = $requestQueueService;
$this->accountService = $accountService;
$this->signatureService = $signatureService;
$this->curlService = $curlService;
@@ -217,11 +217,11 @@ class ActivityService {
$author = $this->getAuthorFromItem($activity);
$instancePaths = $this->generateInstancePaths($activity);
- $token = $this->queueService->generateRequestQueue($instancePaths, $activity, $author);
+ $token = $this->requestQueueService->generateRequestQueue($instancePaths, $activity, $author);
$this->manageInit();
try {
- $directRequest = $this->queueService->getPriorityRequest($token);
+ $directRequest = $this->requestQueueService->getPriorityRequest($token);
$directRequest->setTimeout(self::TIMEOUT_LIVE);
$this->manageRequest($directRequest);
} catch (NoHighPriorityRequestException $e) {
@@ -229,7 +229,7 @@ class ActivityService {
return '';
}
- $requests = $this->queueService->getRequestFromToken($token, RequestQueue::STATUS_STANDBY);
+ $requests = $this->requestQueueService->getRequestFromToken($token, RequestQueue::STATUS_STANDBY);
if (sizeof($requests) > 0) {
$this->curlService->asyncWithToken($token);
}
@@ -256,7 +256,7 @@ class ActivityService {
}
try {
- $this->queueService->initRequest($queue);
+ $this->requestQueueService->initRequest($queue);
} catch (QueueStatusException $e) {
return;
}
@@ -266,24 +266,24 @@ class ActivityService {
try {
$this->signatureService->signRequest($request, $queue);
$this->curlService->request($request);
- $this->queueService->endRequest($queue, true);
+ $this->requestQueueService->endRequest($queue, true);
} catch (RequestResultNotJsonException $e) {
- $this->queueService->endRequest($queue, true);
+ $this->requestQueueService->endRequest($queue, true);
} catch (ActorDoesNotExistException $e) {
$this->miscService->log(
'Error while managing request: ' . json_encode($request) . ' ' . $e->getMessage(), 1
);
- $this->queueService->deleteRequest($queue);
+ $this->requestQueueService->deleteRequest($queue);
} catch (RequestContentException $e) {
$this->miscService->log(
'Error while managing request: ' . json_encode($request) . ' ' . $e->getMessage(), 1
);
- $this->queueService->deleteRequest($queue);
+ $this->requestQueueService->deleteRequest($queue);
} catch (RequestResultSizeException $e) {
$this->miscService->log(
'Error while managing request: ' . json_encode($request) . ' ' . $e->getMessage(), 1
);
- $this->queueService->deleteRequest($queue);
+ $this->requestQueueService->deleteRequest($queue);
} catch (RequestServerException $e) {
$this->miscService->log(
'Temporary error while managing request: RequestServerException - ' . json_encode(
@@ -291,7 +291,7 @@ class ActivityService {
) . ' - '
. $e->getMessage(), 1
);
- $this->queueService->endRequest($queue, false);
+ $this->requestQueueService->endRequest($queue, false);
$this->failInstances[] = $host;
} catch (RequestNetworkException $e) {
$this->miscService->log(
@@ -299,7 +299,7 @@ class ActivityService {
$request
) . ' - ' . $e->getMessage(), 1
);
- $this->queueService->endRequest($queue, false);
+ $this->requestQueueService->endRequest($queue, false);
$this->failInstances[] = $host;
}
}
diff --git a/lib/Service/CurlService.php b/lib/Service/CurlService.php
index f9554670..c40335db 100644
--- a/lib/Service/CurlService.php
+++ b/lib/Service/CurlService.php
@@ -57,7 +57,7 @@ class CurlService {
use TPathTools;
- const ASYNC_TOKEN = '/async/token/{token}';
+ const ASYNC_REQUEST_TOKEN = '/async/request/{token}';
const USER_AGENT = 'Nextcloud Social';
@@ -237,7 +237,7 @@ class CurlService {
$parse = parse_url($address);
$host = $this->get('host', $parse, '');
$path = $this->withEndSlash($this->get('path', $parse, '')) . $this->withoutBeginSlash(
- self::ASYNC_TOKEN
+ self::ASYNC_REQUEST_TOKEN
);
$path = str_replace('{token}', $token, $path);
diff --git a/lib/Service/QueueService.php b/lib/Service/RequestQueueService.php
index b95f7415..ee5b1754 100644
--- a/lib/Service/QueueService.php
+++ b/lib/Service/RequestQueueService.php
@@ -41,7 +41,7 @@ use OCA\Social\Model\InstancePath;
use OCA\Social\Model\RequestQueue;
-class QueueService {
+class RequestQueueService {
<