Browse Source

Switched to selected mailbox folder, customize target email subject and sender

master
Evgeniy Ierusalimov 12 hours ago
parent
commit
9905f0c32d
4 changed files with 15 additions and 2 deletions
  1. 3
    0
      .env
  2. 3
    0
      README.md
  3. 5
    0
      config/services.yaml
  4. 4
    2
      src/Service/MailFetcher.php

+ 3
- 0
.env View File

@@ -44,3 +44,6 @@ TELEGRAM_BOT_TOKEN=
44 44
 TELEGRAM_CHAT_ID=
45 45
 
46 46
 SECURITIES_MAP='{"RU000A1014L8":"LQDT", "RU000A107UL4":"T", "RU000A108X38":"X5"}'
47
+
48
+VALID_EMAIL_SUBJECT='Broker report'
49
+VALID_EMAIL_SENDER='@bcs.ru'

+ 3
- 0
README.md View File

@@ -10,3 +10,6 @@ NB:
10 10
 Do not forget to remove `var/imap/attachments/*.bin` files after
11 11
 
12 12
 Use .env:SECURITIES_MAP to substitute more human-readable titles instead of given ones
13
+
14
+IMAP Connection string for selected folder: IMAP_PATH={imap.yandex.ru:993/imap/ssl}BCS-robot
15
+

+ 5
- 0
config/services.yaml View File

@@ -37,3 +37,8 @@ services:
37 37
     App\Presentation\PortfolioPresenter:
38 38
         arguments:
39 39
             $securitiesMap: '%securitiesMap%'
40
+
41
+    App\Service\MailFetcher:
42
+        arguments:
43
+            $validEmailSubject: '%env(VALID_EMAIL_SUBJECT)%'
44
+            $validEmailSender: '%env(VALID_EMAIL_SENDER)%'

+ 4
- 2
src/Service/MailFetcher.php View File

@@ -22,6 +22,8 @@ readonly class MailFetcher
22 22
         private LoggerInterface     $logger,
23 23
         private TelegramNotifier    $telegramNotifier,
24 24
         private PortfolioPresenter  $portfolioPresenter,
25
+        private string              $validEmailSubject,
26
+        private string              $validEmailSender,
25 27
     )
26 28
     {
27 29
     }
@@ -80,11 +82,11 @@ readonly class MailFetcher
80 82
             return false;
81 83
         }
82 84
 
83
-        if (mb_stripos($mail->subject, 'Broker report') === false) {
85
+        if (mb_stripos($mail->subject, $this->validEmailSubject) === false) {
84 86
             return false;
85 87
         }
86 88
 
87
-        if (mb_stripos($mail->fromAddress, '@bcs.ru') === false) {
89
+        if (mb_stripos($mail->fromAddress, $this->validEmailSender) === false) {
88 90
             return false;
89 91
         }
90 92
 

Loading…
Cancel
Save