-
Notifications
You must be signed in to change notification settings - Fork 2
chore/refactor to strategy formatters #468
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
Conversation
7b3c6b8 to
1cc3cbb
Compare
|
|
||
| private function matchesStrategy(array $strategy, AuditContext $ctx): bool | ||
| { | ||
| if (isset($strategy['route']) && !$this->routeMatches($strategy['route'], $ctx->route)) { |
There was a problem hiding this comment.
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
- HTTP verb
- URI
|
|
||
| private function routeMatches(string $pattern, string $actual_route): bool | ||
| { | ||
| $normalized_pattern = preg_replace('/\{[a-zA-Z_]+\}/', '\d+', $pattern); |
There was a problem hiding this comment.
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
summit-api/app/Audit/AuditEventListener.php
Line 111 in ee9422d
| userAgent: $req?->userAgent(), |
like this
rawRoute: Route::getRoutes()->match($req);
and then it just a simple string comparison
smarcet
left a comment
There was a problem hiding this 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
app/Audit/AuditEventListener.php
Outdated
| $req = request(); | ||
|
|
||
|
|
||
| $route = Route::getRoutes()->match(request()); |
There was a problem hiding this comment.
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
app/Audit/AuditEventListener.php
Outdated
|
|
||
| $route = Route::getRoutes()->match(request()); | ||
| $method = isset($route->methods[0]) ? $route->methods[0] : null; | ||
| $rawRoute = $method."|".$route->uri; |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
smarcet
left a comment
There was a problem hiding this 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
ceb8212 to
88ad555
Compare
…context to the formatters
88ad555 to
e6043e6
Compare
smarcet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
config/audit_log.php
Outdated
| 'formatter' => \App\Audit\ConcreteFormatters\PresentationFormatters\PresentationEventApiAuditLogFormatter::class, | ||
| ], | ||
| [ | ||
| 'route' => 'PUT|api/v1/summits/{id}/events', |
There was a problem hiding this comment.
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}
smarcet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* 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>
* 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>
This reverts commit 7e817d7.
No description provided.