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
This commit is contained in:
ro 2024-09-17 15:41:31 -06:00
parent 0eeab6355e
commit 2932af0d3f
3 changed files with 26 additions and 4 deletions

View file

@ -80,9 +80,11 @@ class FrontIndexController extends Controller
} }
$links = explode(',', $location->archive_links); $links = explode(',', $location->archive_links);
$comments = explode('+', $location->description);
return view('front.location', [ return view('front.location', [
'title' => str_replace(".", " ", $name), 'title' => str_replace(".", " ", $name),
'location' => $location, 'location' => $location,
'comments' => $comments,
'actions' => $location->block_count + $location->silence_count, 'actions' => $location->block_count + $location->silence_count,
'sources_count' => count($sources), 'sources_count' => count($sources),
'images' => json_decode($location->images), 'images' => json_decode($location->images),

View file

@ -37,13 +37,14 @@ class UpdateService
$unified = []; $unified = [];
$sources = $this->source->getActive(); $sources = $this->source->getActive();
$locations = $this->location->getActiveLocations();
foreach ($sources as $source) { foreach ($sources as $source) {
//$listData = json_decode(); //$listData = json_decode();
foreach (json_decode($source->list_data) as $item) { foreach (json_decode($source->list_data) as $item) {
$index = array_search($item->domain, array_column($unified, 'url')); $index = array_search($item->domain, array_column($unified, 'url'));
if ($index) { 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") { if ($item->severity == "suspend" || $item->severity == "defederate") {
++$unified[$index]['block_count']; ++$unified[$index]['block_count'];
array_push($unified[$index]['block_vote'], $source->url); array_push($unified[$index]['block_vote'], $source->url);
@ -51,6 +52,9 @@ class UpdateService
++$unified[$index]['silence_count']; ++$unified[$index]['silence_count'];
array_push($unified[$index]['silence_vote'], $source->url); 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 { } else {
$silence = 0; $silence = 0;
$suspend = 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) { foreach ($unified as $item) {
$location = $this->location->getLocation($item['url']); $location = $this->location->getLocation($item['url']);
if ($location) { if ($location) {
@ -89,6 +99,12 @@ class UpdateService
$location->silence_count = $item['silence_count']; $location->silence_count = $item['silence_count'];
$location->silence_vote = []; $location->silence_vote = [];
$location->silence_vote = $item['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']; $location->actions_count = $item['block_count'] + $item['silence_count'];

View file

@ -7,7 +7,11 @@
<section> <section>
<article> <article>
<h2>Description</h2> <h2>Description</h2>
{{$location->description}}<br /> @foreach($comments as $comment)
@if($comment != " " && $comment != '')
{{trim($comment)}}<br /><br />
@endif
@endforeach
<h2>References</h2> <h2>References</h2>
<h3>Images</h3> <h3>Images</h3>
@if($images != null) @if($images != null)