diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-09-27 12:49:24 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-09-27 12:49:24 +0300 |
commit | fad243572b9813eebba064cddedf18c459c8c267 (patch) | |
tree | 776d66baeb1c719e4ce4508516ff3a0d0ab60db0 /lib/Controller/MessagesController.php | |
parent | 84be01906af0e494d94761d88cdfeafcfc19d0d6 (diff) |
Include the HTML body in the JSON message data
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Controller/MessagesController.php')
-rwxr-xr-x | lib/Controller/MessagesController.php | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php index e2b291b9c..d00063427 100755 --- a/lib/Controller/MessagesController.php +++ b/lib/Controller/MessagesController.php @@ -40,7 +40,6 @@ use OCA\Mail\Model\IMAPMessage; use OCA\Mail\Service\AccountService; use OCA\Mail\Service\IMailBox; use OCP\AppFramework\Controller; -use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\JSONResponse; @@ -168,12 +167,19 @@ class MessagesController extends Controller { return new JSONResponse(null, Http::STATUS_FORBIDDEN); } - $json = $this->mailManager->getMessage($account, base64_decode($folderId), $id, true)->getFullMessage(); - if (isset($json['attachments'])) { - $json['attachments'] = array_map(function ($a) use ($accountId, $folderId, $id) { - return $this->enrichDownloadUrl($accountId, $folderId, $id, $a); - }, $json['attachments']); - } + $json = $this->mailManager->getMessage( + $account, + base64_decode($folderId), + $id, + true + )->getFullMessage( + $accountId, + base64_decode($folderId), + $id + ); + $json['attachments'] = array_map(function ($a) use ($accountId, $folderId, $id) { + return $this->enrichDownloadUrl($accountId, $folderId, $id, $a); + }, $json['attachments']); return new JSONResponse($json); } @@ -222,27 +228,14 @@ class MessagesController extends Controller { ); } - /** @var IMAPMessage $m */ - $m = $this->mailManager->getMessage( - $account, - base64_decode($folderId), - $messageId, - true + $htmlResponse = new HtmlResponse( + $this->mailManager->getMessage( + $account, + base64_decode($folderId), + $messageId, + true + )->getHtmlBody($accountId, $folderId, $messageId) ); - $html = $m->getHtmlBody($accountId, $folderId, $messageId, - function ($cid) use ($m) { - $match = array_filter($m->attachments, - function ($a) use ($cid) { - return $a['cid'] === $cid; - }); - $match = array_shift($match); - if ($match === null) { - return null; - } - return $match['id']; - }); - - $htmlResponse = new HtmlResponse($html); // Harden the default security policy $policy = new ContentSecurityPolicy(); |