mirror of
https://github.com/friendica/friendica
synced 2024-11-18 21:03:41 +00:00
split mailbuilder types
This commit is contained in:
parent
34dce9fd76
commit
cb08912926
4 changed files with 34 additions and 12 deletions
|
@ -502,7 +502,7 @@ function notification($params)
|
|||
Hook::callAll('enotify_mail', $datarray);
|
||||
|
||||
$builder = DI::emailer()
|
||||
->newNotifyMail($l10n)
|
||||
->newNotifyMail()
|
||||
->addHeaders($datarray['headers'])
|
||||
->withRecipient($params['to_email'])
|
||||
->forUser($datarray['uid'])
|
||||
|
|
|
@ -13,8 +13,18 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
|
|||
/**
|
||||
* Builder for notification emails (notification, source, links, ...)
|
||||
*/
|
||||
class NotifyMailBuilder extends SystemMailBuilder
|
||||
class NotifyMailBuilder extends MailBuilder
|
||||
{
|
||||
/** @var string */
|
||||
protected $subject;
|
||||
/** @var string */
|
||||
protected $preamble;
|
||||
/** @var string */
|
||||
protected $body;
|
||||
|
||||
/** @var string */
|
||||
protected $siteAdmin;
|
||||
|
||||
/** @var bool */
|
||||
private $contentAllowed = true;
|
||||
/** @var string */
|
||||
|
@ -42,7 +52,16 @@ class NotifyMailBuilder extends SystemMailBuilder
|
|||
|
||||
public function __construct(L10n $l10n, BaseURL $baseUrl, IConfig $config, string $siteEmailAddress, string $siteName)
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $config, $siteEmailAddress, $siteName);
|
||||
parent::__construct($l10n, $baseUrl, $config);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Set the system wide site address/name as sender (default for system mails)
|
||||
$this->withSender($siteName, $siteEmailAddress, $siteEmailAddress);
|
||||
|
||||
// check whether sending post content in email notifications is allowed
|
||||
$this->contentAllowed = $this->config->get('system', 'enotify_no_content');
|
||||
|
@ -60,9 +79,16 @@ class NotifyMailBuilder extends SystemMailBuilder
|
|||
*/
|
||||
public function withNotification(string $subject, string $preamble, string $title, string $body = null)
|
||||
{
|
||||
$this->title = stripslashes($title);
|
||||
if (!isset($body)) {
|
||||
$body = $preamble;
|
||||
}
|
||||
|
||||
return $this->withMessage($subject, $preamble, $body);
|
||||
$this->title = stripslashes($title);
|
||||
$this->subject = $subject;
|
||||
$this->preamble = $preamble;
|
||||
$this->body = $body;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,9 +38,7 @@ class SystemMailBuilder extends MailBuilder
|
|||
}
|
||||
|
||||
// Set the system wide site address/name as sender (default for system mails)
|
||||
$this->senderName = $siteName;
|
||||
$this->senderAddress = $siteEmailAddress;
|
||||
$this->senderNoReply = $siteEmailAddress;
|
||||
$this->withSender($siteName, $siteEmailAddress, $siteEmailAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -96,13 +96,11 @@ class Emailer
|
|||
*
|
||||
* @see Notify
|
||||
*
|
||||
* @param L10n $l10n The chosen language for the new email
|
||||
*
|
||||
* @return NotifyMailBuilder
|
||||
*/
|
||||
public function newNotifyMail(L10n $l10n)
|
||||
public function newNotifyMail()
|
||||
{
|
||||
return new NotifyMailBuilder($l10n, $this->baseUrl, $this->config,
|
||||
return new NotifyMailBuilder($this->l10n, $this->baseUrl, $this->config,
|
||||
$this->getSiteEmailAddress(), $this->getSiteEmailName());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue