f7cloud_client/apps/mail/lib/Service/PhishingDetection/DateCheck.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

39 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Mail\Service\PhishingDetection;
use OCA\Mail\PhishingDetectionResult;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IL10N;
class DateCheck {
protected IL10N $l10n;
protected ITimeFactory $timeFactory;
public function __construct(IL10N $l10n, ITimeFactory $timeFactory) {
$this->l10n = $l10n;
$this->timeFactory = $timeFactory;
}
public function run(string $date): PhishingDetectionResult {
$now = $this->timeFactory->getDateTime('now');
try {
$dt = $this->timeFactory->getDateTime($date);
} catch (\Exception $e) {
return new PhishingDetectionResult(PhishingDetectionResult::DATE_CHECK, false);
}
if ($dt > $now) {
return new PhishingDetectionResult(PhishingDetectionResult::DATE_CHECK, true, $this->l10n->t('Sent date is in the future'));
}
return new PhishingDetectionResult(PhishingDetectionResult::DATE_CHECK, false);
}
}