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