- Affected version
- 2.3.3
\XF\Service\Report\NotifierService::notifyCreate
is currently kinda monolithic which makes it somewhat difficult to extend.Could this be made more modular, eg. smth. like
PHP:
protected function getCreateNotificationEmailParams(User $user): array
{
$report = $this->report;
$comment = $this->comment;
return [
'receiver' => $user,
'reporter' => $comment->User,
'comment' => $comment,
'report' => $report,
'message' => $report->getContentMessage(),
];
}
protected function sendCreateNotification(Moderator $moderator): void
{
$user = $moderator->User;
if (empty($this->usersEmailed[$user->user_id]) && $moderator->notify_report)
{
$params = $this->getCreateNotificationEmailParams($user);
$mailer = $this->app->mailer();
$mailer->newMail()
->setToUser($user)
->setTemplate('report_create', $params)
->queue();
$this->usersEmailed[$user->user_id] = true;
}
}
public function notifyCreate()
{
$moderatorsToEmail = $this->getUsersForCreatedNotification();
foreach ($moderatorsToEmail AS $moderator)
{
$this->sendCreateNotification($moderator);
}
}
This would allow to easily modify the notification process.