forked from GNUsocial/gnu-social
[COMPONENT] Favourite initial implementation
This commit is contained in:
parent
fee81f8499
commit
e1e3e2d9b3
@ -68,6 +68,37 @@ class Post
|
||||
];
|
||||
}
|
||||
|
||||
public function favourite(Request $request, string $fav_to)
|
||||
{
|
||||
$note = DB::find('note', ['id' => $fav_to]);
|
||||
if ($note == null) {
|
||||
throw new ClientException(_m('No such note'));
|
||||
}
|
||||
|
||||
$actor_id = Common::ensureLoggedIn()->getActor()->getId();
|
||||
|
||||
$form = Form::create([
|
||||
['favourite', SubmitType::class, []],
|
||||
]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted()) {
|
||||
$data = $form->getData();
|
||||
if ($form->isValid()) {
|
||||
self::storeNote($actor_id, $data['content'], $data['attachments'], $is_local = true, $data['reply_to']);
|
||||
} else {
|
||||
// TODO display errors
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'_template' => 'note/reply.html.twig',
|
||||
'note' => $note,
|
||||
'fav' => $form->createView(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function storeNote(int $actor_id, string $content, array $attachments, bool $is_local, ?int $reply_to = null)
|
||||
{
|
||||
$note = Note::create(['gsactor_id' => $actor_id, 'content' => $content, 'is_local' => $is_local, 'reply_to' => $reply_to]);
|
||||
|
@ -10,8 +10,17 @@
|
||||
media="screen and (max-width: 750px)">
|
||||
{% endblock %}
|
||||
|
||||
{% block header %}
|
||||
{{ parent() }}
|
||||
{% endblock %}
|
||||
|
||||
{% block left %}
|
||||
{{ parent() }}
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="content" style="margin-top: 5em">
|
||||
{{ parent() }}
|
||||
<div class="content">
|
||||
<div class="main">
|
||||
{% include '/note/view.html.twig' with {'note': note} only %}
|
||||
{{ form(reply) }}
|
||||
|
@ -19,6 +19,16 @@
|
||||
<use xlink:href="#icon-reply"></use>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="{{ path('note_reply', {'reply_to': note.getId()}) }}">
|
||||
<svg class="icon icon-recycle">
|
||||
<use xlink:href="#icon-recycle"></use>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="{{ path('note_reply', {'reply_to': note.getId()}) }}">
|
||||
<svg class="icon icon-heart">
|
||||
<use xlink:href="#icon-heart"></use>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
<div class="replies">
|
||||
{% for reply in note.getReplies() %}
|
||||
|
Loading…
Reference in New Issue
Block a user