Skip to content

Commit

Permalink
Merge pull request #1575 from ConductionNL/feature/IM-85/log-email-te…
Browse files Browse the repository at this point in the history
…mplate

Some fixes for log Actions and Sending emails
  • Loading branch information
WilcoLouwerse authored Oct 24, 2023
2 parents beb6c06 + defc20f commit 0de5dd8
Show file tree
Hide file tree
Showing 6 changed files with 576 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"symfony/proxy-manager-bridge": "5.3.*",
"symfony/runtime": "5.3.*",
"symfony/security-bundle": "5.3.*",
"symfony/sendinblue-mailer": "5.3.*",
"symfony/serializer": "5.3.*",
"symfony/twig-bundle": "5.3.*",
"symfony/validator": "5.3.*",
Expand Down
67 changes: 66 additions & 1 deletion api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion api/src/Controller/ZZController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function objectAction(
}

/**
* @TODO This function needs to be more dynamic: /{item}/api/{path}.
* This function dynamically handles the custom endpoints.
*
* @Route("/{prefix}/api/{path}", name="dynamic_route_second", requirements={"path" = ".+"})
Expand Down
1 change: 1 addition & 0 deletions api/src/Logger/SessionDataProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function dispatchLogCreateAction(array $record): array
$this->entityManager->getConnection()->getSchemaManager()->listDatabases()
) === true
&& $this->entityManager->getConnection()->getSchemaManager()->tablesExist('action') === true
&& in_array($record['level_name'], ['DEBUG', 'INFO', 'NOTICE', 'WARNING']) === false
){
$event = new ActionEvent('commongateway.action.event', $record, 'core.log.create');

Expand Down
7 changes: 5 additions & 2 deletions api/src/Service/EmailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;

// todo: move this to an email plugin with the following packages from composer.json: symfony/mailer, symfony/mailgun-mailer & symfony/http-client
// todo: move this to an email plugin with the following packages from composer.json: symfony/mailer, symfony/mailgun-mailer, symfony/sendinblue-mailer & symfony/http-client

/**
* @Author Wilco Louwerse <[email protected]>, Ruben van der Linde <[email protected]>, Sarai Misidjan <[email protected]>
Expand Down Expand Up @@ -71,8 +71,11 @@ private function sendEmail(): bool
$variables = [];

foreach ($this->configuration['variables'] as $key => $variable) {
if (array_key_exists($variable, $this->data['response'])) {
// Response is the default used for creating emails after an /api endpoint has been called and returned a response.
if (isset($this->data['response']) === true && array_key_exists($variable, $this->data['response'])) {
$variables[$key] = $this->data['response'][$variable];
} elseif (array_key_exists($variable, $this->data)) {
$variables[$key] = $this->data[$variable];
}
}

Expand Down
Loading

0 comments on commit 0de5dd8

Please sign in to comment.