2022-03-19 00:00:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace brain\api\v1;
|
|
|
|
|
|
|
|
use brain\data\Session;
|
|
|
|
use brain\utility\Mailer;
|
|
|
|
|
|
|
|
class MailerAPI
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
}
|
2022-05-17 04:14:38 +02:00
|
|
|
|
2022-03-19 00:00:51 +01:00
|
|
|
public static function handleMail($request, $body, $response)
|
|
|
|
{
|
2022-04-14 23:46:17 +02:00
|
|
|
// if testing, verify session is active
|
|
|
|
// add clean method for sending programmtic emails
|
|
|
|
if ($body['mail_task'] == 'TESTING') {
|
2022-03-19 00:00:51 +01:00
|
|
|
if (Session::active()) {
|
|
|
|
$result = Mailer::sendmail($body);
|
|
|
|
} else {
|
|
|
|
$result = [
|
2022-05-17 02:41:15 +02:00
|
|
|
'message' => 'You need to be logged in for this, champ.',
|
|
|
|
'type' => 'MAILER_ERROR',
|
2022-03-19 00:00:51 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|