This commit is contained in:
Yuri Kuznetsov
2014-08-27 17:56:37 +03:00
parent 272bccc2fd
commit da677cfae8
4 changed files with 12 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ class Importer
return $this->entityManager;
}
protected function importMessage($message, $userId, $teamsIds = array())
public function importMessage($message, $userId, $teamsIds = array())
{
try {
$email = $this->getEntityManager()->getEntity('Email');
@@ -82,9 +82,9 @@ class Importer
protected function checkIsDuplicate($email)
{
if ($email->has('messageIdInternal')) {
if ($email->get('messageIdInternal')) {
$duplicate = $this->getEntityManager()->getRepository('Email')->where(array(
'messageIdInternal' => $email->has('messageIdInternal')
'messageIdInternal' => $email->get('messageIdInternal')
))->findOne();
if ($duplicate) {
return true;

View File

@@ -183,7 +183,7 @@ class InboundEmail extends \Espo\Services\Record
}
}
if ($k == self::PORTION - 1) {
if ($k == self::PORTION_LIMIT - 1) {
break;
}
$k++;

View File

@@ -54,12 +54,12 @@
},
"messageId": {
"type": "varchar",
"maxLength": 36,
"maxLength": 255,
"readOlny": true
},
"messageIdInternal": {
"type": "varchar",
"maxLength": 36,
"maxLength": 300,
"readOlny": true,
"index": true
},

View File

@@ -133,9 +133,9 @@ class EmailAccount extends Record
$ids = $storage->getIdsFromUID();
print_r($ids);
$k = 0;
foreach ($ids as $k => $id) {
foreach ($ids as $i => $id) {
$message = $storage->getMessage($id);
$importer->importMessage($message, $userId, array($teamId));
@@ -144,19 +144,18 @@ class EmailAccount extends Record
$lastUID = $storage->getUniqueId($id);
$lastDate = $message->date;
}
if ($k == self::PORTION - 1) {
if ($k == self::PORTION_LIMIT - 1) {
break;
}
$k++;
}
$fetchData['lastUID'][$folder] = $lastUID;
$fetchData['lastDate'][$folder] = $lastDate;
$emailAccount->set('fetchData', json_encode($fetchData));
$this->getEntityManager()->saveEntity($emailAccount);
print_r($fetchData);
$this->getEntityManager()->saveEntity($emailAccount);
}
return true;