Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/Controller/Api/MailArchiveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,45 @@ public function __construct(
) {
}

#[Route(path: '/api/_action/frosh-mail-archive/fetch-eml-headers', name: 'api.action.frosh-mail-archive.fetch-eml-headers')]
public function fetchEmlHeaders(Request $request, Context $context): JsonResponse
{
$mailId = $request->request->get('mailId');

if (!\is_string($mailId)) {
throw MailArchiveException::parameterMissing('mailId');
}

$mailArchive = $this->froshMailArchiveRepository->search(new Criteria([$mailId]), $context)->first();
if (!$mailArchive instanceof MailArchiveEntity) {
throw MailArchiveException::notFound();
}

$mainRequest = $this->requestStack->getMainRequest();
if (!$mainRequest instanceof Request) {
throw new \RuntimeException('Cannot get mainRequest');
}

$mainRequest->attributes->set(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_ID, $mailArchive->getSalesChannelId());

$emlPath = $mailArchive->getEmlPath();
if ($emlPath === null) {
return new JsonResponse([]);
}

$emlMessage = $this->emlFileManager->getEmlAsMessage($emlPath);
if ($emlMessage === false) {
return new JsonResponse([]);
}

$headers = [];
foreach ($emlMessage->getAllHeaders() as $header) {
$headers[$header->getName()] = $header->getValue();
}

return new JsonResponse($headers);
}

#[Route(path: '/api/_action/frosh-mail-archive/resend-mail', name: 'api.action.frosh-mail-archive.resend-mail')]
public function resend(Request $request, Context $context): JsonResponse
{
Expand Down
19 changes: 19 additions & 0 deletions src/Resources/app/administration/src/init/api_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ class ApiClient extends ApiService {
super(httpClient, loginService, apiEndpoint);
}

fetchEmlHeaders(mailId) {
const headers = this.getBasicHeaders({});

return this.httpClient
.post(
`_action/${this.getApiBasePath()}/fetch-eml-headers`,
{
mailId,
},
{
...this.basicConfig,
headers,
}
)
.then((response) => {
return ApiService.handleResponse(response);
});
}

resendMail(mailId) {
const headers = this.getBasicHeaders({});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
</dt>
<dd>{{ archive.subject }}</dd>
</sw-description-list>
<sw-description-list>
<dt>
{{ $tc('frosh-mail-archive.detail.metadata.cc') }}
</dt>
<dd>{{ emlHeaders.Cc ?? '-' }}</dd>
</sw-description-list>
<sw-description-list>
<dt>
{{ $tc('frosh-mail-archive.detail.metadata.bcc') }}
</dt>
<dd>{{ emlHeaders.Bcc ?? '-' }}</dd>
</sw-description-list>
<sw-description-list>
<dt>
{{ $tc('frosh-mail-archive.detail.metadata.sentDate') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Component.register('frosh-mail-archive-detail', {
data() {
return {
archive: null,
emlHeaders: {},
resendIsLoading: false,
resendIsSuccessful: false,
downloadIsLoading: false,
Expand Down Expand Up @@ -122,6 +123,12 @@ Component.register('frosh-mail-archive-detail', {
.then((archive) => {
this.archive = archive;
});

this.froshMailArchiveService
.fetchEmlHeaders(this.archiveId)
.then((headers) => {
this.emlHeaders = headers;
});
},
getContent(html) {
const binary = new TextEncoder().encode(html);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"sentDate": "Versanddatum",
"sender": "Absender",
"receiver": "Empfänger",
"cc": "CC",
"bcc": "BCC",
"subject": "Betreff",
"salesChannel": "Verkaufskanal",
"customer": "Kunde",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"sentDate": "Sent date",
"sender": "Sender",
"receiver": "Recipients",
"cc": "CC",
"bcc": "BCC",
"subject": "Subject",
"salesChannel": "Sales Channel",
"customer": "Customer",
Expand Down