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) {
$destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref;
if (!dol_is_dir($destdir)) {
dol_mkdir($destdir);
}
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
$destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref; foreach ($attachments as $attachment) {
if (!dol_is_dir($destdir)) { $attachment->save($destdir.'/');
return -1;
dol_mkdir($destdir);
$this->getmsg($connection, $imapemail, $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

@ -16,24 +16,24 @@ class ComposerStaticInit4da13270269c89a28e472e1f7324e6d1
); );
public static $prefixLengthsPsr4 = array ( public static $prefixLengthsPsr4 = array (
'v' => 'v' =>
array ( array (
'voku\\' => 5, 'voku\\' => 5,
), ),
'p' => 'p' =>
array ( array (
'phpDocumentor\\Reflection\\' => 25, 'phpDocumentor\\Reflection\\' => 25,
), ),
'W' => 'W' =>
array ( array (
'Webmozart\\Assert\\' => 17, 'Webmozart\\Assert\\' => 17,
'Webklex\\PHPIMAP\\' => 16, 'Webklex\\PHPIMAP\\' => 16,
), ),
'T' => 'T' =>
array ( array (
'Tests\\' => 6, // 'Tests\\' => 6,
), ),
'S' => 'S' =>
array ( array (
'Symfony\\Polyfill\\Php80\\' => 23, 'Symfony\\Polyfill\\Php80\\' => 23,
'Symfony\\Polyfill\\Mbstring\\' => 26, 'Symfony\\Polyfill\\Mbstring\\' => 26,
@ -43,115 +43,115 @@ class ComposerStaticInit4da13270269c89a28e472e1f7324e6d1
'Symfony\\Component\\Translation\\' => 30, 'Symfony\\Component\\Translation\\' => 30,
'Symfony\\Component\\HttpFoundation\\' => 33, 'Symfony\\Component\\HttpFoundation\\' => 33,
), ),
'P' => 'P' =>
array ( array (
'Psr\\SimpleCache\\' => 16, 'Psr\\SimpleCache\\' => 16,
'Psr\\Container\\' => 14, 'Psr\\Container\\' => 14,
'Prophecy\\' => 9, 'Prophecy\\' => 9,
), ),
'I' => 'I' =>
array ( array (
'Illuminate\\Support\\' => 19, 'Illuminate\\Support\\' => 19,
'Illuminate\\Pagination\\' => 22, 'Illuminate\\Pagination\\' => 22,
'Illuminate\\Contracts\\' => 21, 'Illuminate\\Contracts\\' => 21,
), ),
'D' => 'D' =>
array ( array (
'Doctrine\\Instantiator\\' => 22, 'Doctrine\\Instantiator\\' => 22,
'Doctrine\\Inflector\\' => 19, 'Doctrine\\Inflector\\' => 19,
), ),
'C' => 'C' =>
array ( array (
'Carbon\\' => 7, 'Carbon\\' => 7,
), ),
); );
public static $prefixDirsPsr4 = array ( public static $prefixDirsPsr4 = array (
'voku\\' => 'voku\\' =>
array ( array (
0 => __DIR__ . '/..' . '/voku/portable-ascii/src/voku', 0 => __DIR__ . '/..' . '/voku/portable-ascii/src/voku',
), ),
'phpDocumentor\\Reflection\\' => 'phpDocumentor\\Reflection\\' =>
array ( array (
0 => __DIR__ . '/..' . '/phpdocumentor/reflection-common/src', 0 => __DIR__ . '/..' . '/phpdocumentor/reflection-common/src',
1 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src', 1 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src',
2 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src', 2 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src',
), ),
'Webmozart\\Assert\\' => 'Webmozart\\Assert\\' =>
array ( array (
0 => __DIR__ . '/..' . '/webmozart/assert/src', 0 => __DIR__ . '/..' . '/webmozart/assert/src',
), ),
'Webklex\\PHPIMAP\\' => 'Webklex\\PHPIMAP\\' =>
array ( array (
0 => __DIR__ . '/../..' . '/src', 0 => __DIR__ . '/../..' . '/src',
), ),
'Tests\\' => 'Tests\\' =>
array ( array (
0 => __DIR__ . '/../..' . '/tests', 0 => __DIR__ . '/../..' . '/tests',
), ),
'Symfony\\Polyfill\\Php80\\' => 'Symfony\\Polyfill\\Php80\\' =>
array ( array (
0 => __DIR__ . '/..' . '/symfony/polyfill-php80', 0 => __DIR__ . '/..' . '/symfony/polyfill-php80',
), ),
'Symfony\\Polyfill\\Mbstring\\' => 'Symfony\\Polyfill\\Mbstring\\' =>
array ( array (
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
), ),
'Symfony\\Polyfill\\Ctype\\' => 'Symfony\\Polyfill\\Ctype\\' =>
array ( array (
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
), ),
'Symfony\\Contracts\\Translation\\' => 'Symfony\\Contracts\\Translation\\' =>
array ( array (
0 => __DIR__ . '/..' . '/symfony/translation-contracts', 0 => __DIR__ . '/..' . '/symfony/translation-contracts',
), ),
'Symfony\\Component\\Yaml\\' => 'Symfony\\Component\\Yaml\\' =>
array ( array (
0 => __DIR__ . '/..' . '/symfony/yaml', 0 => __DIR__ . '/..' . '/symfony/yaml',
), ),
'Symfony\\Component\\Translation\\' => 'Symfony\\Component\\Translation\\' =>
array ( array (
0 => __DIR__ . '/..' . '/symfony/translation', 0 => __DIR__ . '/..' . '/symfony/translation',
), ),
'Symfony\\Component\\HttpFoundation\\' => 'Symfony\\Component\\HttpFoundation\\' =>
array ( array (
0 => __DIR__ . '/..' . '/symfony/http-foundation', 0 => __DIR__ . '/..' . '/symfony/http-foundation',
), ),
'Psr\\SimpleCache\\' => 'Psr\\SimpleCache\\' =>
array ( array (
0 => __DIR__ . '/..' . '/psr/simple-cache/src', 0 => __DIR__ . '/..' . '/psr/simple-cache/src',
), ),
'Psr\\Container\\' => 'Psr\\Container\\' =>
array ( array (
0 => __DIR__ . '/..' . '/psr/container/src', 0 => __DIR__ . '/..' . '/psr/container/src',
), ),
'Prophecy\\' => 'Prophecy\\' =>
array ( array (
0 => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy', 0 => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy',
), ),
'Illuminate\\Support\\' => 'Illuminate\\Support\\' =>
array ( array (
0 => __DIR__ . '/..' . '/illuminate/macroable', 0 => __DIR__ . '/..' . '/illuminate/macroable',
1 => __DIR__ . '/..' . '/illuminate/collections', 1 => __DIR__ . '/..' . '/illuminate/collections',
2 => __DIR__ . '/..' . '/illuminate/support', 2 => __DIR__ . '/..' . '/illuminate/support',
), ),
'Illuminate\\Pagination\\' => 'Illuminate\\Pagination\\' =>
array ( array (
0 => __DIR__ . '/..' . '/illuminate/pagination', 0 => __DIR__ . '/..' . '/illuminate/pagination',
), ),
'Illuminate\\Contracts\\' => 'Illuminate\\Contracts\\' =>
array ( array (
0 => __DIR__ . '/..' . '/illuminate/contracts', 0 => __DIR__ . '/..' . '/illuminate/contracts',
), ),
'Doctrine\\Instantiator\\' => 'Doctrine\\Instantiator\\' =>
array ( array (
0 => __DIR__ . '/..' . '/doctrine/instantiator/src/Doctrine/Instantiator', 0 => __DIR__ . '/..' . '/doctrine/instantiator/src/Doctrine/Instantiator',
), ),
'Doctrine\\Inflector\\' => 'Doctrine\\Inflector\\' =>
array ( array (
0 => __DIR__ . '/..' . '/doctrine/inflector/lib/Doctrine/Inflector', 0 => __DIR__ . '/..' . '/doctrine/inflector/lib/Doctrine/Inflector',
), ),
'Carbon\\' => 'Carbon\\' =>
array ( array (
0 => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon', 0 => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon',
), ),