ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier Class Reference
+ Collaboration diagram for ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier:

Public Member Functions

 __construct (private readonly ilMailCronOrphanedMails $job, private readonly NotificationsCollector $collector, private readonly int $mail_expiration_days, private readonly int $mail_expiration_warning_days, ?ilDBInterface $db=null, ?ClockInterface $clock=null)
 
 send ()
 

Private Member Functions

 markAsNotified (ReportDto $collection_obj)
 
 sendMail (ReportDto $collection_obj)
 

Private Attributes

const int NOTIFICATION_MARKER_PING_THRESHOLD = 250
 
const int MAIL_DELIVERY_PING_THRESHOLD = 25
 
readonly ilDBInterface $db
 
readonly ClockInterface $clock
 
readonly ilDBStatement $mark_as_notified_stmt
 

Detailed Description

Definition at line 31 of file Notifier.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier::__construct ( private readonly ilMailCronOrphanedMails  $job,
private readonly NotificationsCollector  $collector,
private readonly int  $mail_expiration_days,
private readonly int  $mail_expiration_warning_days,
?ilDBInterface  $db = null,
?ClockInterface  $clock = null 
)

Definition at line 40 of file Notifier.php.

References $DIC, and ilDBConstants\T_INTEGER.

47  {
48  global $DIC;
49 
50  $this->db = $db ?? $DIC->database();
51  $this->clock = $clock ?? (new Factory())->clock()->system();
52 
53  $this->mark_as_notified_stmt = $this->db->prepareManip(
54  'INSERT INTO mail_cron_orphaned (mail_id, folder_id, ts_do_delete) VALUES (?, ?, ?)',
56  );
57  }
global $DIC
Definition: shib_login.php:26

Member Function Documentation

◆ markAsNotified()

ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier::markAsNotified ( ReportDto  $collection_obj)
private

Definition at line 59 of file Notifier.php.

References ReportDto\getFolderObjects().

Referenced by ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier\send().

59  : void
60  {
61  $notify_days_before = 1;
62  if ($this->mail_expiration_days > $this->mail_expiration_warning_days) {
63  $notify_days_before = $this->mail_expiration_days - $this->mail_expiration_warning_days;
64  }
65 
66  $deletion_datetime = $this->clock->now()
67  ->modify('+ ' . $notify_days_before . ' days')
68  ->setTime(0, 0);
69 
70  $i = 0;
71  foreach ($collection_obj->getFolderObjects() as $folder_obj) {
72  $folder_id = $folder_obj->getFolderId();
73 
74  foreach ($folder_obj->getOrphanedMailObjects() as $mail_obj) {
75  $mail_id = $mail_obj->getMailId();
76 
77  if ($i > 0 && $i % self::NOTIFICATION_MARKER_PING_THRESHOLD === 0) {
78  $this->job->ping();
79  }
80 
81  $this->db->execute(
82  $this->mark_as_notified_stmt,
83  [$mail_id, $folder_id, $deletion_datetime->getTimestamp()]
84  );
85  $i++;
86  }
87  }
88  }
getFolderObjects()
Definition: ReportDto.php:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send()

ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier::send ( )

Definition at line 98 of file Notifier.php.

References ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier\markAsNotified(), and ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier\sendMail().

Referenced by ilMailCronOrphanedMails\processNotification().

98  : void
99  {
100  $i = 0;
101  foreach ($this->collector->getCollection() as $collection_obj) {
102  if ($i > 0 && $i % self::MAIL_DELIVERY_PING_THRESHOLD === 0) {
103  $this->job->ping();
104  }
105 
106  $this->sendMail($collection_obj);
107  $this->markAsNotified($collection_obj);
108  ++$i;
109  }
110  }
markAsNotified(ReportDto $collection_obj)
Definition: Notifier.php:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMail()

ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier::sendMail ( ReportDto  $collection_obj)
private

Definition at line 90 of file Notifier.php.

References ReportDto\getFolderObjects(), and ReportDto\getUserId().

Referenced by ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier\send().

90  : void
91  {
92  $mail = new MailNotification();
93  $mail->setRecipients([$collection_obj->getUserId()]);
94  $mail->setAdditionalInformation(['mail_folders' => $collection_obj->getFolderObjects()]);
95  $mail->send();
96  }
getFolderObjects()
Definition: ReportDto.php:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $clock

readonly ClockInterface ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier::$clock
private

Definition at line 37 of file Notifier.php.

◆ $db

readonly ilDBInterface ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier::$db
private

Definition at line 36 of file Notifier.php.

◆ $mark_as_notified_stmt

readonly ilDBStatement ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier::$mark_as_notified_stmt
private

Definition at line 38 of file Notifier.php.

◆ MAIL_DELIVERY_PING_THRESHOLD

const int ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier::MAIL_DELIVERY_PING_THRESHOLD = 25
private

Definition at line 34 of file Notifier.php.

◆ NOTIFICATION_MARKER_PING_THRESHOLD

const int ILIAS\Mail\Cron\ExpiredOrOrphanedMails\Notifier::NOTIFICATION_MARKER_PING_THRESHOLD = 250
private

Definition at line 33 of file Notifier.php.


The documentation for this class was generated from the following file: