Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[make:webhook] Rephrase comments to be more explicit + minor improvement of generated code #1512

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Resources/skeleton/webhook/RequestParser.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ protected function getRequestMatcher(): RequestMatcherInterface
*/
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?RemoteEvent
{
// Implement your own logic to validate and parse the request, and return a RemoteEvent object.
// TODO: Adapt or replace the content of this method to fit your need.

// Validate the request against $secret.
$authToken = $request->headers->get('X-Authentication-Token');
if (is_null($authToken) || $authToken !== $secret) {
if ($authToken !== $secret) {
throw new RejectWebhookException(Response::HTTP_UNAUTHORIZED, 'Invalid authentication token.');
}

Expand Down
7 changes: 3 additions & 4 deletions tests/fixtures/make-webhook/RemoteServiceRequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ protected function getRequestMatcher(): RequestMatcherInterface
*/
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?RemoteEvent
{
// Implement your own logic to validate and parse the request, and return a RemoteEvent object.
// TODO: Adapt or replace the content of this method to fit your need.

// Validate the request against $secret.
$authToken = $request->headers->get('X-Authentication-Token');

if (null === $authToken || $authToken !== $secret) {
if ($authToken !== $secret) {
throw new RejectWebhookException(Response::HTTP_UNAUTHORIZED, 'Invalid authentication token.');
}

Expand All @@ -41,7 +40,7 @@ protected function doParse(Request $request, #[\SensitiveParameter] string $secr
}

// Parse the request payload and return a RemoteEvent object.
$payload = $request->getPayload()->getIterator()->getArrayCopy();
$payload = $request->getPayload()->all();

return new RemoteEvent(
$payload['name'],
Expand Down
Loading