Contact Mails

This commit is contained in:
2021-04-09 16:05:36 +02:00
parent 2ae209f53b
commit 779550cab4
17 changed files with 324 additions and 59 deletions

24
cli.php
View File

@@ -1,6 +1,7 @@
<?php
include_once 'core/core.php';
require_once 'core/datetime.php';
include_once 'core/constants.php';
use Configuration\Configuration;
@@ -459,6 +460,26 @@ function onTest($argv) {
}
function onMail($argv) {
$action = $argv[2] ?? null;
if ($action === "sync") {
$user = getUser() or die();
if (!$user->getConfiguration()->getSettings()->isMailEnabled()) {
_exit("Mails are not configured yet.");
}
$req = new Api\Mail\Sync($user);
printLine("Syncing emails…");
if (!$req->execute()) {
_exit("Error syncing mails: " . $req->getLastError());
}
_exit("Done.");
} else {
_exit("Usage: cli.php mail <sync> [options...]");
}
}
$argv = $_SERVER['argv'];
if (count($argv) < 2) {
_exit("Usage: cli.php <db|routes|settings|maintenance> [options...]");
@@ -481,6 +502,9 @@ switch ($command) {
case 'test':
onTest($argv);
break;
case 'mail':
onMail($argv);
break;
default:
printLine("Unknown command '$command'");
printLine();