Remove file uploading from email polling
This commit is contained in:
parent
a4c44fb9ab
commit
673a92c196
|
@ -41,7 +41,7 @@ class EmailPollingController extends Controller {
|
||||||
|
|
||||||
$errors = [];
|
$errors = [];
|
||||||
$emails = $this->getLastEmails();
|
$emails = $this->getLastEmails();
|
||||||
/*
|
|
||||||
$session = Session::getInstance();
|
$session = Session::getInstance();
|
||||||
$oldSession = [
|
$oldSession = [
|
||||||
'userId' => $session->getUserId(),
|
'userId' => $session->getUserId(),
|
||||||
|
@ -70,9 +70,9 @@ class EmailPollingController extends Controller {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
if($email->getAttachement()) {
|
if($email->getAttachment()) {
|
||||||
$attachment = $email->getAttachement();
|
$attachment = $email->getAttachment();
|
||||||
$_FILES['file'] = [
|
$_FILES['file'] = [
|
||||||
'name' => $attachment->name,
|
'name' => $attachment->name,
|
||||||
'type' => mime_content_type($attachment->filePath),
|
'type' => mime_content_type($attachment->filePath),
|
||||||
|
@ -81,6 +81,7 @@ class EmailPollingController extends Controller {
|
||||||
'size' => filesize($attachment->filePath),
|
'size' => filesize($attachment->filePath),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if($email->isReply()) {
|
if($email->isReply()) {
|
||||||
|
@ -113,7 +114,7 @@ class EmailPollingController extends Controller {
|
||||||
Response::respondError(ERRORS::EMAIL_POLLING, null, $errors);
|
Response::respondError(ERRORS::EMAIL_POLLING, null, $errors);
|
||||||
} else {
|
} else {
|
||||||
Response::respondSuccess();
|
Response::respondSuccess();
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastEmails() {
|
public function getLastEmails() {
|
||||||
|
@ -124,15 +125,19 @@ class EmailPollingController extends Controller {
|
||||||
foreach($mailsIds as $mailId) {
|
foreach($mailsIds as $mailId) {
|
||||||
$mail = $this->mailbox->getMail($mailId);
|
$mail = $this->mailbox->getMail($mailId);
|
||||||
$mailHeader = $this->mailbox->getMailHeader($mailId);
|
$mailHeader = $this->mailbox->getMailHeader($mailId);
|
||||||
$mailAttachment = count($mail->getAttachments()) ? $mail->getAttachments()[0] : null;
|
// $mailAttachment = count($mail->getAttachments()) ? current($mail->getAttachments()) : null;
|
||||||
|
|
||||||
$emails[] = new Email([
|
$emails[] = new Email([
|
||||||
'fromAddress' => $mailHeader->fromAddress,
|
'fromAddress' => $mailHeader->fromAddress,
|
||||||
'fromName' => $mailHeader->fromName,
|
'fromName' => $mailHeader->fromName,
|
||||||
'subject' => $mailHeader->subject,
|
'subject' => $mailHeader->subject,
|
||||||
'content' => $mail->textPlain,
|
'content' => $mail->textPlain,
|
||||||
'file' => $mailAttachment,
|
'file' => null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
foreach($mail->getAttachments() as $attachment) {
|
||||||
|
unlink($attachment->filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $emails;
|
return $emails;
|
||||||
|
|
|
@ -134,7 +134,6 @@ abstract class Controller {
|
||||||
$fileUploader->setMaxSize($maxSize);
|
$fileUploader->setMaxSize($maxSize);
|
||||||
|
|
||||||
if($fileUploader->upload('file')) {
|
if($fileUploader->upload('file')) {
|
||||||
|
|
||||||
return $fileUploader;
|
return $fileUploader;
|
||||||
} else {
|
} else {
|
||||||
throw new RequestException(ERRORS::INVALID_FILE);
|
throw new RequestException(ERRORS::INVALID_FILE);
|
||||||
|
|
Loading…
Reference in New Issue