[CONTROLLER][Actor] Handle case where there isn't a logged in user

This commit is contained in:
Hugo Sales 2021-12-21 16:55:48 +00:00 committed by Diogo Peralta Cordeiro
parent 4b98200ecd
commit 67f09d4e50
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 9 additions and 7 deletions

View File

@ -130,7 +130,7 @@ class Actor extends ActorController
}
}
$notes = DB::dql(
$notes = !\is_null($group) ? DB::dql(
<<<'EOF'
select n from note n
join activity a with n.id = a.object_id
@ -138,12 +138,12 @@ class Actor extends ActorController
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(),
'nickname' => $group?->getNickname() ?? $nickname,
'notes' => $notes,
];
}

View File

@ -1,8 +1,7 @@
{% extends 'stdgrid.html.twig' %}
{% import '/cards/note/view.html.twig' as noteView %}
{% set nickname = nickname|escape %}
{% block title %}{{ nickname }}{% endblock %}
{% block stylesheets %}
@ -38,8 +37,11 @@
{% else %}
<div class="section-widget-padded section-widget">
<p>{% trans with { '%group%': nickname } %}The group <em>%group%</em> doesn't exist. Would you like to create it?{% endtrans %}</p>
<p>{% trans with { '%group%': nickname } %}The group <em>%group%</em> doesn't exist.{% endtrans %}</p>
{% if create_form is defined and create_form is not null %}
<p>{% trans %}Would you like to create it?{% endtrans %}</p>
{{ form(create_form) }}
{% endif %}
</div>
{% endif %}
{% endblock body %}