diff --git a/lib/Controller/NoteApiController.php b/lib/Controller/NoteApiController.php index 2d6dd02..6563114 100644 --- a/lib/Controller/NoteApiController.php +++ b/lib/Controller/NoteApiController.php @@ -96,9 +96,27 @@ class NoteApiController extends ApiController { * @param string $title * @param string $content * @param string $color + * @param bool $isPinned + * @param array $sharedWith + * @param array $tags + * @param array $attachments */ - public function create(string $title, string $content, string $color = null) { - $note = $this->noteService->create($this->userId, $title, $content, $color); + public function create(string $title, + string $content, + string $color = null, + bool $isPinned = false, + array $sharedWith = [], + array $tags = [], + array $attachments = []) + { + $note = $this->noteService->create($this->userId, + $title, + $content, + $color, + $isPinned, + $sharedWith, + $tags, + $attachments); $etag = md5(json_encode($note)); diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php index 9aa5883..d1358e6 100644 --- a/lib/Controller/NoteController.php +++ b/lib/Controller/NoteController.php @@ -90,9 +90,27 @@ class NoteController extends Controller { * @param string $title * @param string $content * @param string $color + * @param bool $isPinned + * @param array $sharedWith + * @param array $tags + * @param array $attachments */ - public function create(string $title, string $content, string $color = null) { - $note = $this->noteService->create($this->userId, $title, $content, $color); + public function create(string $title, + string $content, + string $color = null, + bool $isPinned = false, + array $sharedWith = [], + array $tags = [], + array $attachments = []) + { + $note = $this->noteService->create($this->userId, + $title, + $content, + $color, + $isPinned, + $sharedWith, + $tags, + $attachments); $etag = md5(json_encode($note)); diff --git a/lib/Service/NoteService.php b/lib/Service/NoteService.php index ed13bbe..11df0fb 100644 --- a/lib/Service/NoteService.php +++ b/lib/Service/NoteService.php @@ -152,9 +152,21 @@ class NoteService { * @param string $userId * @param string $title * @param string $content - * @param string $color + * @param string $color optional color. + * @param bool $isPinned optional if note must be pinned + * @param array $sharedWith optional list of shares + * @param array $tags optional list of tags + * @param array $attachments optional list of attachments */ - public function create(string $userId, string $title, string $content, string $color = NULL): Note { + public function create(string $userId, + string $title, + string $content, + string $color = null, + bool $isPinned = false, + array $sharedWith = [], + array $tags = [], + array $attachments = []): ?Note + { if (is_null($color)) { $color = $this->settingsService->getColorForNewNotes(); } @@ -168,17 +180,21 @@ class NoteService { $hcolor = $this->colormapper->insert($hcolor); } + // Create note and insert it $note = new Note(); $note->setTitle($title); $note->setContent($content); + $note->setPinned($isPinned ? 1 : 0); $note->setTimestamp(time()); $note->setColorId($hcolor->id); $note->setUserId($userId); $newNote = $this->notemapper->insert($note); + // TODO: Insert optional shares, tags and attachments. + // Insert true color pin and tags to response $newNote->setColor($hcolor->getColor()); $newNote->setIsPinned(false);