Skip to content
This repository was archived by the owner on Oct 20, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions src/Getui.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Cncal\Getui\Sdk\IGetui\IGtListMessage;
use Cncal\Getui\Sdk\IGetui\IGtSingleMessage;
use Cncal\Getui\Sdk\IGetui\Template\GetuiTemplate;
use Cncal\Getui\Sdk\IGetui\Utils\AppConditions;

class Getui
{
Expand Down Expand Up @@ -95,14 +96,14 @@ public function pushMessageToSingle($data)
$cid = $data['cid'];

$is_off_line = isset($data['template_data']['is_offline']) ?
(bool)$data['template_data']['is_offline'] : $this->is_offline;
(bool)$data['template_data']['is_offline'] : $this->is_offline;

$offline_expire_time = isset($data['template_data']['is_offline']) ?
(int)$data['template_data']['offline_expire_time'] * 1000 * 3600 :
$this->offline_expire_time * 1000 * 3600;
(int)$data['template_data']['offline_expire_time'] * 1000 * 3600 :
$this->offline_expire_time * 1000 * 3600;

$network_type = isset($data['template_data']['network_type']) ?
(int)$data['template_data']['network_type'] : $this->network_type;
(int)$data['template_data']['network_type'] : $this->network_type;

// todo: need to discuss
$getui_template = new GetuiTemplate($template_type, $template_data);
Expand All @@ -126,8 +127,8 @@ public function pushMessageToSingle($data)
// 使用队列
if ($this->queue_is_used) {
PushGetuiMessage::dispatch($this->igt, 'pushMessageToSingle', $message, $target)
->onConnection($this->queue_connection)
->onQueue($this->queue_queue);
->onConnection($this->queue_connection)
->onQueue($this->queue_queue);

return true;
}
Expand All @@ -151,14 +152,14 @@ public function pushMessageToList($data)
$template_data = $data['template_data'];

$is_off_line = isset($data['template_data']['is_offline']) ?
(bool)$data['template_data']['is_offline'] : $this->is_offline;
(bool)$data['template_data']['is_offline'] : $this->is_offline;

$offline_expire_time = isset($data['template_data']['is_offline']) ?
(int)$data['template_data']['offline_expire_time'] * 1000 * 3600 :
$this->offline_expire_time * 1000 * 3600;
(int)$data['template_data']['offline_expire_time'] * 1000 * 3600 :
$this->offline_expire_time * 1000 * 3600;

$network_type = isset($data['template_data']['network_type']) ?
(int)$data['template_data']['network_type'] : $this->network_type;
(int)$data['template_data']['network_type'] : $this->network_type;

$getui_template = new GetuiTemplate($template_type, $template_data);
$template = $getui_template->getTemplate();
Expand Down Expand Up @@ -186,8 +187,8 @@ public function pushMessageToList($data)
// 使用队列
if ($this->queue_is_used) {
PushGetuiMessage::dispatch($this->igt, 'pushMessageToList', $contentId, $target_list)
->onConnection($this->queue_connection)
->onQueue($this->queue_queue);
->onConnection($this->queue_connection)
->onQueue($this->queue_queue);

return true;
}
Expand All @@ -211,21 +212,27 @@ public function pushMessageToApp($data)
$template_data = $data['template_data'];

$is_off_line = isset($data['template_data']['is_offline']) ?
(bool)$data['template_data']['is_offline'] : $this->is_offline;
(bool)$data['template_data']['is_offline'] : $this->is_offline;

$offline_expire_time = isset($data['template_data']['is_offline']) ?
(int)$data['template_data']['offline_expire_time'] * 1000 * 3600 :
$this->offline_expire_time * 1000 * 3600;
(int)$data['template_data']['offline_expire_time'] * 1000 * 3600 :
$this->offline_expire_time * 1000 * 3600;

$network_type = isset($data['template_data']['network_type']) ?
(int)$data['template_data']['network_type'] : $this->network_type;
(int)$data['template_data']['network_type'] : $this->network_type;

// todo: need to discuss
$getui_template = new GetuiTemplate($template_type, $template_data);
$template = $getui_template->getTemplate();

$cdt = new AppConditions();
$cdt->addCondition3(AppConditions::PHONE_TYPE, $data['phone_type_list']);
$cdt->addCondition3(AppConditions::REGION, $data['province_list']);
$cdt->addCondition3(AppConditions::TAG, $data['tag_list']);

$message = new IGtAppMessage();
$message->set_isOffline($is_off_line);
$message->set_conditions($cdt);

if ($is_off_line) {
$message->set_offlineExpireTime($offline_expire_time);
Expand All @@ -238,8 +245,8 @@ public function pushMessageToApp($data)
// 使用队列
if ($this->queue_is_used) {
PushGetuiMessage::dispatch($this->igt, 'pushMessageToApp', $message)
->onConnection($this->queue_connection)
->onQueue($this->queue_queue);
->onConnection($this->queue_connection)
->onQueue($this->queue_queue);

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/IGtPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private function getListAppContentId($message, $taskGroupName = null)
if ($rep['result'] == 'ok') {
return $rep['contentId'];
} else {
throw new \Exception("host:[" . $this->host . "]" + "获取contentId失败:" . $rep);
throw new \Exception("host:[" . $this->host . "]" . "获取contentId失败:" . $rep);
}
}

Expand Down Expand Up @@ -407,7 +407,7 @@ public function getAPNContentId($appId, $message)
if ($rep['result'] == 'ok') {
return $rep['contentId'];
} else {
throw new \Exception("host:[" . $this->host . "]" + "获取contentId失败:" . $rep);
throw new \Exception("host:[" . $this->host . "]" . "获取contentId失败:" . $rep);
}
}

Expand Down