Fix coding style in Repository\Notify and Util\Emailer

This commit is contained in:
Hypolite Petovan 2025-01-26 17:52:02 -05:00
parent 0006d838f5
commit 5d6be39a0c
2 changed files with 130 additions and 98 deletions

View file

@ -15,7 +15,6 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Factory\Api\Mastodon\Notification as NotificationFactory;
@ -205,7 +204,7 @@ class Notify extends BaseRepository
* @return bool
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function createFromArray($params)
public function createFromArray($params)
{
/** @var string the common prefix of a notification subject */
$subjectPrefix = $this->l10n->t('[Friendica:Notify]');
@ -340,7 +339,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s %s posted to your profile wall', $subjectPrefix, $params['source_name']);
$preamble = $l10n->t('%1$s posted to your profile wall at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('%1$s posted to [url=%2$s]your wall[/url]',
$epreamble = $l10n->t(
'%1$s posted to [url=%2$s]your wall[/url]',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
$params['link']
);
@ -356,7 +356,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s Introduction received', $subjectPrefix);
$preamble = $l10n->t('You\'ve received an introduction from \'%1$s\' at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.',
$epreamble = $l10n->t(
'You\'ve received [url=%1$s]an introduction[/url] from %2$s.',
$itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
);
@ -373,7 +374,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s A new person is sharing with you', $subjectPrefix);
$preamble = $l10n->t('%1$s is sharing with you at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('%1$s is sharing with you at %2$s',
$epreamble = $l10n->t(
'%1$s is sharing with you at %2$s',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
$sitename
);
@ -383,7 +385,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s You have a new follower', $subjectPrefix);
$preamble = $l10n->t('You have a new follower at %2$s : %1$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You have a new follower at %2$s : %1$s',
$epreamble = $l10n->t(
'You have a new follower at %2$s : %1$s',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
$sitename
);
@ -399,7 +402,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s Friend suggestion received', $subjectPrefix);
$preamble = $l10n->t('You\'ve received a friend suggestion from \'%1$s\' at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.',
$epreamble = $l10n->t(
'You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.',
$itemlink,
'[url='.$params['item']['url'].']'.$params['item']['name'].'[/url]',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
@ -420,7 +424,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s Connection accepted', $subjectPrefix);
$preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('%2$s has accepted your [url=%1$s]connection request[/url].',
$epreamble = $l10n->t(
'%2$s has accepted your [url=%1$s]connection request[/url].',
$itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
);
@ -435,7 +440,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s Connection accepted', $subjectPrefix);
$preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('%2$s has accepted your [url=%1$s]connection request[/url].',
$epreamble = $l10n->t(
'%2$s has accepted your [url=%1$s]connection request[/url].',
$itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
);
@ -457,14 +463,17 @@ class Notify extends BaseRepository
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('registration request');
$preamble = $l10n->t('You\'ve received a registration request from \'%1$s\' at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.',
$epreamble = $l10n->t(
'You\'ve received a [url=%1$s]registration request[/url] from %2$s.',
$itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
);
$body = $l10n->t("Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
$body = $l10n->t(
"Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
$params['source_name'],
$siteurl, $params['source_mail'],
$siteurl,
$params['source_mail'],
$params['source_nick']
);
@ -478,14 +487,17 @@ class Notify extends BaseRepository
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('new registration');
$preamble = $l10n->t('You\'ve received a new registration from \'%1$s\' at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You\'ve received a [url=%1$s]new registration[/url] from %2$s.',
$epreamble = $l10n->t(
'You\'ve received a [url=%1$s]new registration[/url] from %2$s.',
$itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
);
$body = $l10n->t("Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
$body = $l10n->t(
"Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
$params['source_name'],
$siteurl, $params['source_mail'],
$siteurl,
$params['source_mail'],
$params['source_nick']
);
@ -643,7 +655,8 @@ class Notify extends BaseRepository
$emailBuilder->withPhoto(
$datarray['source_photo'],
$datarray['source_link'] ?? $sitelink,
$datarray['source_name'] ?? $sitename);
$datarray['source_name'] ?? $sitename
);
}
$email = $emailBuilder->build();
@ -723,9 +736,12 @@ class Notify extends BaseRepository
$params['source_photo'] = $contact['photo'];
}
$item = Model\Post::selectFirstForUser($Notification->uid, Model\Item::ITEM_FIELDLIST,
$item = Model\Post::selectFirstForUser(
$Notification->uid,
Model\Item::ITEM_FIELDLIST,
['uid' => [0, $Notification->uid], 'uri-id' => $Notification->targetUriId, 'deleted' => false],
['order' => ['uid' => true]]);
['order' => ['uid' => true]]
);
if (empty($item)) {
$this->logger->info('Item not found', ['uri-id' => $Notification->targetUriId, 'type' => $Notification->type]);
return false;

View file

@ -40,9 +40,13 @@ class Emailer
/** @var string */
private $siteEmailName;
public function __construct(IManageConfigValues $config, IManagePersonalConfigValues $pConfig, BaseURL $baseURL, LoggerInterface $logger,
L10n $defaultLang)
{
public function __construct(
IManageConfigValues $config,
IManagePersonalConfigValues $pConfig,
BaseURL $baseURL,
LoggerInterface $logger,
L10n $defaultLang
) {
$this->config = $config;
$this->pConfig = $pConfig;
$this->logger = $logger;
@ -89,8 +93,14 @@ class Emailer
*/
public function newSystemMail()
{
return new SystemMailBuilder($this->l10n, $this->baseUrl, $this->config, $this->logger,
$this->getSiteEmailAddress(), $this->getSiteEmailName());
return new SystemMailBuilder(
$this->l10n,
$this->baseUrl,
$this->config,
$this->logger,
$this->getSiteEmailAddress(),
$this->getSiteEmailName()
);
}
/**
@ -100,8 +110,14 @@ class Emailer
*/
public function newNotifyMail()
{
return new NotifyMailBuilder($this->l10n, $this->baseUrl, $this->config, $this->logger,
$this->getSiteEmailAddress(), $this->getSiteEmailName());
return new NotifyMailBuilder(
$this->l10n,
$this->baseUrl,
$this->config,
$this->logger,
$this->getSiteEmailAddress(),
$this->getSiteEmailName()
);
}
/**