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

add missing delay variable in email #148

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 15 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,18 @@ public function getAllowedStatesToErase(int|string|null $website = null): array
$website
));
}

/**
* @param int|string|null $website
*
* @return int
*/
public function getDelay(int|string|null $website = null): int
{
return (int)$this->scopeConfig->getValue(
self::CONFIG_PATH_ERASURE_DELAY,
ScopeInterface::SCOPE_WEBSITE,
$website
);
}
thomas-kl1 marked this conversation as resolved.
Show resolved Hide resolved
}
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
Loading