Differential D14219 Diff 34352 src/applications/metamta/garbagecollector/MetaMTAMailSentGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/garbagecollector/MetaMTAMailSentGarbageCollector.php
| <?php | <?php | ||||
| final class MetaMTAMailSentGarbageCollector | final class MetaMTAMailSentGarbageCollector | ||||
| extends PhabricatorGarbageCollector { | extends PhabricatorGarbageCollector { | ||||
| const COLLECTORCONST = 'metamta.sent'; | const COLLECTORCONST = 'metamta.sent'; | ||||
| public function getCollectorName() { | public function getCollectorName() { | ||||
| return pht('Mail (Sent)'); | return pht('Mail (Sent)'); | ||||
| } | } | ||||
| public function getDefaultRetentionPolicy() { | public function getDefaultRetentionPolicy() { | ||||
| return phutil_units('90 days in seconds'); | return phutil_units('90 days in seconds'); | ||||
| } | } | ||||
| public function collectGarbage() { | protected function collectGarbage() { | ||||
| $ttl = phutil_units('90 days in seconds'); | |||||
| $mails = id(new PhabricatorMetaMTAMail())->loadAllWhere( | $mails = id(new PhabricatorMetaMTAMail())->loadAllWhere( | ||||
| 'dateCreated < %d LIMIT 100', | 'dateCreated < %d LIMIT 100', | ||||
| PhabricatorTime::getNow() - $ttl); | $this->getGarbageEpoch()); | ||||
| foreach ($mails as $mail) { | foreach ($mails as $mail) { | ||||
| $mail->delete(); | $mail->delete(); | ||||
| } | } | ||||
| return (count($mails) == 100); | return (count($mails) == 100); | ||||
| } | } | ||||
| } | } | ||||