Skip to content

Commit

Permalink
Add image to comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Tschucki committed Jul 24, 2024
1 parent 42e872d commit b8ac01a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/Console/Commands/SyncMessagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ protected function syncComments(array $comments): void
{
$this->withProgressBar($comments, function ($comment) {
if ($this->isValidComment($comment)) {
$posts = Pr0grammApi::Post()->get([
"id" => $comment['itemId'],
"flags" => 31
]);

$post = collect($posts->json()["items"])->filter(function (array $post) use($comment) {
return $post["id"] === $comment['itemId'];
});

$image = $post->first()["image"];

if($image !== null) {
$comment["image"] = $image;
}

Message::firstOrCreate(['messageId' => $comment['id']], $comment);
}
});
Expand Down

0 comments on commit b8ac01a

Please sign in to comment.