mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
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:
@ -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'];
|
||||
|
||||
|
Reference in New Issue
Block a user