diff --git a/controller/notecontroller.php b/controller/notecontroller.php index 9536de0..3d2191b 100644 --- a/controller/notecontroller.php +++ b/controller/notecontroller.php @@ -60,10 +60,15 @@ class NoteController extends Controller { $shareEntries = $this->notesharemapper->findForUser($this->userId); $shares = array(); foreach($shareEntries as $entry) { - $share = $this->notemapper->findById($entry->getNoteId()); - $share->setIsShared(true); - $shares[] = $share; - + try { + //find is only to check if current user is owner + $this->notemapper->find($entry->getNoteId(), $this->userId); + //user is owner, nothing to do + } catch(\OCP\AppFramework\Db\DoesNotExistException $e) { + $share = $this->notemapper->findById($entry->getNoteId()); + $share->setIsShared(true); + $shares[] = $share; + } } $notes = array_merge($notes, $shares); // Insert true color to response diff --git a/db/notemapper.php b/db/notemapper.php index b5eb702..50ce0c0 100644 --- a/db/notemapper.php +++ b/db/notemapper.php @@ -11,6 +11,13 @@ class NoteMapper extends Mapper { parent::__construct($db, 'quicknotes_notes', '\OCA\QuickNotes\Db\Note'); } + /** + * @param int $id + * @param string $userId + * @throws \OCP\AppFramework\Db\DoesNotExistException if not found + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result + * @return Note + */ public function find($id, $userId) { $sql = 'SELECT * FROM *PREFIX*quicknotes_notes WHERE id = ? AND user_id = ?'; return $this->findEntity($sql, [$id, $userId]);