Commit 0b5361f9 authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[TASK] Use plain text for version notification email

The file extension of NewVersionNotify is changed from
`.html` to `.txt`, since it's a plain text template. This allows
to use the same template together with FluidEmail for both,
the REST API and the TER API.
parent 97bfaf4b
......@@ -12,6 +12,7 @@ namespace T3o\Ter\Api;
*/
use ApacheSolrForTypo3\Solr\IndexQueue\Queue;
use Symfony\Component\Mime\Address;
use T3o\Ter\Exception\FailedDependencyException;
use T3o\Ter\Exception\InternalServerErrorException;
use T3o\Ter\Exception\InvalidExtensionVersionFormatException;
......@@ -24,6 +25,8 @@ use T3o\TerFe2\Utility\CategoryUtility;
use T3o\TerFe2\Utility\VersionUtility;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Mail\FluidEmail;
use TYPO3\CMS\Core\Mail\Mailer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
......@@ -708,20 +711,25 @@ class ExtensionVersion
if (!empty($notifications)) {
foreach ($notifications as $notification) {
$mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
$mail->setTo($notification['email'], $notification['name']);
$mail->setSubject('Release of extension "' . (string)$this->extensionKey . '", version ' . $extensionData['version_string']);
$standalone = GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class);
$standalone->setTemplatePathAndFilename('EXT:ter_fe2/Resources/Private/Templates/Mail/NewVersionNotify.html');
$standalone->assignMultiple(
[
$email = $notification['email'] ?? '';
$username = $notification['username'] ?? '';
if ($email === '' || !GeneralUtility::validEmail($email)) {
continue;
}
$fluidEmail = GeneralUtility::makeInstance(FluidEmail::class);
$fluidEmail
->to(new Address($email, $username))
->format(FluidEmail::FORMAT_PLAIN)
->subject(sprintf('Release of extension "%s", version %s', $this->extensionKey, $extensionData['version_string'] ?? ''))
->setTemplate('NewVersionNotify')
->assignMultiple([
'notify' => $notification,
'extData' => $extensionData
]
);
$mail->text($standalone->render());
]);
$mail->send();
GeneralUtility::makeInstance(Mailer::class)->send($fluidEmail);
}
}
}
......
......@@ -558,10 +558,10 @@ class VersionService extends AbstractService
foreach ($notificationRecipients as $recipient) {
$this->mailService->sendMailToUser(
['email' => $recipient['email'], 'username' => $recipient['name']],
'Release of extension "' . $this->key . '", version ' . $this->version,
sprintf('Release of extension "%s", version %s', $this->key, $this->version),
['notify' => $recipient, 'extData' => $versionFields],
'NewVersionNotify',
FluidEmail::FORMAT_HTML
FluidEmail::FORMAT_PLAIN
);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment