<?php
namespace Claromentis\Infocapture\Subscriber;

$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"] ?: array()) + array("_03b1f0cee" . "835582d115" . "8dce2678b5" . "05c" => base64_decode("U3RhcnRpbmcgaW5mb2NhcHR1cmUgbWFpbCByZWNlaXZlZCBzdWJ" . "zY3JpYmVy"), "_67a0d624" . "aebcceb0a" . "bd5ce56a5" . "3ff06f" => base64_decode("ZGF" . "0ZQ" . "=="), "projec" . "t_id" => base64_decode("cHJva" . "mVjdF" . "9pZA=" . "="), "_f656816" . "961e8573" . "806141c5" . "58b184fe" . "2" => base64_decode("c3ViamVj" . "dA=="), "_a3d82c5df38e1" . "94c9c73e3ccb42" . "23bbc" => base64_decode("ZW1haWxfZGF0YQ=" . "="), "_618a4aeb9fecc4592a45" . "21f34876fa29" => base64_decode("ZnJvbQ" . "=="), "_5d40a2cf1c525fb252bf5599e3" . "39fdd0" => base64_decode("Tm8gaW5mb2NhcHR1cmUgcHJvamVjdCB3YXMgaWRlbnRpZmllZCBmb3IgbWFpbDsgc3Via" . "mVjdCAn"), "_c35473364fa7a050299058f33" . "2ec29c1" => base64_decode("ZXhj" . "ZXB0" . "aW9u"), "_ced92d7b391285c8a26846f" . "1f4bd3128" => base64_decode("Ym9keV9" . "0ZXh0"), "_e608e5b5c4c34a" . "67ba97ef84c1e16" . "199" => base64_decode("Jw" . "=="), "_9b16fa2" . "683095e6" . "7d7c8b26" . "5a8081d0" . "b" => base64_decode("TWFpbFJlY2VpdmVkRXZlbnRSZWNl" . "aXZlcg=="), "_bfda889b74ea561b143" . "25e30e7d75426" => base64_decode("Ym9keV9" . "odG1s"), "_376d30c40857357a4d4c" . "bb1ffaa25817" => base64_decode("dG" . "8="), "_460e1aeb3113a1676ce59a8f40431" . "d5c" => base64_decode("RmFpbGVkIHRvIHBy" . "b2Nlc3MgZW1haWwg" . "Zm9yIGluZm9jYXB0" . "dXJlIHByb2plY3Q="));
use Claromentis\Core\Event\EventDispatcherInterface;
use Claromentis\Core\Event\EventSubscriberInterface;
use Claromentis\Core\Mail\Receive\Event\ReceiveMailEventType;
use Claromentis\Core\Mail\Receive\Event\ReceiveMailEvent;
use Claromentis\Infocapture\Model\MailboxMessage;
use Claromentis\Infocapture\UseCase\GetProjectByEmailAddress;
use Claromentis\Infocapture\UseCase\ProcessEmail;
use Exception;
use Psr\Log\LoggerInterface;
class MailReceivedSubscriber implements EventSubscriberInterface
{
    protected $logger;
    protected $get_project_use_case;
    protected $process_email_use_case;
    public function __construct(LoggerInterface $logger, GetProjectByEmailAddress $_ecd19adac06bcc3637cff9925531a823, ProcessEmail $_33929bbf18079cca22e39e6dbe7eea3c)
    {
        $this->logger = $logger;
        $this->get_project_use_case = $_ecd19adac06bcc3637cff9925531a823;
        $this->process_email_use_case = $_33929bbf18079cca22e39e6dbe7eea3c;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public static function getSubscribedEvents()
    {
        return [
            
            
            ReceiveMailEventType::RECEIVE_MAIL => $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_9b16fa268309" . "5e67d7c8b265a" . "8081d0b"],
        ];
    }
    
    
    
    
    
    
    public function MailReceivedEventReceiver(ReceiveMailEvent $event, $_5693d84b45564f912e36404cbe8957e8, EventDispatcherInterface $_b497ce6f2af10f67516aed0ecf34d8cf)
    {
        $this->logger->info($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_03b1f0cee835582" . "d1158dce2678b505" . "c"]);
        $_a9bf694098bca136cc65bf4d2623bc70 = $event->GetMailMessage();
        $_f656816961e8573806141c558b184fe2 = $_a9bf694098bca136cc65bf4d2623bc70->GetSubject();
        
        
        $project = null;
        if ($_a9bf694098bca136cc65bf4d2623bc70 instanceof MailboxMessage) {
            $project = $_a9bf694098bca136cc65bf4d2623bc70->GetProject();
        } else {
            $project = $this->get_project_use_case->GetMailgunProject($_a9bf694098bca136cc65bf4d2623bc70->GetRecipientAddress());
        }
        if ($project === null) {
            $this->logger->debug($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_5d40a2cf1c525fb252bf5599e339fdd" . "0"] . $_f656816961e8573806141c558b184fe2 . $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_e608e5b5c4c34a67ba" . "97ef84c1e16199"]);
            return;
        }
        $_a3d82c5df38e194c9c73e3ccb4223bbc = [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_618a4aeb9fecc4592a4521f348" . "76fa29"] => $_a9bf694098bca136cc65bf4d2623bc70->GetSenderAddress(), $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_376d30c40" . "857357a4d4" . "cbb1ffaa25" . "817"] => $_a9bf694098bca136cc65bf4d2623bc70->GetRecipientAddress(), $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_f656816961e857380" . "6141c558b184fe2"] => $_f656816961e8573806141c558b184fe2, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_ced92d7" . "b391285c" . "8a26846f" . "1f4bd312" . "8"] => $_a9bf694098bca136cc65bf4d2623bc70->GetBodyText(), $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_bfda889b74ea561b14325e30e7d754" . "26"] => $_a9bf694098bca136cc65bf4d2623bc70->GetBodyHtml(), $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_67a0d624aebcceb0abd5ce56a53ff0" . "6f"] => $_a9bf694098bca136cc65bf4d2623bc70->GetDate()];
        try {
            $this->process_email_use_case->ProcessEmail($project, $_a3d82c5df38e194c9c73e3ccb4223bbc, $_a9bf694098bca136cc65bf4d2623bc70->GetAttachments());
        } catch (Exception $_c35473364fa7a050299058f332ec29c1) {
            $this->logger->warning($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_460e1aeb3113a1676ce59a8f40431" . "d5c"], [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["project" . "_id"] => $project->GetId(), $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_a3d82c5df38e194" . "c9c73e3ccb4223bb" . "c"] => $_a3d82c5df38e194c9c73e3ccb4223bbc, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_c35473364fa7a050299058" . "f332ec29c1"] => $_c35473364fa7a050299058f332ec29c1]);
        }
    }
}