Skip to content

Conversation

@andrestejerina97
Copy link
Contributor

No description provided.

@andrestejerina97 andrestejerina97 changed the title Chore/refactor to strategy formatters chore/refactor to strategy formatters Dec 5, 2025
@andrestejerina97 andrestejerina97 force-pushed the chore/refactor-to-strategy-formatters branch 3 times, most recently from 7b3c6b8 to 1cc3cbb Compare December 5, 2025 13:37

private function matchesStrategy(array $strategy, AuditContext $ctx): bool
{
if (isset($strategy['route']) && !$this->routeMatches($strategy['route'], $ctx->route)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrestejerina97 here we are missing to check the HTTP verb too
a route is compound of 2 attributes

  1. HTTP verb
  2. URI


private function routeMatches(string $pattern, string $actual_route): bool
{
$normalized_pattern = preg_replace('/\{[a-zA-Z_]+\}/', '\d+', $pattern);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrestejerina97 we dont need this lets just add the rawRoute ( without the bindings at AuditContext)
here

userAgent: $req?->userAgent(),

like this

rawRoute: Route::getRoutes()->match($req);
and then it just a simple string comparison

Copy link
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrestejerina97 please review comments

$req = request();


$route = Route::getRoutes()->match(request());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use $req here we are already getting the ref


$route = Route::getRoutes()->match(request());
$method = isset($route->methods[0]) ? $route->methods[0] : null;
$rawRoute = $method."|".$route->uri;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a constant here to communicate the intention


private function matchesStrategy(array $strategy, AuditContext $ctx): bool
{
if (isset($strategy['route']) && !$this->routeMatches($strategy['route'], $ctx->route)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u need to user $ctx->rawRoute not $ctx->route

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

Copy link
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrestejerina97 @martinquiroga-exo pleare review comments

@andrestejerina97 andrestejerina97 force-pushed the chore/refactor-to-strategy-formatters branch from ceb8212 to 88ad555 Compare December 9, 2025 18:37
@andrestejerina97 andrestejerina97 marked this pull request as ready for review December 9, 2025 18:39
@andrestejerina97 andrestejerina97 force-pushed the chore/refactor-to-strategy-formatters branch from 88ad555 to e6043e6 Compare December 9, 2025 18:43
Copy link
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

'formatter' => \App\Audit\ConcreteFormatters\PresentationFormatters\PresentationEventApiAuditLogFormatter::class,
],
[
'route' => 'PUT|api/v1/summits/{id}/events',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is missing param {event_id}
route is api/v1/summits/{id}/events/{event_id}

Copy link
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@smarcet smarcet merged commit 7e817d7 into main Dec 9, 2025
5 checks passed
matiasperrone-exo pushed a commit that referenced this pull request Dec 9, 2025
* feat: add news formatter for entitys related to Presentation for speakers

* feat: add a formatter for entities related to speaker presentations

* chore: replace the otlp interface with abstractFactory. Add the user context to the formatters

* chore: refactor getUserInfo to AbstractAuditLog

* chore: refactor strategy for get Formatters

* chore: change path to actual routes

* fix: change path to actual routes

* fix: OpenAPI doc

* fix: add missing param

---------

Co-authored-by: Matias Perrone <github@matiasperrone.com>
matiasperrone-exo pushed a commit that referenced this pull request Dec 10, 2025
* feat: add news formatter for entitys related to Presentation for speakers

* feat: add a formatter for entities related to speaker presentations

* chore: replace the otlp interface with abstractFactory. Add the user context to the formatters

* chore: refactor getUserInfo to AbstractAuditLog

* chore: refactor strategy for get Formatters

* chore: change path to actual routes

* fix: change path to actual routes

* fix: OpenAPI doc

* fix: add missing param

---------

Co-authored-by: Matias Perrone <github@matiasperrone.com>
andrestejerina97 added a commit that referenced this pull request Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants