Skip to content

Commit

Permalink
multi allowed vendors for copyright watchers (#1388)
Browse files Browse the repository at this point in the history
I don't know if Symfony has multiple, but `flarum-lang` (for Flarum Languages) receives so many updates with the amount of languages being added lately. This solves the issue by marking certain vendors as allowed.

I haven't tested this by the way, but I might try doing that if you'd be up for this.
  • Loading branch information
luceos authored Aug 2, 2023
1 parent 2ae8c31 commit eabad13
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Validator/CopyrightValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,30 @@ public function validate(mixed $value, Constraint $constraint): void
}

$copyrightWatches = [
'flarum' => '[email protected]',
'symfony' => '[email protected]',
'flarum' => [
'allow' => ['flarum', 'flarum-lang', 'flarum-com'],
'email' => '[email protected]'
],
'symfony' => [
'allow' => ['symfony'],
'email' => '[email protected]'
],
];

$req = $this->requestStack->getMainRequest();
if (!$req || $req->attributes->get('_route') === 'submit.fetch_info') {
return;
}

foreach ($copyrightWatches as $vendor => $email) {
if ($value->getVendor() === $vendor || !str_contains($value->getVendor(), $vendor)) {
foreach ($copyrightWatches as $vendor => $config) {
if (in_array($value->getVendor(), $config['allow']) || !str_contains($value->getVendor(), $vendor)) {
continue;
}

$message = (new Email())
->subject('Packagist.org package submission notification: '.$value->getName().' contains '.$vendor.' in its vendor name')
->from(new Address($this->mailFromEmail))
->to($email)
->to($config['email'])
->text('Check out '.$this->urlGenerator->generate('view_package', ['name' => $value->getName()], UrlGeneratorInterface::ABSOLUTE_URL).' for copyright infringement.')
;
$message->getHeaders()->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply');
Expand Down

0 comments on commit eabad13

Please sign in to comment.