From e7dcea3f26698ce83ffb6751d9a04c2b5a1eaa03 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Tue, 21 Dec 2021 12:47:16 +0000 Subject: [PATCH] [CONTROLLER][Actor] Add group notes query and fixup template --- src/Controller/Actor.php | 11 +++++++++++ templates/actor/group_view.html.twig | 10 +++++++--- templates/actor/view.html.twig | 8 ++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/Controller/Actor.php b/src/Controller/Actor.php index 9051e05523..790e8e1779 100644 --- a/src/Controller/Actor.php +++ b/src/Controller/Actor.php @@ -128,10 +128,21 @@ class Actor extends ActorController } } + $notes = DB::dql( + <<<'EOF' + select n from note n + join activity a with n.id = a.object_id + join group_inbox gi with a.id = gi.activity_id + where a.object_type = 'note' and gi.group_id = :group_id + EOF, + ['group_id' => $group->getId()], + ); + return [ '_template' => 'actor/group_view.html.twig', 'actor' => $group, 'nickname' => $group->getNickname(), + 'notes' => $notes, ]; } } diff --git a/templates/actor/group_view.html.twig b/templates/actor/group_view.html.twig index fc41bb84df..193d2fbc8b 100644 --- a/templates/actor/group_view.html.twig +++ b/templates/actor/group_view.html.twig @@ -1,7 +1,7 @@ {% extends 'stdgrid.html.twig' %} {% import '/cards/note/view.html.twig' as noteView %} -{% set nickname = nickname|escape %} + {% block title %}{{ nickname }}{% endblock %} @@ -20,9 +20,13 @@
{% if notes is defined and notes is not empty %} - {% for note in notes %} + {% for conversation in notes %} {% block current_note %} - {{ noteView.macro_note(note, null) }} + {% if conversation is instanceof('array') %} + {{ noteView.macro_note(conversation['note'], conversation['replies']) }} + {% else %} + {{ noteView.macro_note(conversation) }} + {% endif %}
{% endblock current_note %} {% endfor %} diff --git a/templates/actor/view.html.twig b/templates/actor/view.html.twig index bd10975741..6428d0f0b5 100644 --- a/templates/actor/view.html.twig +++ b/templates/actor/view.html.twig @@ -18,9 +18,13 @@
{% if notes is defined and notes is not empty %} - {% for note in notes %} + {% for conversation in notes %} {% block current_note %} - {{ noteView.macro_note(note, null) }} + {% if conversation is instanceof('array') %} + {{ noteView.macro_note(conversation['note'], conversation['replies']) }} + {% else %} + {{ noteView.macro_note(conversation) }} + {% endif %}
{% endblock current_note %} {% endfor %}