Merge pull request #21869 from fboitel/imap-by-oauth2-attachment

Imap by oauth2 attachments
This commit is contained in:
Laurent Destailleur 2022-08-26 18:36:19 +02:00 committed by GitHub
commit 3c5c067d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 37 deletions

View File

@ -1582,7 +1582,9 @@ class EmailCollector extends CommonObject
$plainmsg = $imapemail->getTextBody(); $plainmsg = $imapemail->getTextBody();
} }
if ($imapemail->hasAttachments()) { if ($imapemail->hasAttachments()) {
$attachments = $imapemail->getAttachments(); $attachments = $imapemail->getAttachments()->all();
} else {
$attachments = [];
} }
} else { } else {
$this->getmsg($connection, $imapemail); $this->getmsg($connection, $imapemail);
@ -2440,6 +2442,20 @@ class EmailCollector extends CommonObject
$errorforactions++; $errorforactions++;
$this->error = 'Failed to create project: '.$langs->trans($projecttocreate->error); $this->error = 'Failed to create project: '.$langs->trans($projecttocreate->error);
$this->errors = $projecttocreate->errors; $this->errors = $projecttocreate->errors;
} else {
if ($attachments) {
$destdir = $conf->project->dir_output.'/'.$projecttocreate->ref;
if (!dol_is_dir($destdir)) {
dol_mkdir($destdir);
}
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
foreach ($attachments as $attachment) {
$attachment->save($destdir.'/');
}
} else {
$this->getmsg($connection, $imapemail, $destdir);
}
}
} }
} }
} }
@ -2550,13 +2566,16 @@ class EmailCollector extends CommonObject
$this->errors = $tickettocreate->errors; $this->errors = $tickettocreate->errors;
} else { } else {
if ($attachments) { if ($attachments) {
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
$destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref; $destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref;
if (!dol_is_dir($destdir)) { if (!dol_is_dir($destdir)) {
return -1;
dol_mkdir($destdir); dol_mkdir($destdir);
$this->getmsg($connection, $imapemail, $destdir);
} }
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
foreach ($attachments as $attachment) {
$attachment->save($destdir.'/');
}
} else {
$this->getmsg($connection, $imapemail, $destdir);
} }
} }
} }

View File

@ -13,4 +13,5 @@
./vendor/phpdocumentor ./vendor/phpdocumentor
./vendor/nesbot/carbon/src/Carbon/Lang ./vendor/nesbot/carbon/src/Carbon/Lang
./vendor/doctrine ./vendor/doctrine
./vendor/bin
./tests ./tests

View File

@ -31,7 +31,7 @@ class ComposerStaticInit4da13270269c89a28e472e1f7324e6d1
), ),
'T' => 'T' =>
array ( array (
'Tests\\' => 6, // 'Tests\\' => 6,
), ),
'S' => 'S' =>
array ( array (