...
|
...
|
@@ -45,7 +45,7 @@ class SyncMailToEs { |
|
|
public $es;
|
|
|
|
|
|
public function handler(){
|
|
|
$this->es = new Es('hg_ai_emails');
|
|
|
// $this->es = new Es('hg_ai_emails');
|
|
|
if(in_array($this->table,['lists','lists_auto','lists_hot'])){
|
|
|
|
|
|
if($this->type=='create'){
|
...
|
...
|
@@ -70,16 +70,18 @@ class SyncMailToEs { |
|
|
return ;
|
|
|
}
|
|
|
else if($this->table == 'lists'){
|
|
|
$id = $this->data['email_id'].'_'.$this->data['folder_id'].'_'.$this->data['uid'];
|
|
|
if(empty($this->data['is_auto'])){
|
|
|
$this->data['is_auto'] = 0;
|
|
|
}
|
|
|
$this->es->save($id,$this->getData($this->data));
|
|
|
redis()->rPush('sync_to_es',$this->data['id']);
|
|
|
// $id = $this->data['email_id'].'_'.$this->data['folder_id'].'_'.$this->data['uid'];
|
|
|
// if(empty($this->data['is_auto'])){
|
|
|
// $this->data['is_auto'] = 0;
|
|
|
// }
|
|
|
// $this->es->save($id,$this->getData($this->data));
|
|
|
}
|
|
|
else if($this->table == 'lists_auto'){
|
|
|
$data = db()->first(listsSql::first('`id` = '.$this->data['list_id']));
|
|
|
$id = $data['email_id'].'_'.$data['folder_id'].'_'.$data['uid'];
|
|
|
$this->es->save($id,$this->getData($data));
|
|
|
redis()->rPush('sync_to_es',$this->data['list_id']);
|
|
|
// $data = db()->first(listsSql::first('`id` = '.$this->data['list_id']));
|
|
|
// $id = $data['email_id'].'_'.$data['folder_id'].'_'.$data['uid'];
|
|
|
// $this->es->save($id,$this->getData($data));
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -95,39 +97,17 @@ class SyncMailToEs { |
|
|
// }
|
|
|
if($this->table == 'lists'){
|
|
|
// 更新es
|
|
|
$lists = db()->all(listsSql::all($this->where));
|
|
|
$lists = db()->all(listsSql::all($this->where,'`id`'));
|
|
|
foreach ($lists as $list){
|
|
|
$id = $list['email_id'].'_'.$list['folder_id'].'_'.$list['uid'];
|
|
|
$this->es->save($id,$this->getData($list));
|
|
|
redis()->rPush('sync_to_es',$list['id']);
|
|
|
// $id = $list['email_id'].'_'.$list['folder_id'].'_'.$list['uid'];
|
|
|
// $this->es->save($id,$this->getData($list));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public function getData($data){
|
|
|
if(!empty($data['id'])){
|
|
|
$data['uuid'] = $data['id'];
|
|
|
unset($data['id']);
|
|
|
}
|
|
|
if(!empty($data['from'])){
|
|
|
$data['from'] = [
|
|
|
'email' => $data['from'],
|
|
|
'name' => $data['from_name']??''
|
|
|
];
|
|
|
unset($data['from_name']);
|
|
|
}
|
|
|
unset($data['date']);
|
|
|
if(!empty($data['created_at'])){
|
|
|
$data['created_at'] = date('Y-m-d\TH:i:s',strtotime($data['created_at']));
|
|
|
}
|
|
|
if(!empty($data['updated_at'])){
|
|
|
$data['updated_at'] = date('Y-m-d\TH:i:s',strtotime($data['updated_at']));
|
|
|
}
|
|
|
$data['references'] = empty($data['references']) ? '' : $data['references'];
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|