Skip to content

Commit

Permalink
feat: do not register anonymous entities
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Dec 27, 2024
1 parent 3ea6e3e commit a535d8c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace App\Entity;

use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\EntityRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand All @@ -15,13 +12,14 @@
use Symfony\Component\Serializer\Attribute\SerializedName;

#[ORM\Entity(repositoryClass: EntityRepository::class)]
#[ApiFilter(SearchFilter::class, properties: ['jCard' => 'partial'])]
#[ApiResource(
operations: [
/*
new GetCollection(
uriTemplate: '/entities',
normalizationContext: ['groups' => ['entity:list', 'event:list']]
),
*/
new Get(
uriTemplate: '/entities/{handle}',
normalizationContext: [
Expand Down
3 changes: 2 additions & 1 deletion src/Entity/Nameserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\NameserverRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand All @@ -15,6 +14,7 @@
#[ORM\Entity(repositoryClass: NameserverRepository::class)]
#[ApiResource(
operations: [
/*
new GetCollection(
uriTemplate: '/nameservers',
normalizationContext: [
Expand All @@ -23,6 +23,7 @@
],
]
),
*/
new Get(
uriTemplate: '/nameservers/{ldhName}',
normalizationContext: [
Expand Down
9 changes: 9 additions & 0 deletions src/Service/RDAPService.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
'xn--hlcj6aya9esc7a',
];

public const ENTITY_HANDLE_BLACKLIST = [
'REDACTED_FOR_PRIVACY',
'ANO00-FRNIC',
];

public function __construct(private HttpClientInterface $client,
private EntityRepository $entityRepository,
private DomainRepository $domainRepository,
Expand Down Expand Up @@ -333,6 +338,10 @@ private function updateDomainEntities(Domain $domain, array $rdapData): void

if (array_key_exists('entities', $rdapData) && is_array($rdapData['entities'])) {
foreach ($rdapData['entities'] as $rdapEntity) {
if (array_key_exists('handle', $rdapEntity) && in_array($rdapEntity['handle'], self::ENTITY_HANDLE_BLACKLIST)) {
continue;
}

$roles = $this->extractEntityRoles($rdapData['entities'], $rdapEntity);
$entity = $this->registerEntity($rdapEntity, $roles, $domain->getLdhName());

Expand Down

0 comments on commit a535d8c

Please sign in to comment.