Merge pull request #43 from matiasdelellis/newApi

New api
This commit is contained in:
matiasdelellis
2020-09-19 18:42:12 -03:00
committed by GitHub
12 changed files with 219 additions and 84 deletions

View File

@@ -204,14 +204,14 @@ View.prototype = {
this._editableId(note.id); this._editableId(note.id);
this._editableTitle(note.title); this._editableTitle(note.title);
this._editableContent(note.content); this._editableContent(note.content);
this._editablePinned(note.ispinned); this._editablePinned(note.isPinned);
this._editableColor(note.color); this._editableColor(note.color);
this._editableShares(note.shared_with); this._editableShares(note.sharedWith);
this._editableTags(note.tags); this._editableTags(note.tags);
this._editableAttachts(note.attachts, !note.is_shared); this._editableAttachts(note.attachments, !note.sharedBy.length);
// Create medium div editor. // Create medium div editor.
this._isEditable(!note.is_shared); this._isEditable(!note.sharedBy.length);
// Show modal editor // Show modal editor
this._showEditor(id); this._showEditor(id);
@@ -222,11 +222,11 @@ View.prototype = {
id: this._editableId(), id: this._editableId(),
title: this._editableTitle(), title: this._editableTitle(),
content: this._editableContent(), content: this._editableContent(),
attachts: this._editableAttachts(), attachments: this._editableAttachts(),
color: this._editableColor(), color: this._editableColor(),
pinned: this._editablePinned(), isPinned: this._editablePinned(),
tags: this._editableTags(), tags: this._editableTags(),
shared_with: this._editableShares() sharedWith: this._editableShares()
}; };
var self = this; var self = this;
this._notes.update(fakeNote).done(function (note) { this._notes.update(fakeNote).done(function (note) {
@@ -390,7 +390,7 @@ View.prototype = {
var id = parseInt(gridNote.data('id'), 10); var id = parseInt(gridNote.data('id'), 10);
var note = self._notes.read(id); var note = self._notes.read(id);
note.pinned = true; note.isPinned = true;
self._notes.update(note).done(function () { self._notes.update(note).done(function () {
icon.removeClass("hide-header-icon"); icon.removeClass("hide-header-icon");
@@ -413,7 +413,7 @@ View.prototype = {
var id = parseInt(gridNote.data('id'), 10); var id = parseInt(gridNote.data('id'), 10);
var note = self._notes.read(id); var note = self._notes.read(id);
note.pinned = false; note.isPinned = false;
self._notes.update(note).done(function () { self._notes.update(note).done(function () {
icon.removeClass("fixed-header-icon"); icon.removeClass("fixed-header-icon");
@@ -851,7 +851,7 @@ View.prototype = {
}; };
}); });
} else { } else {
var html = Handlebars.templates['shares']({shared_with: shared_with}); var html = Handlebars.templates['shares']({sharedWith: shared_with});
$("#modal-note-div .note-shares").replaceWith(html); $("#modal-note-div .note-shares").replaceWith(html);
} }
}, },
@@ -878,7 +878,7 @@ View.prototype = {
}; };
}); });
} else { } else {
var html = Handlebars.templates['attachts']({ attachts: attachts, can_delete: can_delete}); var html = Handlebars.templates['attachts']({ attachments: attachts, can_delete: can_delete});
$("#modal-note-div .note-attachts").replaceWith(html); $("#modal-note-div .note-attachts").replaceWith(html);
lozad('.attach-preview').observe(); lozad('.attach-preview').observe();

View File

@@ -1,5 +1,5 @@
<div class='note-attachts'> <div class='note-attachts'>
{{#each attachts}} {{#each attachments}}
<div class='note-attach-grid'> <div class='note-attach-grid'>
<a target="_blank" href="{{redirect_url}}"> <a target="_blank" href="{{redirect_url}}">
<div class="attach-preview note-attach" attach-file-id="{{file_id}}" data-background-image="{{preview_url}}"/> <div class="attach-preview note-attach" attach-file-id="{{file_id}}" data-background-image="{{preview_url}}"/>

View File

@@ -1,8 +1,8 @@
<div class="note-grid-item"> <div class="note-grid-item">
<div class="quicknote noselect {{#if is_shared}}shared{{/if}} {{#if shared_with.length}}shareowner{{/if}}" style="background-color: {{color}}" data-id="{{ id }}" data-timestamp="{{ timestamp }}" > <div class="quicknote noselect {{#if sharedBy.length}}shared{{/if}} {{#if sharedWith.length}}shareowner{{/if}}" style="background-color: {{color}}" data-id="{{ id }}" data-timestamp="{{ timestamp }}" >
<div class='note-header'> <div class='note-header'>
<div class='note-attachts'> <div class='note-attachts'>
{{#each attachts}} {{#each attachments}}
<div class='note-attach-grid'> <div class='note-attach-grid'>
<div class="attach-preview note-attach" attach-file-id="{{file_id}}" data-background-image="{{preview_url}}"/> <div class="attach-preview note-attach" attach-file-id="{{file_id}}" data-background-image="{{preview_url}}"/>
</div> </div>
@@ -11,7 +11,7 @@
</div> </div>
<div class='note-body'> <div class='note-body'>
<div> <div>
{{#if ispinned}} {{#if isPinned}}
<div class="icon-header-note icon-pinned fixed-header-icon" title="{{t "quicknotes" "Unpin note"}}"></div> <div class="icon-header-note icon-pinned fixed-header-icon" title="{{t "quicknotes" "Unpin note"}}"></div>
{{else}} {{else}}
<div class="icon-header-note icon-pin hide-header-icon" title="{{t "quicknotes" "Pin note"}}"></div> <div class="icon-header-note icon-pin hide-header-icon" title="{{t "quicknotes" "Pin note"}}"></div>
@@ -25,7 +25,7 @@
{{{ content }}} {{{ content }}}
</div> </div>
<div class='note-shares'> <div class='note-shares'>
{{#each shared_with}} {{#each sharedWith}}
<div class="icon-user slim-share" share-id="{{ shared_user }}" title="Shared with {{ shared_user }}">{{{ shared_user }}}</div> <div class="icon-user slim-share" share-id="{{ shared_user }}" title="Shared with {{ shared_user }}">{{{ shared_user }}}</div>
{{/each}} {{/each}}
</div> </div>

View File

@@ -2,10 +2,10 @@
<div id="notes-grid-div" class="notes-grid"> <div id="notes-grid-div" class="notes-grid">
{{#each notes}} {{#each notes}}
<div class="note-grid-item"> <div class="note-grid-item">
<div class="quicknote noselect {{#if is_shared}}shared{{/if}} {{#if shared_with.length}}shareowner{{/if}}" style="background-color: {{color}}" data-id="{{ id }}" data-timestamp="{{ timestamp }}" > <div class="quicknote noselect {{#if sharedBy.length}}shared{{/if}} {{#if sharedWith.length}}shareowner{{/if}}" style="background-color: {{color}}" data-id="{{ id }}" data-timestamp="{{ timestamp }}" >
<div class='note-header'> <div class='note-header'>
<div class='note-attachts'> <div class='note-attachts'>
{{#each attachts}} {{#each attachments}}
<div class='note-attach-grid'> <div class='note-attach-grid'>
<div class="attach-preview note-attach" attach-file-id="{{file_id}}" data-background-image="{{preview_url}}"/> <div class="attach-preview note-attach" attach-file-id="{{file_id}}" data-background-image="{{preview_url}}"/>
</div> </div>
@@ -14,11 +14,11 @@
</div> </div>
<div class='note-body'> <div class='note-body'>
<div> <div>
{{#if is_shared}} {{#if sharedBy}}
<div class="icon-header-note icon-share" title="{{tSB userid }}"></div> <div class="icon-header-note icon-share" title="{{tSB sharedBy.user_id }}"></div>
<div class="icon-header-note icon-delete hide-header-icon icon-delete-note" title="{{t "quicknotes" "Delete note"}}"></div> <div class="icon-header-note icon-delete hide-header-icon icon-delete-note" title="{{t "quicknotes" "Delete shared note"}}"></div>
{{else}} {{else}}
{{#if ispinned}} {{#if isPinned}}
<div class="icon-header-note icon-pinned fixed-header-icon" title="{{t "quicknotes" "Unpin note"}}"></div> <div class="icon-header-note icon-pinned fixed-header-icon" title="{{t "quicknotes" "Unpin note"}}"></div>
{{else}} {{else}}
<div class="icon-header-note icon-pin hide-header-icon" title="{{t "quicknotes" "Pin note"}}"></div> <div class="icon-header-note icon-pin hide-header-icon" title="{{t "quicknotes" "Pin note"}}"></div>
@@ -33,7 +33,7 @@
{{{ content }}} {{{ content }}}
</div> </div>
<div class='note-shares'> <div class='note-shares'>
{{#each shared_with}} {{#each sharedWith}}
<div class="icon-user slim-share" share-id="{{ shared_user }}" title="{{tSW shared_user}}">{{{ shared_user }}}</div> <div class="icon-user slim-share" share-id="{{ shared_user }}" title="{{tSW shared_user}}">{{{ shared_user }}}</div>
{{/each}} {{/each}}
</div> </div>

View File

@@ -1,5 +1,5 @@
<div class='note-shares'> <div class='note-shares'>
{{#each shared_with}} {{#each sharedWith}}
<div class="icon-user slim-share" share-id="{{ shared_user }}" title="{{tSW shared_user}}">{{{ shared_user }}}</div> <div class="icon-user slim-share" share-id="{{ shared_user }}" title="{{tSW shared_user}}">{{{ shared_user }}}</div>
{{/each}} {{/each}}
</div> </div>

View File

@@ -32,14 +32,18 @@ use OCP\IServerContainer;
class Application extends App { class Application extends App {
/** @var string */ /** @var string */
public const APP_NAME = 'quicknotes'; public const APP_ID = 'quicknotes';
/** @var string */
public const API_VERSION = '1.0';
public function __construct(array $urlParams = []) { public function __construct(array $urlParams = []) {
parent::__construct(self::APP_NAME, $urlParams); parent::__construct(self::APP_ID, $urlParams);
} }
public function register(): void { public function register(): void {
$this->registerNavigationEntry(); $this->registerNavigationEntry();
$this->registerCapabilities();
} }
private function registerNavigationEntry(): void { private function registerNavigationEntry(): void {
@@ -59,4 +63,9 @@ class Application extends App {
}); });
} }
private function registerCapabilities(): void {
$container = $this->getContainer();
$container->registerCapability(Capabilities::class);
}
} }

View File

@@ -0,0 +1,47 @@
<?php declare(strict_types=1);
/*
* @copyright 2016-2020 Matias De lellis <mati86dl@gmail.com>
*
* @author 2016 Matias De lellis <mati86dl@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\QuickNotes\AppInfo;
use OCP\Capabilities\ICapability;
use OCP\App\IAppManager;
class Capabilities implements ICapability {
/** @var IAppManager */
private $appManager;
public function __construct(IAppManager $appManager) {
$this->appManager = $appManager;
}
public function getCapabilities() {
return [
Application::APP_ID => [
'version' => $this->appManager->getAppVersion(Application::APP_ID),
'api_version' => Application::API_VERSION,
],
];
}
}

View File

@@ -37,7 +37,7 @@ class NoteApiController extends ApiController {
private $userId; private $userId;
public function __construct($AppName, public function __construct($AppName,
IRequest $request, IRequest $request,
NoteService $noteService, NoteService $noteService,
$userId) $userId)
{ {
@@ -74,7 +74,7 @@ class NoteApiController extends ApiController {
* *
* @param int $id * @param int $id
*/ */
public function show($id): JSONResponse { public function show(int $id): JSONResponse {
$note = $this->noteService->get($this->userId, $id); $note = $this->noteService->get($this->userId, $id);
if (is_null($note)) { if (is_null($note)) {
return new JSONResponse([], Http::STATUS_NOT_FOUND); return new JSONResponse([], Http::STATUS_NOT_FOUND);
@@ -96,9 +96,27 @@ class NoteApiController extends ApiController {
* @param string $title * @param string $title
* @param string $content * @param string $content
* @param string $color * @param string $color
* @param bool $isPinned
* @param array $sharedWith
* @param array $tags
* @param array $attachments
*/ */
public function create($title, $content, $color = "#F7EB96") { public function create(string $title,
$note = $this->noteService->create($this->userId, $title, $content, $color); 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)); $etag = md5(json_encode($note));
@@ -116,13 +134,31 @@ class NoteApiController extends ApiController {
* @param int $id * @param int $id
* @param string $title * @param string $title
* @param string $content * @param string $content
* @param array $attachts
* @param bool $pinned
* @param array $tags
* @param string $color * @param string $color
* @param bool $isPinned
* @param array $tags
* @param array $attachments
* @param array $sharedWith
*/ */
public function update(int $id, string $title, string $content, array $attachts, bool $pinned, array $tags, string $color = "#F7EB96"): JSONResponse { public function update(int $id,
$note = $this->noteService->update($this->userId, $id, $title, $content, $attachts, $pinned, $tags, $color); string $title,
string $content,
string $color,
bool $isPinned,
array $tags,
array $attachments,
array $sharedWith): JSONResponse
{
$note = $this->noteService->update($this->userId,
$id,
$title,
$content,
$color,
$isPinned,
$tags,
$attachments,
$sharedWith);
if (is_null($note)) { if (is_null($note)) {
return new JSONResponse([], Http::STATUS_NOT_FOUND); return new JSONResponse([], Http::STATUS_NOT_FOUND);
} }

View File

@@ -37,7 +37,7 @@ class NoteController extends Controller {
private $userId; private $userId;
public function __construct($AppName, public function __construct($AppName,
IRequest $request, IRequest $request,
NoteService $noteService, NoteService $noteService,
$userId) $userId)
{ {
@@ -70,7 +70,7 @@ class NoteController extends Controller {
* *
* @param int $id * @param int $id
*/ */
public function show($id): JSONResponse { public function show(int $id): JSONResponse {
$note = $this->noteService->get($this->userId, $id); $note = $this->noteService->get($this->userId, $id);
if (is_null($note)) { if (is_null($note)) {
return new JSONResponse([], Http::STATUS_NOT_FOUND); return new JSONResponse([], Http::STATUS_NOT_FOUND);
@@ -90,9 +90,27 @@ class NoteController extends Controller {
* @param string $title * @param string $title
* @param string $content * @param string $content
* @param string $color * @param string $color
* @param bool $isPinned
* @param array $sharedWith
* @param array $tags
* @param array $attachments
*/ */
public function create($title, $content, $color = NULL) { public function create(string $title,
$note = $this->noteService->create($this->userId, $title, $content, $color); 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)); $etag = md5(json_encode($note));
@@ -108,14 +126,31 @@ class NoteController extends Controller {
* @param int $id * @param int $id
* @param string $title * @param string $title
* @param string $content * @param string $content
* @param array $attachts
* @param bool $pinned
* @param array $tags
* @param array $shared_with
* @param string $color * @param string $color
* @param bool $isPinned
* @param array $tags
* @param array $attachments
* @param array $sharedWith
*/ */
public function update(int $id, string $title, string $content, array $attachts, bool $pinned, array $tags, array $shared_with, string $color = "#F7EB96"): JSONResponse { public function update(int $id,
$note = $this->noteService->update($this->userId, $id, $title, $content, $attachts, $pinned, $tags, $shared_with, $color); string $title,
string $content,
string $color,
bool $isPinned,
array $tags,
array $attachments,
array $sharedWith): JSONResponse
{
$note = $this->noteService->update($this->userId,
$id,
$title,
$content,
$color,
$isPinned,
$tags,
$attachments,
$sharedWith);
if (is_null($note)) { if (is_null($note)) {
return new JSONResponse([], Http::STATUS_NOT_FOUND); return new JSONResponse([], Http::STATUS_NOT_FOUND);
} }
@@ -137,4 +172,5 @@ class NoteController extends Controller {
$this->noteService->destroy($this->userId, $id); $this->noteService->destroy($this->userId, $id);
return new JSONResponse([]); return new JSONResponse([]);
} }
} }

View File

@@ -15,7 +15,6 @@ class Note extends Entity implements JsonSerializable {
protected $userId; protected $userId;
protected $sharedWith = []; protected $sharedWith = [];
protected $sharedBy = []; protected $sharedBy = [];
protected $isShared;
protected $tags; protected $tags;
protected $attachts; protected $attachts;
@@ -32,20 +31,16 @@ class Note extends Entity implements JsonSerializable {
public function jsonSerialize() { public function jsonSerialize() {
return [ return [
'id' => $this->id, 'id' => $this->id,
'title' => $this->title, 'title' => $this->title,
'content' => $this->content, 'content' => $this->content,
'pinned' => $this->pinned, 'isPinned' => $this->isPinned,
'ispinned' => $this->isPinned, 'timestamp' => $this->timestamp,
'timestamp' => $this->timestamp, 'color' => $this->color,
'colorid' => $this->colorId, 'sharedWith' => $this->sharedWith,
'color' => $this->color, 'sharedBy' => $this->sharedBy,
'userid' => $this->userId, 'tags' => $this->tags,
'shared_with' => $this->sharedWith, 'attachments' => $this->attachts
'shared_by' => $this->sharedBy,
'is_shared' => $this->isShared,
'tags' => $this->tags,
'attachts' => $this->attachts
]; ];
} }
} }

View File

@@ -81,7 +81,6 @@ class NoteService {
// Set shares with others. // Set shares with others.
foreach($notes as $note) { foreach($notes as $note) {
$note->setIsShared(false);
$note->setSharedWith($this->noteShareMapper->getSharesForNote($note->getId())); $note->setSharedWith($this->noteShareMapper->getSharesForNote($note->getId()));
} }
@@ -90,8 +89,6 @@ class NoteService {
$sharedEntries = $this->noteShareMapper->findForUser($userId); $sharedEntries = $this->noteShareMapper->findForUser($userId);
foreach($sharedEntries as $sharedEntry) { foreach($sharedEntries as $sharedEntry) {
$sharedNote = $this->notemapper->findShared($sharedEntry->getNoteId()); $sharedNote = $this->notemapper->findShared($sharedEntry->getNoteId());
$sharedNote->setIsShared(true);
$sharedEntry->setUserId($sharedNote->getUserId()); $sharedEntry->setUserId($sharedNote->getUserId());
$sharedNote->setSharedBy([$sharedEntry]); $sharedNote->setSharedBy([$sharedEntry]);
$shares[] = $sharedNote; $shares[] = $sharedNote;
@@ -155,9 +152,21 @@ class NoteService {
* @param string $userId * @param string $userId
* @param string $title * @param string $title
* @param string $content * @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)) { if (is_null($color)) {
$color = $this->settingsService->getColorForNewNotes(); $color = $this->settingsService->getColorForNewNotes();
} }
@@ -171,20 +180,24 @@ class NoteService {
$hcolor = $this->colormapper->insert($hcolor); $hcolor = $this->colormapper->insert($hcolor);
} }
// Create note and insert it // Create note and insert it
$note = new Note(); $note = new Note();
$note->setTitle($title); $note->setTitle($title);
$note->setContent($content); $note->setContent($content);
$note->setPinned($isPinned ? 1 : 0);
$note->setTimestamp(time()); $note->setTimestamp(time());
$note->setColorId($hcolor->id); $note->setColorId($hcolor->id);
$note->setUserId($userId); $note->setUserId($userId);
$newNote = $this->notemapper->insert($note); $newNote = $this->notemapper->insert($note);
// TODO: Insert optional shares, tags and attachments.
// Insert true color pin and tags to response // Insert true color pin and tags to response
$newNote->setColor($hcolor->getColor()); $newNote->setColor($hcolor->getColor());
$newNote->setIsPinned(false); $newNote->setIsPinned($isPinned);
$newNote->setTags([]); $newNote->setTags([]);
$newNote->setAttachts([]); $newNote->setAttachts([]);
@@ -193,24 +206,24 @@ class NoteService {
/** /**
* @param string userId * @param string userId
* @param int $id * @param int $id
* @param string $title * @param string $title
* @param string $content * @param string $content
* @param array $attachts
* @param bool $pinned
* @param array $tags
* @param array $shares
* @param string $color * @param string $color
* @param bool $isPinned
* @param array $tags
* @param array $attachments
* @param array $sharedWith
*/ */
public function update(string $userId, public function update(string $userId,
int $id, int $id,
string $title, string $title,
string $content, string $content,
array $attachts, string $color,
bool $pinned, bool $isPinned,
array $tags, array $tags,
array $shares, array $attachments,
string $color): ?Note array $sharedWith): ?Note
{ {
// Get current Note and Color. // Get current Note and Color.
$note = $this->get($userId, $id); $note = $this->get($userId, $id);
@@ -244,7 +257,7 @@ class NoteService {
} }
// Add new attachts // Add new attachts
foreach ($attachts as $attach) { foreach ($attachments as $attach) {
if (!$this->attachMapper->fileAttachExists($userId, $id, $attach['file_id'])) { if (!$this->attachMapper->fileAttachExists($userId, $id, $attach['file_id'])) {
$hAttach = new Attach(); $hAttach = new Attach();
$hAttach->setUserId($userId); $hAttach->setUserId($userId);
@@ -259,7 +272,7 @@ class NoteService {
$dbShares = $this->noteShareMapper->getSharesForNote($id); $dbShares = $this->noteShareMapper->getSharesForNote($id);
foreach ($dbShares as $dbShare) { foreach ($dbShares as $dbShare) {
$delete = true; $delete = true;
foreach ($shares as $share) { foreach ($sharedWith as $share) {
if ($dbShare->getSharedUser() === $share['shared_user']) { if ($dbShare->getSharedUser() === $share['shared_user']) {
$delete = false; $delete = false;
break; break;
@@ -271,7 +284,7 @@ class NoteService {
} }
// Add new shares // Add new shares
foreach ($shares as $share) { foreach ($sharedWith as $share) {
if (!$this->noteShareMapper->existsByNoteAndUser($id, $share['shared_user'])) { if (!$this->noteShareMapper->existsByNoteAndUser($id, $share['shared_user'])) {
$hShare = new NoteShare(); $hShare = new NoteShare();
$hShare->setNoteId($id); $hShare->setNoteId($id);
@@ -320,7 +333,7 @@ class NoteService {
// Set new info on Note // Set new info on Note
$note->setTitle($title); $note->setTitle($title);
$note->setContent($content); $note->setContent($content);
$note->setPinned($pinned ? 1 : 0); $note->setPinned($isPinned ? 1 : 0);
$note->setTimestamp(time()); $note->setTimestamp(time());
$note->setColorId($hcolor->id); $note->setColorId($hcolor->id);
@@ -329,7 +342,7 @@ class NoteService {
// Insert true color and pin to response // Insert true color and pin to response
$newnote->setColor($hcolor->getColor()); $newnote->setColor($hcolor->getColor());
$newnote->setIsPinned($note->getPinned() ? true : false); $newnote->setIsPinned($isPinned);
// Fill new tags // Fill new tags
$newnote->setTags($this->tagmapper->getTagsForNote($userId, $newnote->getId())); $newnote->setTags($this->tagmapper->getTagsForNote($userId, $newnote->getId()));
@@ -343,7 +356,6 @@ class NoteService {
$newnote->setAttachts($attachts); $newnote->setAttachts($attachts);
// Fill shared with with others // Fill shared with with others
$newnote->setIsShared(false);
$newnote->setSharedWith($this->noteShareMapper->getSharesForNote($newnote->getId())); $newnote->setSharedWith($this->noteShareMapper->getSharesForNote($newnote->getId()));
// Remove old color if necessary // Remove old color if necessary
@@ -363,7 +375,7 @@ class NoteService {
* @param string $userId * @param string $userId
* @param int $id * @param int $id
*/ */
public function destroy($userId, $id) { public function destroy (string $userId, int $id) {
// Get Note and Color // Get Note and Color
try { try {
$note = $this->notemapper->find($id, $userId); $note = $this->notemapper->find($id, $userId);

View File

@@ -55,11 +55,11 @@ class SettingsService {
public function getColorForNewNotes(): string { public function getColorForNewNotes(): string {
return $this->config->getUserValue($this->userId, Application::APP_NAME, self::COLOR_FOR_NEW_NOTES_KEY, self::DEFAULT_COLOR_FOR_NEW_NOTES); return $this->config->getUserValue($this->userId, Application::APP_ID, self::COLOR_FOR_NEW_NOTES_KEY, self::DEFAULT_COLOR_FOR_NEW_NOTES);
} }
public function setColorForNewNotes(string $color) { public function setColorForNewNotes(string $color) {
$this->config->setUserValue($this->userId, Application::APP_NAME, self::COLOR_FOR_NEW_NOTES_KEY, $color); $this->config->setUserValue($this->userId, Application::APP_ID, self::COLOR_FOR_NEW_NOTES_KEY, $color);
} }
} }