|
|
@@ -10,23 +10,17 @@ use Symfony\Component\DependencyInjection\Attribute\Target;
|
|
10
|
10
|
use Symfony\Component\Filesystem\Filesystem;
|
|
11
|
11
|
use Symfony\Component\Filesystem\Path;
|
|
12
|
12
|
use App\Presentation\PortfolioPresenter as PresentationPortfolio;
|
|
13
|
|
-use Symfony\Component\Notifier\Bridge\Telegram\TelegramOptions;
|
|
14
|
|
-use Symfony\Component\Notifier\Bridge\Telegram\TelegramTransport;
|
|
15
|
|
-use Symfony\Component\Notifier\Chatter;
|
|
16
|
|
-use Symfony\Component\Notifier\Message\ChatMessage;
|
|
17
|
|
-use Symfony\Component\Notifier\Notifier;
|
|
18
|
|
-use Symfony\Component\Notifier\NotifierInterface;
|
|
19
|
13
|
use App\Service\TelegramNotifier;
|
|
20
|
14
|
|
|
21
|
15
|
readonly class MailFetcher
|
|
22
|
16
|
{
|
|
23
|
17
|
public function __construct(
|
|
24
|
18
|
#[Target('finfollowConnection')]
|
|
25
|
|
- private ConnectionInterface $connection,
|
|
26
|
|
- private XmlParser $xmlParser,
|
|
27
|
|
- private PortfolioManager $portfolioManager,
|
|
28
|
|
- private LoggerInterface $logger,
|
|
29
|
|
- private TelegramNotifier $telegramNotifier,
|
|
|
19
|
+ private ConnectionInterface $connection,
|
|
|
20
|
+ private XmlParser $xmlParser,
|
|
|
21
|
+ private PortfolioManager $portfolioManager,
|
|
|
22
|
+ private LoggerInterface $logger,
|
|
|
23
|
+ private TelegramNotifier $telegramNotifier,
|
|
30
|
24
|
)
|
|
31
|
25
|
{
|
|
32
|
26
|
}
|
|
|
@@ -46,13 +40,13 @@ readonly class MailFetcher
|
|
46
|
40
|
if (!$mailsIds) {
|
|
47
|
41
|
$this->logger->info('Mailbox is empty');
|
|
48
|
42
|
|
|
49
|
|
- $this->logger->warn("Here we should send info about no changes performed..");
|
|
|
43
|
+ $this->logger->warning("Here we should send info about no changes performed..");
|
|
50
|
44
|
|
|
51
|
45
|
return;
|
|
52
|
46
|
}
|
|
53
|
47
|
|
|
54
|
|
-// If '__DIR__' was defined in the first line, it will automatically
|
|
55
|
|
-// save all attachments to the specified directory
|
|
|
48
|
+ // If '__DIR__' was defined in the first line, it will automatically
|
|
|
49
|
+ // save all attachments to the specified directory
|
|
56
|
50
|
|
|
57
|
51
|
foreach ($mailsIds as $mailId) {
|
|
58
|
52
|
$mail = $mailbox->getMail($mailId);
|
|
|
@@ -72,7 +66,7 @@ readonly class MailFetcher
|
|
72
|
66
|
|
|
73
|
67
|
}
|
|
74
|
68
|
|
|
75
|
|
- //$mailbox->deleteMail($mailId);
|
|
|
69
|
+ $mailbox->deleteMail($mailId);
|
|
76
|
70
|
$this->logger->debug("Deleted email with id=" . $mailId);
|
|
77
|
71
|
} else {
|
|
78
|
72
|
$this->logger->debug("Skipped mail with id=" . $mailId);
|
|
|
@@ -141,8 +135,8 @@ readonly class MailFetcher
|
|
141
|
135
|
$parsedPortfolio = $this->xmlParser->processXml($xml);
|
|
142
|
136
|
$message = PresentationPortfolio::toPrint($parsedPortfolio);
|
|
143
|
137
|
|
|
144
|
|
- if ($this->portfolioManager->updatePortfolio($parsedPortfolio, $xmlString)) {
|
|
145
|
|
- $this->telegramNotifier->notify($message);
|
|
|
138
|
+ if ($this->portfolioManager->updatePortfolio($parsedPortfolio, $xmlString)) {
|
|
|
139
|
+ $this->telegramNotifier->notify('<pre>' . $message . '</pre>');
|
|
146
|
140
|
}
|
|
147
|
141
|
|
|
148
|
142
|
$fs = new Filesystem();
|