Fix the admin notification API

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-04-15 11:15:14 +02:00
Родитель aff3a20209
Коммит 67703b64a5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
3 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -27,6 +27,7 @@ return [
['name' => 'Endpoint#deleteAllNotifications', 'url' => '/api/{apiVersion}/notifications', 'verb' => 'DELETE', 'requirements' => ['apiVersion' => 'v(1|2)']],
['name' => 'Push#registerDevice', 'url' => '/api/{apiVersion}/push', 'verb' => 'POST', 'requirements' => ['apiVersion' => 'v2']],
['name' => 'Push#removeDevice', 'url' => '/api/{apiVersion}/push', 'verb' => 'DELETE', 'requirements' => ['apiVersion' => 'v2']],
['name' => 'API#generateNotification', 'url' => '/api/{apiVersion}/notifications/{userId}', 'verb' => 'POST', 'requirements' => ['apiVersion' => 'v(1|2)'], 'root' => '/apps/admin_notifications'],
['name' => 'API#generateNotification', 'url' => '/api/{apiVersion}/admin_notifications/{userId}', 'verb' => 'POST', 'requirements' => ['apiVersion' => 'v(1|2)']],
],
];

Просмотреть файл

@ -28,9 +28,13 @@ Options:
## HTTP request
> ⚠️ The URL had to be changed when switching from Nextcloud 20 to 21:
> * 20 and earlier: ocs/v2.php/apps/admin_notifications/api/v1/notifications/{user}
> * 21 and later: ocs/v2.php/apps/notifications/api/v2/admin_notifications/{user}
```
curl -H "OCS-APIREQUEST: true" -X POST \
https://admin:admin@localhost/ocs/v2.php/apps/admin_notifications/api/v1/notifications/admin \
https://admin:admin@localhost/ocs/v2.php/apps/notifications/api/v1/admin_notifications/admin \
-d "shortMessage=Short message up to 255 characters" \
-d "longMessage=Optional: longer message with more details, up to 4000 characters"
```

Просмотреть файл

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
*
@ -43,14 +46,11 @@ class APIController extends OCSController {
/** @var IManager */
protected $notificationManager;
/**
* @param string $appName
* @param IRequest $request
* @param ITimeFactory $timeFactory
* @param IUserManager $userManager
* @param IManager $notificationManager
*/
public function __construct($appName, IRequest $request, ITimeFactory $timeFactory, IUserManager $userManager, IManager $notificationManager) {
public function __construct(string $appName,
IRequest $request,
ITimeFactory $timeFactory,
IUserManager $userManager,
IManager $notificationManager) {
parent::__construct($appName, $request);
$this->timeFactory = $timeFactory;