Lines
100.00%
26 / 26
Methods
100.00%
2 / 2
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| readResponse | 100.00% | 23 / 23 | 100.00% | 1 / 1 | 2 | ||
| [BO\Zmsbackend\Api\BaseController] __invoke | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | ||
| 16 | class ProcessAddLog extends \BO\Zmsbackend\Api\BaseController | |
| 17 | { | |
| 18 | /** | |
| 19 | * @SuppressWarnings(Param) | |
| 20 | * @return \Psr\Http\Message\ResponseInterface | |
| 21 | */ | |
| 22 | #[\Override] | |
| 23 | public function readResponse( | |
| 24 | \Psr\Http\Message\RequestInterface $request, | |
| 25 | \Psr\Http\Message\ResponseInterface $response, | |
| 26 | array $args | |
| 27 | ) { | |
| 28 | (new \BO\Zmsbackend\Helper\User($request))->checkPermissions('superuser'); | |
| 29 | ||
| 30 | $processId = Validator::value($args['id'])->isNumber()->getValue(); | |
| 31 | ||
| 32 | /** @var ProcessEntity $process */ | |
| 33 | $process = (new \BO\Zmsbackend\Process\Service\Process())->readById($processId); | |
| 34 | $input = Validator::input()->isJson()->assertValid()->getValue(); | |
| 35 | $mimepart = new \BO\Zmsentities\Mimepart($input); | |
| 36 | $mimepart->testValid(); | |
| 37 | ||
| 38 | $isError = Validator::param('error')->isNumber()->setDefault(0)->getValue(); | |
| 39 | if ($isError) { | |
| 40 | Query::writeProcessLog( | |
| 41 | "MTA failed, message=" . $mimepart->content, | |
| 42 | Query::ACTION_MAIL_FAIL, | |
| 43 | $process | |
| 44 | ); | |
| 45 | } else { | |
| 46 | Query::writeProcessLog( | |
| 47 | "MTA successful, subject=" . $mimepart->content, | |
| 48 | Query::ACTION_MAIL_SUCCESS, | |
| 49 | $process | |
| 50 | ); | |
| 51 | } | |
| 52 | ||
| 53 | $message = \BO\Zmsbackend\Api\Response\Message::create($request); | |
| 54 | $message->data = $mimepart; | |
| 55 | ||
| 56 | $response = Render::withLastModified($response, time(), '0'); | |
| 57 | $response = Render::withJson($response, $message, 200); | |
| 58 | return $response; | |
| 59 | } | |
| 60 | } |
Inherited from BO\Zmsbackend\Api\BaseController
| 20 | public function __invoke(RequestInterface $request, ResponseInterface $response, array $args) | |
| 21 | { | |
| 22 | $request = $this->initRequest($request); | |
| 23 | $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0'); | |
| 24 | return $this->readResponse($request, $noCacheResponse, $args); | |
| 25 | } |