diff options
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/note.php | 7 | ||||
| -rw-r--r-- | routes/pages.php | 7 |
2 files changed, 4 insertions, 10 deletions
diff --git a/routes/note.php b/routes/note.php index 6dd0025..1967a2d 100644 --- a/routes/note.php +++ b/routes/note.php @@ -40,11 +40,8 @@ Router::getInstance()->mount('/@/:handle/note/:id', function (array $args) { throw new NotFound("i don't know that note"); } // check the current user is allowed to see it - if ($note->privacy->scope != NotePrivacyScope::PUBLIC ) { - $user = UserAccount::requireByCurrentSession(); - if (!in_array($user->actor, $note->getRelevantActors())) { - throw new Forbidden(); - } + if (!$note->isViewableBy(UserAccount::findByCurrentSession())) { + throw new Forbidden(); } // change the handle in the url if it's wrong if ($args['handle'] != $note->author->getFullHandle()) { diff --git a/routes/pages.php b/routes/pages.php index 418436f..f57d10d 100644 --- a/routes/pages.php +++ b/routes/pages.php @@ -58,11 +58,8 @@ Router::getInstance()->mount('/@/:handle/page/:id', function (array $args) { throw new NotFound("i don't know that note"); } // check the current user is allowed to see it - if ($note->privacy->scope != NotePrivacyScope::PUBLIC ) { - $user = UserAccount::requireByCurrentSession(); - if (!in_array($user->actor, $note->getRelevantActors())) { - throw new Forbidden(); - } + if (!$note->isViewableBy(UserAccount::findByCurrentSession())) { + throw new Forbidden(); } // go back to the note if it's not a page if (!$note->hasPage()) { |
