From 2932af0d3fbc1c5d08b530bcbf8eb7ba0076cac1 Mon Sep 17 00:00:00 2001 From: ro Date: Tue, 17 Sep 2024 15:41:31 -0600 Subject: [PATCH] show multiple instance comments the previous update cycle only showed the latest comment from Sources concerning a specific instance now all available comments are pulled from denylist data to be displayed under Description on the front end --- app/Http/Controllers/FrontIndexController.php | 4 +++- app/Services/UpdateService.php | 20 +++++++++++++++++-- resources/views/front/location.blade.php | 6 +++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/FrontIndexController.php b/app/Http/Controllers/FrontIndexController.php index 375b948..7852020 100644 --- a/app/Http/Controllers/FrontIndexController.php +++ b/app/Http/Controllers/FrontIndexController.php @@ -79,10 +79,12 @@ class FrontIndexController extends Controller ($member->role == 1 || $member->role == 2) ? $edit = true : $edit = false; } - $links = explode(',', $location->archive_links); + $links = explode(',', $location->archive_links); + $comments = explode('+', $location->description); return view('front.location', [ 'title' => str_replace(".", " ", $name), 'location' => $location, + 'comments' => $comments, 'actions' => $location->block_count + $location->silence_count, 'sources_count' => count($sources), 'images' => json_decode($location->images), diff --git a/app/Services/UpdateService.php b/app/Services/UpdateService.php index b275b0a..60335bb 100644 --- a/app/Services/UpdateService.php +++ b/app/Services/UpdateService.php @@ -36,14 +36,15 @@ class UpdateService $fresh = 0; $unified = []; - $sources = $this->source->getActive(); + $sources = $this->source->getActive(); + $locations = $this->location->getActiveLocations(); foreach ($sources as $source) { //$listData = json_decode(); foreach (json_decode($source->list_data) as $item) { $index = array_search($item->domain, array_column($unified, 'url')); if ($index) { - //if there is a match, update the count + //if there is a match, update the count and comment if ($item->severity == "suspend" || $item->severity == "defederate") { ++$unified[$index]['block_count']; array_push($unified[$index]['block_vote'], $source->url); @@ -51,6 +52,9 @@ class UpdateService ++$unified[$index]['silence_count']; array_push($unified[$index]['silence_vote'], $source->url); } + if (!is_null($item->comment) && $item->comment != ' ' && $item->comment != '') { + $unified[$index]['comment'] = $item->comment . '+' . $unified[$index]['comment']; + } } else { $silence = 0; $suspend = 0; @@ -77,6 +81,12 @@ class UpdateService } } + //clear out all previous descriptions + foreach ($locations as $loc) { + $loc->description = ' '; + $loc->save(); + } + foreach ($unified as $item) { $location = $this->location->getLocation($item['url']); if ($location) { @@ -89,6 +99,12 @@ class UpdateService $location->silence_count = $item['silence_count']; $location->silence_vote = []; $location->silence_vote = $item['silence_vote']; + //clear descriptions + if (!is_null($item['comment']) || !$item['comment'] != " ") { + $location->description = $item['comment']; + } else { + $location->description = 'description pending'; + } $location->actions_count = $item['block_count'] + $item['silence_count']; diff --git a/resources/views/front/location.blade.php b/resources/views/front/location.blade.php index cd48e8b..5de5678 100644 --- a/resources/views/front/location.blade.php +++ b/resources/views/front/location.blade.php @@ -7,7 +7,11 @@

Description

- {{$location->description}}
+ @foreach($comments as $comment) + @if($comment != " " && $comment != '') + {{trim($comment)}}

+ @endif + @endforeach

References

Images

@if($images != null)