mirror of
https://github.com/Karaka-Management/oms-Monitoring.git
synced 2026-02-02 18:58:40 +00:00
make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ...
This commit is contained in:
parent
cfc5de9d4f
commit
2398a78105
35
Admin/Install/Workflow.install.json
Executable file
35
Admin/Install/Workflow.install.json
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"triggers": [
|
||||
],
|
||||
"actions": {
|
||||
"1000700001": {
|
||||
"name": "Error report",
|
||||
"description": {
|
||||
"en": "Send error report",
|
||||
"de": "Versende Fehlerbericht"
|
||||
},
|
||||
"function_type": "Cli",
|
||||
"function": "cliLogReport",
|
||||
"module": "Monitoring",
|
||||
"inputs": [
|
||||
"email",
|
||||
"{*}"
|
||||
],
|
||||
"outputs": [
|
||||
"resources[]",
|
||||
"{*}"
|
||||
],
|
||||
"settings": {
|
||||
"email": {
|
||||
"type": "input",
|
||||
"subtype": "text",
|
||||
"default": null,
|
||||
"title": {
|
||||
"en": "Email",
|
||||
"de": "Email"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Admin/Install/Workflow.php
Executable file
43
Admin/Install/Workflow.php
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Monitoring\Admin\Install
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Monitoring\Admin\Install;
|
||||
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
|
||||
/**
|
||||
* Workflow class.
|
||||
*
|
||||
* @package Modules\Monitoring\Admin\Install
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Workflow
|
||||
{
|
||||
/**
|
||||
* Install workflow providing
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param string $path Module path
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function install(ApplicationAbstract $app, string $path) : void
|
||||
{
|
||||
\Modules\Workflow\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Workflow.install.json']);
|
||||
}
|
||||
}
|
||||
|
|
@ -47,45 +47,34 @@ final class CliController extends Controller
|
|||
*/
|
||||
public function cliLogReport(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
|
||||
{
|
||||
//return new NullView();
|
||||
$handler = $this->app->moduleManager->get('Admin', 'Api')->setUpServerMailHandler();
|
||||
|
||||
/** @var \Model\Setting[] $emailSettings */
|
||||
$emailSettings = $this->app->appSettings->get(
|
||||
names: [
|
||||
SettingsEnum::MAIL_SERVER_ADDR,
|
||||
SettingsEnum::MAIL_SERVER_CERT,
|
||||
SettingsEnum::MAIL_SERVER_KEY,
|
||||
SettingsEnum::MAIL_SERVER_KEYPASS,
|
||||
SettingsEnum::MAIL_SERVER_TLS,
|
||||
],
|
||||
module: 'Admin'
|
||||
names: SettingsEnum::MAIL_SERVER_ADDR,
|
||||
module: 'OnlineResourceWatcher'
|
||||
);
|
||||
|
||||
/** @var \Modules\Admin\Models\Account $account */
|
||||
$account = AccountMapper::get()->where('id', 1)->execute();
|
||||
$today = new \DateTime('now');
|
||||
|
||||
/** @var \phpOMS\Message\Mail\MailHandler $mailHandler */
|
||||
$mailHandler = $this->app->moduleManager->get('Admin', 'Api')->setUpServerMailHandler();
|
||||
$hasErrorReport = \is_file($file = __DIR__ . '/../../../Logs/' . $today->format('Y-m-d') . '.log');
|
||||
|
||||
// @todo: define report email template
|
||||
$mail = new Email();
|
||||
$mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content, 'Karaka');
|
||||
$mail->addTo($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content, \trim($account->name1 . ' ' . $account->name2 . ' ' . $account->name3));
|
||||
$mail->subject = 'Log report';
|
||||
$mail->body = '';
|
||||
$mail->msgHTML('Attached please find the daily log report');
|
||||
$mail->addAttachment(__DIR__ . '/../../../humans.txt');
|
||||
$mail->setFrom($emailSettings->content);
|
||||
$mail->addTo($emailSettings->content);
|
||||
$mail->subject = 'Error report';
|
||||
|
||||
if (!empty($emailSettings[SettingsEnum::MAIL_SERVER_CERT]->content ?? '')
|
||||
&& !empty($emailSettings[SettingsEnum::MAIL_SERVER_KEY]->content ?? '')
|
||||
) {
|
||||
$mail->sign(
|
||||
$emailSettings[SettingsEnum::MAIL_SERVER_CERT]->content,
|
||||
$emailSettings[SettingsEnum::MAIL_SERVER_KEY]->content,
|
||||
$emailSettings[SettingsEnum::MAIL_SERVER_KEYPASS]->content
|
||||
);
|
||||
if ($hasErrorReport) {
|
||||
$mail->body = 'Your daily Error report.';
|
||||
$mail->bodyAlt = 'Your daily Error report.';
|
||||
|
||||
$mail->addAttachment($file);
|
||||
} else {
|
||||
$mail->body = 'No errors today.';
|
||||
$mail->bodyAlt = 'No errors today.';
|
||||
}
|
||||
|
||||
$mailHandler->send($mail);
|
||||
$handler->send($mail);
|
||||
|
||||
return new NullView();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user