aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorwinter2025-01-17 17:16:53 +0000
committerwinter2025-01-17 17:16:53 +0000
commit3bd6cf6cd2eda9aa95c734df58af11bbae57ce04 (patch)
tree2416a76d5e441196d54df638b84b0be557e03d75
parentdb52d0961e695a22ad7bbbfbb6e92187d466f8b6 (diff)
don't leak private notes on actor profile page
-rw-r--r--Digitigrade/Model/Note.php10
-rw-r--r--templates/actor_profile_page.php6
2 files changed, 15 insertions, 1 deletions
diff --git a/Digitigrade/Model/Note.php b/Digitigrade/Model/Note.php
index 64a2168..f6f492d 100644
--- a/Digitigrade/Model/Note.php
+++ b/Digitigrade/Model/Note.php
@@ -164,6 +164,16 @@ class Note extends PushableModel implements TimelineIncludeable {
return array_unique(array_filter($instances, fn(?Instance $i) => $i != null));
}
+ public function isViewableBy(?UserAccount $viewer): bool {
+ if ($this->privacy->scope == NotePrivacyScope::PUBLIC ) {
+ return true;
+ }
+ if ($viewer == null) {
+ return false;
+ }
+ return in_array($viewer->actor, $this->getRelevantActors());
+ }
+
/**
* Gets this note's formatted content in the given mimetype or null if there isn't one
* @param string $mimetype content type to return
diff --git a/templates/actor_profile_page.php b/templates/actor_profile_page.php
index 649069d..eba9d04 100644
--- a/templates/actor_profile_page.php
+++ b/templates/actor_profile_page.php
@@ -1,12 +1,15 @@
<?php
use Digitigrade\Model\Note;
+use Digitigrade\Model\UserAccount;
call_template('skeleton', [
'pageTitle' => "$actor->displayName - @" . $actor->getFullHandle(),
'renderTitleHeading' => false
], function () {
global $actor;
+ $user = UserAccount::findByCurrentSession();
+
call_template('actor_profile', ['actor' => $actor]);
echo '<hr>';
$notes = Note::findAllWithAuthor($actor, 20);
@@ -14,7 +17,8 @@ call_template('skeleton', [
call_template('placeholder_text', ['message' => __('user.notes.placeholder')]);
} else {
foreach ($notes as $n) {
- call_template('note', ['note' => $n]);
+ if ($n->isViewableBy($user))
+ call_template('note', ['note' => $n]);
}
$countNotShown = Note::countWithAuthor($actor) - count($notes);
if ($countNotShown >= 0) {