Skip to content

Commit

Permalink
Merge pull request #148 from kpitn/feat-add-missing-delay
Browse files Browse the repository at this point in the history
add missing delay variable in email
  • Loading branch information
thomas-kl1 authored Aug 22, 2024
2 parents ac18010 + 6e30512 commit 5561056
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
9 changes: 9 additions & 0 deletions Model/Config/Entity/Erasure.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Erasure
{
private const CONFIG_PATH_ERASURE_MAX_AGE = 'gdpr/erasure/entity_max_age';
private const CONFIG_PATH_ERASURE_ALLOWED_STATES = 'gdpr/erasure/allowed_states';
private const CONFIG_PATH_ERASURE_DELAY = 'gdpr/erasure/delay';

public function __construct(
private ScopeConfigInterface $scopeConfig
Expand Down Expand Up @@ -51,4 +52,12 @@ public function getAllowedStatesToErase(int|string|null $website = null): array
$website
));
}

/**
* @return int
*/
public function getDelay(): int
{
return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY, ScopeInterface::SCOPE_WEBSITE);
}
}
15 changes: 7 additions & 8 deletions Model/Customer/Notifier/MailSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,19 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Mail\Template\TransportBuilder;
use Magento\Store\Model\StoreManagerInterface;
use Opengento\Gdpr\Model\Config\Entity\Erasure;
use Opengento\Gdpr\Model\Notifier\AbstractMailSender;

class MailSender extends AbstractMailSender implements SenderInterface
{
private View $customerViewHelper;

private StoreManagerInterface $storeManager;

public function __construct(
View $customerViewHelper,
private Erasure $erasureConfig,
private View $customerViewHelper,
private StoreManagerInterface $storeManager,
TransportBuilder $transportBuilder,
ScopeConfigInterface $scopeConfig,
StoreManagerInterface $storeManager,
array $configPaths
) {
$this->customerViewHelper = $customerViewHelper;
$this->storeManager = $storeManager;
parent::__construct($transportBuilder, $scopeConfig, $configPaths);
}

Expand All @@ -42,8 +38,11 @@ public function __construct(
*/
public function send(CustomerInterface $customer): void
{
$delay = $this->erasureConfig->getDelay();

$storeId = $customer->getStoreId() === null ? null : (int)$customer->getStoreId();
$vars = [
'delay' => $delay !== 0 ? $delay / 60 : 0,
'customer' => $customer,
'store' => $this->storeManager->getStore($customer->getStoreId()),
'customer_data' => [
Expand Down
11 changes: 3 additions & 8 deletions Model/EraseEntityManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
use Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory;
use Opengento\Gdpr\Api\EraseEntityManagementInterface;
use Opengento\Gdpr\Api\EraseEntityRepositoryInterface;
use Opengento\Gdpr\Model\Config\Entity\Erasure;
use Opengento\Gdpr\Service\Erase\ProcessorFactory;

class EraseEntityManagement implements EraseEntityManagementInterface
{
private const CONFIG_PATH_ERASURE_DELAY = 'gdpr/erasure/delay';

public function __construct(
private Erasure $erasureConfig,
private EraseEntityInterfaceFactory $eraseEntityFactory,
private EraseEntityRepositoryInterface $eraseRepository,
private ProcessorFactory $processorFactory,
Expand Down Expand Up @@ -94,12 +94,7 @@ private function retrieveScheduledAt(): string
{
return $this->localeDate->gmtDate(
DateTimeFormat::DATETIME_PHP_FORMAT,
$this->resolveErasureDelay() * 60 + $this->localeDate->gmtTimestamp()
$this->erasureConfig->getDelay() * 60 + $this->localeDate->gmtTimestamp()
);
}

private function resolveErasureDelay(): int
{
return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY);
}
}
2 changes: 1 addition & 1 deletion view/frontend/email/erase_pending.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<tr class="email-summary">
<td>
<p>{{trans "We have received a request to erase the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
<p>{{trans 'You can cancel the erase within %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
<p>{{trans 'You can cancel the erase within %delay hours by <a href="%account_url">logging into your account</a>.' delay=$delay account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
</td>
</tr>
<tr class="help-info">
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/email/erase_pending_guest.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<tr class="email-summary">
<td>
<p>{{trans "We have received a request to erase the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
<p>{{trans 'You can cancel the erase within %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
<p>{{trans 'You can cancel the erase within %delay hours by <a href="%account_url">logging into your account</a>.' delay=$delay account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
</td>
</tr>
<tr class="help-info">
Expand Down

0 comments on commit 5561056

Please sign in to comment.