53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
namespace OCA\OwnNotes\Controller;
|
|
|
|
use OCP\IRequest;
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
use OCP\AppFramework\Controller;
|
|
|
|
use OCA\OwnNotes\Service\NoteService;
|
|
|
|
class NoteController extends Controller {
|
|
|
|
private $service;
|
|
private $userId;
|
|
|
|
use Errors;
|
|
|
|
public function __construct($AppName, IRequest $request,
|
|
NoteService $service, $UserId){
|
|
parent::__construct($AppName, $request);
|
|
$this->service = $service;
|
|
$this->userId = $UserId;
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
*/
|
|
public function favorites() {
|
|
return new DataResponse($this->service->findAll($this->userId));
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
*
|
|
* @param string $title
|
|
* @param string $content
|
|
*/
|
|
public function fav($id) {
|
|
return $this->service->create($id, $this->userId);
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
*
|
|
* @param int $id
|
|
*/
|
|
public function unfav($id) {
|
|
return $this->handleNotFound(function () use ($id) {
|
|
return $this->service->delete($id, $this->userId);
|
|
});
|
|
}
|
|
|
|
}
|