Fix unable to forget shared note... Part of issue #72

This commit is contained in:
Matias De lellis
2022-05-31 14:11:56 -03:00
parent 7d1748d2e5
commit 38860f784f
4 changed files with 28 additions and 22 deletions

View File

@@ -55,15 +55,11 @@ class ShareController extends Controller {
* @param int $noteId
*/
public function destroy(int $noteId): JSONResponse {
try {
$noteShare = $this->noteShareMapper->findByNoteAndUser($noteId, $this->userId);
} catch (DoesNotExistException $e) {
if ($this->noteShareMapper->forgetShareByNoteIdAndSharedUser($noteId, $this->userId)) {
return new JSONResponse([], Http::STATUS_OK);
} else {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
$this->noteShareMapper->delete($noteShare);
return new JSONResponse([]);
}
}