[MAIL] Make mailserver a required service
This commit is contained in:
parent
71db1870db
commit
04e31d273d
5
bin/configure
vendored
5
bin/configure
vendored
@ -50,7 +50,9 @@ EOF
|
||||
|
||||
fi
|
||||
|
||||
echo "${database_url}" > .env.local
|
||||
echo "${database_url}" >> .env.local
|
||||
|
||||
printf "Mailer dsn: " && read -r mailer_dsn
|
||||
|
||||
mkdir -p ./docker/social
|
||||
|
||||
@ -65,4 +67,5 @@ SOCIAL_ADMIN_NICK="${admin_nick}"
|
||||
SOCIAL_ADMIN_PASSWORD="${admin_password}"
|
||||
SOCIAL_ADMIN_EMAIL="${email}"
|
||||
SOCIAL_SITE_PROFILE="${profile}"
|
||||
MAILER_DSN="${mailer_dsn}"
|
||||
EOF
|
||||
|
@ -47,9 +47,7 @@ use App\Core\DB\DefaultSettings;
|
||||
use App\Core\I18n\I18n;
|
||||
use App\Core\Queue\Queue;
|
||||
use App\Core\Router\Router;
|
||||
use App\Util\Common;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
@ -58,6 +56,7 @@ use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Component\Security\Core\Security as SSecurity;
|
||||
@ -77,6 +76,8 @@ class GNUsocial implements EventSubscriberInterface
|
||||
protected EventDispatcherInterface $event_dispatcher;
|
||||
protected SessionInterface $session;
|
||||
protected SSecurity $security;
|
||||
protected MailerInterface $mailer;
|
||||
protected ModuleManager $module_manager;
|
||||
|
||||
/**
|
||||
* Symfony dependency injection gives us access to these services
|
||||
@ -89,7 +90,9 @@ class GNUsocial implements EventSubscriberInterface
|
||||
MessageBusInterface $mb,
|
||||
EventDispatcherInterface $ed,
|
||||
SessionInterface $sess,
|
||||
SSecurity $sec)
|
||||
SSecurity $sec,
|
||||
MailerInterface $mail,
|
||||
ModuleManager $mod)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
$this->translator = $trans;
|
||||
@ -100,6 +103,8 @@ class GNUsocial implements EventSubscriberInterface
|
||||
$this->event_dispatcher = $ed;
|
||||
$this->session = $sess;
|
||||
$this->security = $sec;
|
||||
$this->mailer = $mail;
|
||||
$this->module_manager = $mod;
|
||||
|
||||
$this->initialize();
|
||||
}
|
||||
@ -119,20 +124,13 @@ class GNUsocial implements EventSubscriberInterface
|
||||
Form::setFactory($this->form_factory);
|
||||
Queue::setMessageBus($this->message_bus);
|
||||
Security::setHelper($this->security);
|
||||
Mailer::setMailer($this->mailer);
|
||||
|
||||
DefaultSettings::setDefaults();
|
||||
|
||||
// TODO use configuration properly
|
||||
try {
|
||||
if (Common::config('site', 'use_email')) {
|
||||
Mailer::setMailer($this->containen->get('mailer'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Table doesn't exist yet
|
||||
}
|
||||
|
||||
Cache::setupCache();
|
||||
ModulesManager::loadModules();
|
||||
|
||||
$this->module_manager->loadModules();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,21 +32,18 @@
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
use App\Util\Common;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
|
||||
abstract class Mailer
|
||||
{
|
||||
private MailerInterface $mailer;
|
||||
private static MailerInterface $mailer;
|
||||
public static function setMailer($m)
|
||||
{
|
||||
$this->mailer = $m;
|
||||
self::$mailer = $m;
|
||||
}
|
||||
|
||||
public static function __callStatic(string $method, array $args)
|
||||
{
|
||||
if (Common::config('site', 'use_email')) {
|
||||
return $this->{$method}(...$args);
|
||||
}
|
||||
return self::{$method}(...$args);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user