mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
misc(emailer): Use constants for email types (#1794)
This commit is contained in:
parent
95ccf9bf3e
commit
c95d414ef6
5 changed files with 24 additions and 10 deletions
|
@ -309,6 +309,9 @@ define('HTML_DISABLED', ' disabled ');
|
|||
define('HTML_READONLY', ' readonly ');
|
||||
define('HTML_SELECTED', ' selected ');
|
||||
|
||||
define('EMAIL_TYPE_HTML', 'text/html');
|
||||
define('EMAIL_TYPE_TEXT', 'text/plain');
|
||||
|
||||
// $GPC
|
||||
define('KEY_NAME', 0); // position in $GPC['xxx']
|
||||
define('DEF_VAL', 1);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace TorrentPier;
|
||||
|
||||
use Exception;
|
||||
|
||||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||
use Symfony\Component\Mailer\Mailer;
|
||||
use Symfony\Component\Mailer\Transport\SendmailTransport;
|
||||
|
@ -119,6 +121,7 @@ class Emailer
|
|||
* @param string $email_format
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send(string $email_format = 'text/plain'): bool
|
||||
{
|
||||
|
@ -176,10 +179,15 @@ class Emailer
|
|||
$message->getHeaders()
|
||||
->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply');
|
||||
|
||||
if ($email_format == 'text/html') {
|
||||
switch ($email_format) {
|
||||
case EMAIL_TYPE_HTML:
|
||||
$message->html($this->message);
|
||||
} else {
|
||||
break;
|
||||
case EMAIL_TYPE_TEXT:
|
||||
$message->text($this->message);
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Unknown email format: ' . $email_format);
|
||||
}
|
||||
|
||||
/** Send message */
|
||||
|
|
|
@ -50,6 +50,9 @@ class IndexNow
|
|||
'naver' => 'searchadvisor.naver.com'
|
||||
];
|
||||
|
||||
/**
|
||||
* IndexNow constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
|
|
@ -130,14 +130,14 @@ class Updater
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns information of latest TorrentPier version
|
||||
* Returns information of latest TorrentPier version available
|
||||
*
|
||||
* @param bool $allowRC
|
||||
* @param bool $allowPreReleases
|
||||
* @return array
|
||||
*/
|
||||
public function getLastVersion(bool $allowRC = true): array
|
||||
public function getLastVersion(bool $allowPreReleases = true): array
|
||||
{
|
||||
if (!$allowRC) {
|
||||
if (!$allowPreReleases) {
|
||||
foreach ($this->jsonResponse as $index) {
|
||||
if (isset($index['prerelease']) && $index['prerelease']) {
|
||||
continue;
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
<td class="row1 tRight"><b>{L_MASS_EMAIL_MESSAGE_TYPE}</b></td>
|
||||
<td class="row2">
|
||||
<select name="message_type">
|
||||
<option value="text/plain" selected>text/plain</option>
|
||||
<option value="text/html">text/html</option>
|
||||
<option value="{#EMAIL_TYPE_TEXT#}" selected>{#EMAIL_TYPE_TEXT#}</option>
|
||||
<option value="{#EMAIL_TYPE_HTML#}">{#EMAIL_TYPE_HTML#}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue