diff --git a/appinfo/routes.php b/appinfo/routes.php
index 5a8fac49..0afbc269 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -1,4 +1,5 @@
*
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index cb1e164f..7786ab6a 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -27,7 +27,5 @@
class Application extends App {
public function __construct (array $urlParams = array()) {
parent::__construct('survey_client', $urlParams);
-
- $this->getContainer()->registerAlias('EndpointController', 'OCA\Survey_Client\Controller\EndpointController');
}
}
diff --git a/lib/Collector.php b/lib/Collector.php
index af70d3df..dfad9a34 100644
--- a/lib/Collector.php
+++ b/lib/Collector.php
@@ -31,6 +31,7 @@
use OCA\Survey_Client\Categories\Server;
use OCA\Survey_Client\Categories\Stats;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\DataResponse;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -151,9 +152,9 @@ public function getReport() {
}
/**
- * @return \OC\OCS\Result
+ * @return DataResponse
*/
- public function sendReport() {
+ public function sendReport(): DataResponse {
$report = $this->getReport();
$client = $this->clientService->newClient();
@@ -166,7 +167,7 @@ public function sendReport() {
],
]);
} catch (\Exception $e) {
- return new \OC\OCS\Result(
+ return new DataResponse(
$report,
Http::STATUS_INTERNAL_SERVER_ERROR
);
@@ -175,13 +176,12 @@ public function sendReport() {
if ($response->getStatusCode() === Http::STATUS_OK) {
$this->config->setAppValue('survey_client', 'last_sent', time());
$this->config->setAppValue('survey_client', 'last_report', json_encode($report));
- return new \OC\OCS\Result(
- $report,
- 100// HTTP::STATUS_OK, TODO: failure200
+ return new DataResponse(
+ $report
);
}
- return new \OC\OCS\Result(
+ return new DataResponse(
$report,
Http::STATUS_INTERNAL_SERVER_ERROR
);
diff --git a/lib/Controller/EndpointController.php b/lib/Controller/EndpointController.php
index bff98956..b6ff563d 100644
--- a/lib/Controller/EndpointController.php
+++ b/lib/Controller/EndpointController.php
@@ -1,4 +1,5 @@
*
@@ -22,13 +23,15 @@
namespace OCA\Survey_Client\Controller;
use OCA\Survey_Client\Collector;
-use OCP\AppFramework\Controller;
-use OCP\AppFramework\Http;
+
+use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\OCSController;
use OCP\BackgroundJob\IJobList;
use OCP\IRequest;
use OCP\Notification\IManager;
+use OCA\Survey_Client\BackgroundJobs\MonthlyReport;
-class EndpointController extends Controller {
+class EndpointController extends OCSController {
/** @var Collector */
protected $collector;
@@ -46,7 +49,11 @@ class EndpointController extends Controller {
* @param IJobList $jobList
* @param IManager $manager
*/
- public function __construct($appName, IRequest $request, Collector $collector, IJobList $jobList, IManager $manager) {
+ public function __construct(string $appName,
+ IRequest $request,
+ Collector $collector,
+ IJobList $jobList,
+ IManager $manager) {
parent::__construct($appName, $request);
$this->collector = $collector;
@@ -55,35 +62,35 @@ public function __construct($appName, IRequest $request, Collector $collector, I
}
/**
- * @return \OC\OCS\Result
+ * @return DataResponse
*/
- public function enableMonthly() {
- $this->jobList->add('OCA\Survey_Client\BackgroundJobs\MonthlyReport');
+ public function enableMonthly(): DataResponse {
+ $this->jobList->add(MonthlyReport::class);
$notification = $this->manager->createNotification();
$notification->setApp('survey_client');
$this->manager->markProcessed($notification);
- return new \OC\OCS\Result();
+ return new DataResponse();
}
/**
- * @return \OC\OCS\Result
+ * @return DataResponse
*/
- public function disableMonthly() {
- $this->jobList->remove('OCA\Survey_Client\BackgroundJobs\MonthlyReport');
+ public function disableMonthly(): DataResponse {
+ $this->jobList->remove(MonthlyReport::class);
$notification = $this->manager->createNotification();
$notification->setApp('survey_client');
$this->manager->markProcessed($notification);
- return new \OC\OCS\Result();
+ return new DataResponse();
}
/**
- * @return \OC\OCS\Result
+ * @return DataResponse
*/
- public function sendReport() {
+ public function sendReport(): DataResponse {
return $this->collector->sendReport();
}
}