Added Email Logging for Emailnotification class

This commit is contained in:
Frank Schubert
2025-08-22 17:49:54 +02:00
parent 866c3b2ae1
commit 3a86160b38
26 changed files with 1636 additions and 46 deletions
@@ -1041,6 +1041,9 @@ class PreorderController extends mfBaseController {
$data = [];
switch($do) {
case "getLoggedEmail":
$return = $this->getLoggedEmail();
break;
case "saveAttribute":
$return = $this->saveAttributeApi();
break;
@@ -1101,6 +1104,60 @@ class PreorderController extends mfBaseController {
}
}
protected function getLoggedEmail() {
$preorder_id = $this->request->pid;
$emaillog_id = $this->request->eid;
if(!is_numeric($preorder_id) || $preorder_id < 1) {
return false;
}
if(!is_numeric($emaillog_id) || $emaillog_id < 1) {
return false;
}
$preorder = new Preorder($preorder_id);
if(!$preorder->id) {
return false;
}
$emaillog = new EmailLog($emaillog_id);
if(!$emaillog->id) {
return false;
}
if($emaillog->object_type != "Preorder" || $emaillog->object_id != $preorder->id) {
return false;
}
$return = [
"preorder_id" => $preorder_id,
"emaillog_id" => $emaillog_id,
"from" => $emaillog->from,
"to" => $emaillog->to,
"subject" => $emaillog->subject,
"body" => ($emaillog->body_html) ? $emaillog->body_html : $emaillog->body_text,
"bodyIsHtml" => (bool) $emaillog->body_html,
"sent" => date("d.m.Y H:i", $emaillog->create),
"headers" => json_decode($emaillog->headers),
"attachments" => [],
];
if(is_array($emaillog->attachments) && count($emaillog->attachments)) {
foreach($emaillog->attachments as $attachment) {
$return["attachments"][] = [
"id" => $attachment->id,
"hash" => $attachment->content->sha256,
"filename" => $attachment->filename,
"filesize" => ($attachment->content) ? $attachment->content->filesize : 0,
"mimetype" => ($attachment->content) ? $attachment->content->mimetype : "",
];
}
}
return $return;
}
protected function saveBorderpointStatusApi() {
$preorder_id = $this->request->preorder_id;
$status_type = $this->request->status_type;