[PLUGINS][Reply] Fix return on getReplyToNote

The array contained an object, the result was within that object and not the object itself.
This commit is contained in:
Eliseu Amaro 2021-11-29 14:50:25 +00:00 committed by Diogo Peralta Cordeiro
parent db33800ade
commit 01078e20fb
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 4 additions and 4 deletions

View File

@ -95,8 +95,8 @@ class NoteReply extends Entity
$result = DB::dql('select nr.reply_to from note_reply nr ' $result = DB::dql('select nr.reply_to from note_reply nr '
. 'where nr.note_id = :note_id', ['note_id' => $note->getId()], ); . 'where nr.note_id = :note_id', ['note_id' => $note->getId()], );
if (!\is_null($result) && \array_key_exists('reply_to', $result)) { if (!\is_null($result) && \array_key_exists(0, $result)) {
return $result['reply_to']; return $result[0]['reply_to'];
} }
return null; return null;

View File

@ -32,7 +32,7 @@ class TreeNotes extends Plugin
*/ */
public function onFormatNoteList(array $notes_in, ?array &$notes_out) public function onFormatNoteList(array $notes_in, ?array &$notes_out)
{ {
$roots = array_filter($notes_in, fn (Note $note) => NoteReply::getReplyToNote($note) == null); $roots = array_filter($notes_in, fn (Note $note) => \is_null(NoteReply::getReplyToNote($note)));
$notes_out = $this->build_tree($roots, $notes_in); $notes_out = $this->build_tree($roots, $notes_in);
} }
@ -47,7 +47,7 @@ class TreeNotes extends Plugin
private function build_subtree(Note $parent, array $notes) private function build_subtree(Note $parent, array $notes)
{ {
$children = array_filter($notes, fn (Note $note) => $parent->getId() == NoteReply::getReplyToNote($note)); $children = array_filter($notes, fn (Note $note) => $parent->getId() === NoteReply::getReplyToNote($note));
return ['note' => $parent, 'replies' => $this->build_tree($children, $notes)]; return ['note' => $parent, 'replies' => $this->build_tree($children, $notes)];
} }
} }