- {% include '/cards/note/view.html.twig' with {'note': note} only %}
- {{ form(reply) }}
+ {{ noteView.macro_note_minimal(note) }}
+ {{ form(add_reply) }}
{% endblock body %}
diff --git a/plugins/TreeNotes/TreeNotes.php b/plugins/TreeNotes/TreeNotes.php
index 354b3fa106..e63182bb3c 100644
--- a/plugins/TreeNotes/TreeNotes.php
+++ b/plugins/TreeNotes/TreeNotes.php
@@ -23,6 +23,7 @@ namespace Plugin\TreeNotes;
use App\Core\Modules\Plugin;
use App\Entity\Note;
+use Plugin\Reply\Entity\NoteReply;
class TreeNotes extends Plugin
{
@@ -31,7 +32,7 @@ class TreeNotes extends Plugin
*/
public function onFormatNoteList(array $notes_in, ?array &$notes_out)
{
- $roots = array_filter($notes_in, fn (Note $note) => $note->getReplyTo() == null);
+ $roots = array_filter($notes_in, fn (Note $note) => NoteReply::getReplyToNote($note) == null);
$notes_out = $this->build_tree($roots, $notes_in);
}
@@ -46,7 +47,7 @@ class TreeNotes extends Plugin
private function build_subtree(Note $parent, array $notes)
{
- $children = array_filter($notes, fn (Note $n) => $parent->getId() == $n->getReplyTo());
+ $children = array_filter($notes, fn (Note $note) => $parent->getId() == NoteReply::getReplyToNote($note));
return ['note' => $parent, 'replies' => $this->build_tree($children, $notes)];
}
}
diff --git a/src/Entity/Note.php b/src/Entity/Note.php
index f54d2f57c5..0745f9d7af 100644
--- a/src/Entity/Note.php
+++ b/src/Entity/Note.php
@@ -49,11 +49,9 @@ class Note extends Entity
private ?string $content_type = null;
private ?string $content = null;
private ?string $rendered = null;
- private ?int $reply_to;
private ?bool $is_local;
private ?string $source;
private ?int $conversation;
- private ?int $repeat_of;
private int $scope = VisibilityScope::PUBLIC;
private string $url;
private string $language;
@@ -118,17 +116,6 @@ class Note extends Entity
return $this->rendered;
}
- public function setReplyTo(?int $reply_to): self
- {
- $this->reply_to = $reply_to;
- return $this;
- }
-
- public function getReplyTo(): ?int
- {
- return $this->reply_to;
- }
-
public function setIsLocal(?bool $is_local): self
{
$this->is_local = $is_local;
@@ -162,17 +149,6 @@ class Note extends Entity
return $this->conversation;
}
- /* public function setRepeatOf(?int $repeat_of): self
- {
- $this->repeat_of = $repeat_of;
- return $this;
- }
-
- public function getRepeatOf(): ?int
- {
- return $this->repeat_of;
- }*/
-
public function setScope(int $scope): self
{
$this->scope = $scope;
@@ -291,27 +267,6 @@ class Note extends Entity
});
}
- public function getReplies(): array
- {
- return Cache::getList('note-replies-' . $this->id, fn () => DB::dql('select n from note n where n.reply_to = :id', ['id' => $this->id]));
- }
-
- public function getReplyToNickname(): ?string
- {
- if (!empty($this->reply_to)) {
- return Cache::get('note-reply-to-' . $this->id, function () {
- return DB::dql(
- <<<'EOF'
- select g from note n join
- actor g with n.actor_id = g.id where n.reply_to = :reply
- EOF,
- ['reply' => $this->reply_to],
- )[0]->getNickname();
- });
- }
- return null;
- }
-
/**
* Whether this note is visible to the given actor
*/
@@ -321,18 +276,18 @@ class Note extends Entity
$scope = VisibilityScope::create($this->scope);
return $scope->public
|| (!\is_null($a) && (
- ($scope->subscriber && 0 != DB::count('subscription', ['subscriber' => $a->getId(), 'subscribed' => $this->actor_id]))
- || ($scope->addressee && 0 != DB::count('notification', ['activity_id' => $this->id, 'actor_id' => $a->getId()]))
- || ($scope->group && [] != DB::dql(
- <<<'EOF'
+ ($scope->subscriber && 0 != DB::count('subscription', ['subscriber' => $a->getId(), 'subscribed' => $this->actor_id]))
+ || ($scope->addressee && 0 != DB::count('notification', ['activity_id' => $this->id, 'actor_id' => $a->getId()]))
+ || ($scope->group && [] != DB::dql(
+ <<<'EOF'
select m from group_member m
join group_inbox i with m.group_id = i.group_id
join note n with i.activity_id = n.id
where n.id = :note_id and m.actor_id = :actor_id
EOF,
- ['note_id' => $this->id, 'actor_id' => $a->getId()],
- ))
- ));
+ ['note_id' => $this->id, 'actor_id' => $a->getId()],
+ ))
+ ));
}
/**
@@ -354,11 +309,9 @@ class Note extends Entity
'content' => ['type' => 'text', 'description' => 'note content'],
'content_type' => ['type' => 'varchar', 'not null' => true, 'default' => 'text/plain', 'length' => 129, 'description' => 'A note can be written in a multitude of formats such as text/plain, text/markdown, application/x-latex, and text/html'],
'rendered' => ['type' => 'text', 'description' => 'rendered note content, so we can keep the microtags (if not local)'],
- 'reply_to' => ['type' => 'int', 'foreign key' => true, 'target' => 'Note.id', 'multiplicity' => 'one to one', 'description' => 'note replied to, null if root of a conversation'],
'is_local' => ['type' => 'bool', 'description' => 'was this note generated by a local actor'],
'source' => ['type' => 'varchar', 'foreign key' => true, 'length' => 32, 'target' => 'NoteSource.code', 'multiplicity' => 'many to one', 'description' => 'fkey to source of note, like "web", "im", or "clientname"'],
'conversation' => ['type' => 'int', 'foreign key' => true, 'target' => 'Conversation.id', 'multiplicity' => 'one to one', 'description' => 'the local conversation id'],
- // 'repeat_of' => ['type' => 'int', 'foreign key' => true, 'target' => 'Note.id', 'multiplicity' => 'one to one', 'description' => 'note this is a repeat of'],
'scope' => ['type' => 'int', 'not null' => true, 'default' => VisibilityScope::PUBLIC, 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = groups; 8 = subscribers; 16 = messages; null = default'],
'url' => ['type' => 'text', 'description' => 'Permalink to Note'],
'language' => ['type' => 'int', 'foreign key' => true, 'target' => 'Language.id', 'multiplicity' => 'one to many', 'description' => 'The language for this note'],
@@ -370,7 +323,6 @@ class Note extends Entity
'note_created_id_is_local_idx' => ['created', 'is_local'],
'note_actor_created_idx' => ['actor_id', 'created'],
'note_is_local_created_actor_idx' => ['is_local', 'created', 'actor_id'],
- // 'note_repeat_of_created_idx' => ['repeat_of', 'created'],
'note_conversation_created_idx' => ['conversation', 'created'],
'note_reply_to_idx' => ['reply_to'],
],
diff --git a/src/Twig/Runtime.php b/src/Twig/Runtime.php
index 336877e539..de8ad7eab7 100644
--- a/src/Twig/Runtime.php
+++ b/src/Twig/Runtime.php
@@ -134,15 +134,6 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
return $result;
}
- public function getAdditionalTemplateVars(array $vars): array
- {
- $result = [];
- if (Event::handle('GetAdditionalTemplateVars', [$vars, &$result]) !== Event::stop) {
- return [];
- }
- return $result;
- }
-
// ----------------------------------------------------------
/**
diff --git a/templates/cards/note/view.html.twig b/templates/cards/note/view.html.twig
index 75a2aedd35..7a6ae1624f 100644
--- a/templates/cards/note/view.html.twig
+++ b/templates/cards/note/view.html.twig
@@ -79,21 +79,29 @@
{% macro macro_note(note, replies) %}
{% set nickname = note.getActorNickname() %}
{% set fullname = note.getActorFullname() %}
- {% set actor_url = note.getActor().getUrl() %}
+ {% set actor = note.getActor() %}
+ {% set actor_url = actor.getUrl() %}
{{ block('note_sidebar') }}
{{ block('note_author') }}
- {{ block('note_reply_to') }}
{{ block('note_actions') }}
+
{{ block('note_text') }}
{{ block('note_attachments') }}
{{ block('note_links') }}
+
+ {% for block in handle_event('AppendCardNote', {'note': note, 'actor': actor}) %}
+
+ {% endfor %}
+
{{ block('note_replies') }}
diff --git a/templates/network/feed.html.twig b/templates/network/feed.html.twig
index 2973d06151..5431248884 100644
--- a/templates/network/feed.html.twig
+++ b/templates/network/feed.html.twig
@@ -1,7 +1,5 @@
{% extends 'stdgrid.html.twig' %}
-
-{% set override_import = handle_override_template_import('/network/feed.html.twig', '/cards/note/view.html.twig') %}
-{% import override_import as noteView %}
+{% import '/cards/note/view.html.twig' as noteView %}
{% block title %}{% if page_title is defined %}{{ page_title | trans }}{% endif %}{% endblock %}