2018-11-27 16:59:19 +00:00
|
|
|
<?php
|
2022-04-15 11:34:01 +00:00
|
|
|
|
2018-11-27 16:59:19 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
2024-09-08 13:46:22 +00:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-11-27 16:59:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Social\Controller;
|
|
|
|
|
|
|
|
use OCA\Social\AppInfo\Application;
|
|
|
|
use OCA\Social\Exceptions\SocialAppConfigException;
|
|
|
|
use OCA\Social\Model\RequestQueue;
|
|
|
|
use OCA\Social\Service\ActivityService;
|
|
|
|
use OCA\Social\Service\MiscService;
|
2019-01-24 11:24:17 +00:00
|
|
|
use OCA\Social\Service\RequestQueueService;
|
2023-05-25 20:45:28 +00:00
|
|
|
use OCA\Social\Tools\Traits\TAsync;
|
2018-11-27 16:59:19 +00:00
|
|
|
use OCP\AppFramework\Controller;
|
|
|
|
use OCP\IRequest;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class QueueController
|
|
|
|
*
|
|
|
|
* @package OCA\Social\Controller
|
|
|
|
*/
|
|
|
|
class QueueController extends Controller {
|
|
|
|
use TAsync;
|
|
|
|
|
2022-04-15 11:01:18 +00:00
|
|
|
private RequestQueueService $requestQueueService;
|
|
|
|
private ActivityService $activityService;
|
|
|
|
private MiscService $miscService;
|
2018-11-27 16:59:19 +00:00
|
|
|
|
|
|
|
public function __construct(
|
2019-01-24 11:24:17 +00:00
|
|
|
IRequest $request, RequestQueueService $requestQueueService, ActivityService $activityService,
|
2024-10-28 12:53:06 +00:00
|
|
|
MiscService $miscService,
|
2018-11-27 16:59:19 +00:00
|
|
|
) {
|
2023-06-20 10:02:58 +00:00
|
|
|
parent::__construct(Application::APP_ID, $request);
|
2018-11-27 16:59:19 +00:00
|
|
|
|
2019-01-24 11:24:17 +00:00
|
|
|
$this->requestQueueService = $requestQueueService;
|
2018-11-27 16:59:19 +00:00
|
|
|
$this->activityService = $activityService;
|
|
|
|
$this->miscService = $miscService;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @PublicPage
|
|
|
|
* @NoCSRFRequired
|
|
|
|
*/
|
2019-01-24 11:24:17 +00:00
|
|
|
public function asyncForRequest(string $token) {
|
|
|
|
$requests = $this->requestQueueService->getRequestFromToken($token, RequestQueue::STATUS_STANDBY);
|
2018-12-08 11:32:54 +00:00
|
|
|
|
2018-12-12 11:04:11 +00:00
|
|
|
if (!empty($requests)) {
|
2018-12-08 11:32:54 +00:00
|
|
|
$this->async();
|
|
|
|
|
|
|
|
$this->activityService->manageInit();
|
|
|
|
foreach ($requests as $request) {
|
|
|
|
$request->setTimeout(ActivityService::TIMEOUT_ASYNC);
|
|
|
|
try {
|
|
|
|
$this->activityService->manageRequest($request);
|
|
|
|
} catch (SocialAppConfigException $e) {
|
|
|
|
}
|
2018-11-27 16:59:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// or it will feed the logs.
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|