set up webhook for organization creation ( hard Coded )
This commit is contained in:
parent
2dae055ae9
commit
0a4cb375e9
|
|
@ -19,6 +19,8 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-client" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/ralouphie/getallheaders" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/rate-limiter" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/remote-event" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/webhook" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
|
|
|
|||
|
|
@ -181,6 +181,10 @@
|
|||
<path value="$PROJECT_DIR$/vendor/twig/extra-bundle" />
|
||||
<path value="$PROJECT_DIR$/vendor/staabm/side-effects-detector" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/rate-limiter" />
|
||||
<path value="$PROJECT_DIR$/vendor/dama/doctrine-test-bundle" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php85" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/remote-event" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/webhook" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.2" />
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@
|
|||
"symfony/ux-turbo": "^2.24",
|
||||
"symfony/validator": "7.4.*",
|
||||
"symfony/web-link": "7.4.*",
|
||||
"symfony/webhook": "7.4.*",
|
||||
"symfony/yaml": "7.4.*",
|
||||
"twig/twig": "^2.12|^3.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -676,7 +676,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||
* }>,
|
||||
* },
|
||||
* webhook?: bool|array{ // Webhook configuration
|
||||
* enabled?: bool|Param, // Default: false
|
||||
* enabled?: bool|Param, // Default: true
|
||||
* message_bus?: scalar|Param|null, // The message bus to use. // Default: "messenger.default_bus"
|
||||
* routing?: array<string, array{ // Default: []
|
||||
* service: scalar|Param|null,
|
||||
|
|
@ -684,7 +684,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||
* }>,
|
||||
* },
|
||||
* remote-event?: bool|array{ // RemoteEvent configuration
|
||||
* enabled?: bool|Param, // Default: false
|
||||
* enabled?: bool|Param, // Default: true
|
||||
* },
|
||||
* json_streamer?: bool|array{ // JSON streamer configuration
|
||||
* enabled?: bool|Param, // Default: false
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ use App\Form\OrganizationForm;
|
|||
use App\Repository\OrganizationsRepository;
|
||||
use App\Repository\UsersOrganizationsRepository;
|
||||
use App\Service\ActionService;
|
||||
use App\Service\AwsService;
|
||||
use App\Service\LoggerService;
|
||||
use App\Webhook\OrganizationNotifier;
|
||||
use App\Service\OrganizationsService;
|
||||
use App\Service\UserOrganizationService;
|
||||
use App\Service\UserService;
|
||||
|
|
@ -37,7 +37,9 @@ class OrganizationController extends AbstractController
|
|||
private readonly ActionService $actionService,
|
||||
private readonly UserOrganizationService $userOrganizationService,
|
||||
private readonly OrganizationsRepository $organizationsRepository,
|
||||
private readonly LoggerService $loggerService, private readonly UsersOrganizationsRepository $usersOrganizationsRepository)
|
||||
private readonly LoggerService $loggerService,
|
||||
private readonly UsersOrganizationsRepository $usersOrganizationsRepository,
|
||||
private readonly OrganizationNotifier $organizationNotifier)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +113,8 @@ class OrganizationController extends AbstractController
|
|||
$this->entityManager->persist($organization);
|
||||
$this->entityManager->flush();
|
||||
|
||||
//webhook notify
|
||||
$this->organizationNotifier->notifyOrganizationCreated($organization);
|
||||
// Loggers...
|
||||
$this->loggerService->logOrganizationInformation($organization->getId(), $actingUser->getUserIdentifier(), "Organization Created via ajax");
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class LogoutSubscriber implements EventSubscriberInterface
|
|||
$params['redirect_app'] = $redirectApp;
|
||||
}
|
||||
|
||||
$easycheckLogoutUrl = $this->easycheckUrl . '/logout?' . http_build_query($params);
|
||||
$easycheckLogoutUrl = rtrim($this->easycheckUrl, '/'). '/logout?' . http_build_query($params);
|
||||
|
||||
$this->logger->info('Redirecting to EasyCheck logout', [
|
||||
'url' => $easycheckLogoutUrl,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Webhook;
|
||||
|
||||
use App\Entity\Organizations;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\RemoteEvent\RemoteEvent;
|
||||
use Symfony\Component\Webhook\Messenger\SendWebhookMessage;
|
||||
use Symfony\Component\Webhook\Subscriber;
|
||||
|
||||
class OrganizationNotifier
|
||||
{
|
||||
public function __construct(
|
||||
private readonly MessageBusInterface $messageBus,
|
||||
private readonly string $easycheckUrl,
|
||||
private readonly string $webhookSecret
|
||||
) {
|
||||
}
|
||||
|
||||
public function notifyOrganizationCreated(Organizations $organizations): void
|
||||
{
|
||||
$subscriber = new Subscriber(
|
||||
url: rtrim($this->easycheckUrl, '/'). '/webhook/organization_created',
|
||||
secret: $this->webhookSecret,
|
||||
);
|
||||
|
||||
$event = new RemoteEvent(
|
||||
name: 'organization_created',
|
||||
id: uniqid('', true),
|
||||
payload: [
|
||||
'orgId' => $organizations->getId(),
|
||||
'orgName' => $organizations->getName(),
|
||||
'orgEmail' => $organizations->getEmail(),
|
||||
'orgNumber' => $organizations->getNumber(),
|
||||
'orgAddress' => $organizations->getAddress(),
|
||||
'orgLogo' => $organizations->getLogoUrl(),
|
||||
'created_at' => time(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->messageBus->dispatch(
|
||||
new SendWebhookMessage($subscriber, $event)
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue