mirror of
https://github.com/friendica/friendica
synced 2024-12-23 08:40:16 +00:00
Move "App::getSenderEmailAddress()" to "Emailer::getSiteEmailAddress()"
This commit is contained in:
parent
206b53477e
commit
0e13428210
5 changed files with 45 additions and 41 deletions
|
@ -72,7 +72,7 @@ function notification($params)
|
|||
$hostname = substr($hostname, 0, strpos($hostname, ':'));
|
||||
}
|
||||
|
||||
$sender_email = $a->getSenderEmailAddress();
|
||||
$sender_email = DI::emailer()->getSiteEmailAddress();
|
||||
|
||||
$user = DBA::selectFirst('user', ['nickname', 'page-flags'],
|
||||
['uid' => $params['uid']]);
|
||||
|
|
21
src/App.php
21
src/App.php
|
@ -242,27 +242,6 @@ class App
|
|||
$this->baseURL->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the site's default sender email address
|
||||
*
|
||||
* @return string
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function getSenderEmailAddress()
|
||||
{
|
||||
$sender_email = $this->config->get('config', 'sender_email');
|
||||
if (empty($sender_email)) {
|
||||
$hostname = $this->baseURL->getHostname();
|
||||
if (strpos($hostname, ':')) {
|
||||
$hostname = substr($hostname, 0, strpos($hostname, ':'));
|
||||
}
|
||||
|
||||
$sender_email = 'noreply@' . $hostname;
|
||||
}
|
||||
|
||||
return $sender_email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current theme name. May be overriden by the mobile theme name.
|
||||
*
|
||||
|
|
|
@ -77,7 +77,7 @@ class Invite extends BaseModule
|
|||
}
|
||||
|
||||
$additional_headers = 'From: ' . $app->user['email'] . "\n"
|
||||
. 'Sender: ' . $app->getSenderEmailAddress() . "\n"
|
||||
. 'Sender: ' . DI::emailer()->getSiteEmailAddress() . "\n"
|
||||
. 'Content-type: text/plain; charset=UTF-8' . "\n"
|
||||
. 'Content-transfer-encoding: 8bit';
|
||||
|
||||
|
|
|
@ -26,19 +26,18 @@ class SystemMailBuilder extends MailBuilder
|
|||
/** @var string */
|
||||
protected $siteAdmin;
|
||||
|
||||
public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, IConfig $config)
|
||||
public function __construct(L10n $l10n, BaseURL $baseUrl, IConfig $config, string $siteEmailAddress, string $siteName)
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $config);
|
||||
|
||||
$siteName = $this->config->get('config', 'sitename');
|
||||
|
||||
if ($this->config->get('config', 'admin_name')) {
|
||||
$this->siteAdmin = $l10n->t('%1$s, %2$s Administrator', $this->config->get('config', 'admin_name'), $siteName);
|
||||
} else {
|
||||
$this->siteAdmin = $l10n->t('%s Administrator', $siteName);
|
||||
}
|
||||
|
||||
$this->senderAddress = $a->getSenderEmailAddress();
|
||||
// Set the system wide site address/name as sender (default for system mails)
|
||||
$this->withSender($siteEmailAddress, $siteName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,15 +108,4 @@ class SystemMailBuilder extends MailBuilder
|
|||
'$textversion' => $textVersion,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function build(bool $raw = false)
|
||||
{
|
||||
// for system emails, always use the sitename/site address as the sender
|
||||
$this->withSender($this->config->get('config', 'sitename'), $this->senderAddress);
|
||||
|
||||
return parent::build($raw);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,25 +29,62 @@ class Emailer
|
|||
/** @var App\BaseURL */
|
||||
private $baseUrl;
|
||||
|
||||
/** @var string */
|
||||
private $siteEmailAddress;
|
||||
/** @var string */
|
||||
private $siteEmailName;
|
||||
|
||||
public function __construct(IConfig $config, IPConfig $pConfig, App\BaseURL $baseURL, LoggerInterface $logger)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->logger = $logger;
|
||||
$this->baseUrl = $baseURL;
|
||||
|
||||
$this->siteEmailAddress = $this->config->get('config', 'sender_email');
|
||||
if (empty($sysEmailAddress)) {
|
||||
$hostname = $this->baseUrl->getHostname();
|
||||
if (strpos($hostname, ':')) {
|
||||
$hostname = substr($hostname, 0, strpos($hostname, ':'));
|
||||
}
|
||||
|
||||
$this->siteEmailAddress = 'noreply@' . $hostname;
|
||||
}
|
||||
|
||||
$this->siteEmailName = $this->config->get('config', 'sitename', 'Friendica Social Network');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the site's default sender email address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSiteEmailAddress()
|
||||
{
|
||||
return $this->siteEmailAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the site's default sender name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSiteEmailName()
|
||||
{
|
||||
return $this->siteEmailName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new system email
|
||||
*
|
||||
* @param App $a The Friendica app
|
||||
* @param L10n $l10n The chosen language for the new email
|
||||
*
|
||||
* @return SystemMailBuilder
|
||||
*/
|
||||
public function newSystemMail(App $a, L10n $l10n)
|
||||
public function newSystemMail(L10n $l10n)
|
||||
{
|
||||
return new SystemMailBuilder($a, $l10n, $this->baseUrl, $this->config);
|
||||
return new SystemMailBuilder($l10n, $this->baseUrl, $this->config,
|
||||
$this->getSiteEmailAddress(), $this->getSiteEmailName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue