diff --git a/src/Controller/Actor.php b/src/Controller/Actor.php index 8cd278e8e9..2bc0c658ff 100644 --- a/src/Controller/Actor.php +++ b/src/Controller/Actor.php @@ -71,6 +71,6 @@ class Actor extends Controller } public function ActorShowNickname(Request $request, string $nickname) { - return $this->ActorByNickname($nickname, fn ($actor) => ['_template' => 'actor/view.html.twig', 'actor' => $actor]); + return $this->ActorByNickname($nickname, fn ($actor) => ['_template' => 'actor/view.html.twig', 'actor' => $actor, 'notes' => \App\Entity\Note::getAllNotesByActor($actor)]); } } diff --git a/src/Entity/Note.php b/src/Entity/Note.php index e26493cd71..62efafb69b 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -217,6 +217,18 @@ class Note extends Entity return Avatar::getAvatarUrl($this->getActorId(), $size); } + public static function getAllNotesByActor(Actor $actor): array + { + return DB::sql( + <<<'EOF' + select {select} from note n + where (n.actor_id & :actor_id) <> 0 + order by n.created DESC + EOF, + ['actor_id' => $actor], + ); + } + public static function getAllNotes(int $note_scope): array { return DB::sql( diff --git a/templates/actor/view.html.twig b/templates/actor/view.html.twig index bb5d32778d..27f5a671d4 100644 --- a/templates/actor/view.html.twig +++ b/templates/actor/view.html.twig @@ -1,20 +1,30 @@ {% extends 'stdgrid.html.twig' %} +{% import '/cards/note/view.html.twig' as noteView %} -{% block title %}{{ actor.getNickname() }}'s profile{% endblock %} +{% block title %}{{ actor.getNickname() ~ '\'s profile' | trans }}{% endblock %} + +{% block stylesheets %} + {{ parent() }} + +{% endblock stylesheets %} {% block body %} -{% block profile_view %}{% include 'cards/profile/view.html.twig' %}{% endblock profile_view %} + {% block profile_view %} + {% include 'cards/profile/view.html.twig' %} + {% endblock profile_view %} -
-
- {% if notes is defined and notes is not empty %} - {% for conversation in notes %} - {% include '/note/view.html.twig' with {'note': conversation['note'], 'have_user': have_user, 'replies': conversation['replies']} only %} -
- {% endfor %} - {% else %} -

{% trans %}No notes here.{% endtrans %}

- {% endif %} -
-
+
+
+ {% if notes is defined and notes is not empty %} + {% for note in notes %} + {% block current_note %} + {{ noteView.macro_note(note, null) }} +
+ {% endblock current_note %} + {% endfor %} + {% else %} +

{% trans %}No notes here.{% endtrans %}

+ {% endif %} +
+
{% endblock body %} diff --git a/templates/cards/profile/view.html.twig b/templates/cards/profile/view.html.twig index 7c2cb3ecf4..8f024f98a8 100644 --- a/templates/cards/profile/view.html.twig +++ b/templates/cards/profile/view.html.twig @@ -40,6 +40,4 @@ {{ block | raw }} {% endfor %} - -
{% endblock profile_view %}