mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-02 02:48:13 +00:00
no message
This commit is contained in:
parent
8af540f9b2
commit
81fdcce40f
@ -155,12 +155,12 @@ class UmengAlias extends AbstractModel
|
||||
$builder->whereUserid($userid);
|
||||
}
|
||||
$builder
|
||||
->orderByDesc('id')
|
||||
->orderByDesc('updated_at')
|
||||
->chunkById(100, function ($datas) use ($array) {
|
||||
$uids = $datas->groupBy('userid');
|
||||
foreach ($uids as $uid => $rows) {
|
||||
$array['badge'] = WebSocketDialogMsgRead::whereUserid($uid)->whereSilence(0)->whereReadAt(null)->count();
|
||||
$lists = $rows->groupBy('platform');
|
||||
$lists = $rows->take(5)->groupBy('platform'); // 每个会员最多推送5个别名
|
||||
foreach ($lists as $platform => $list) {
|
||||
$alias = $list->pluck('alias')->implode(',');
|
||||
self::pushMsgToAlias($alias, $platform, $array);
|
||||
|
||||
@ -112,7 +112,7 @@ class PushTask extends AbstractTask
|
||||
*/
|
||||
public static function push(array $lists, $retryOffline = true, $key = null, $delay = 1)
|
||||
{
|
||||
if (!is_array($lists) || empty($lists)) {
|
||||
if (empty($lists)) {
|
||||
return;
|
||||
}
|
||||
if (!Base::isTwoArray($lists)) {
|
||||
@ -178,14 +178,7 @@ class PushTask extends AbstractTask
|
||||
Task::deliver($task);
|
||||
} else {
|
||||
try {
|
||||
$encrypt = Base::json2array(Cache::get("User::encrypt:" . $fid));
|
||||
if ($encrypt['type'] == 'pgp') {
|
||||
$msg = [
|
||||
'type' => 'encrypt',
|
||||
'encrypted' => Doo::pgpEncryptApi($msg, $encrypt['key']),
|
||||
];
|
||||
}
|
||||
$swoole->push($fid, Base::array2json($msg));
|
||||
$swoole->push($fid, self::pushMsgFormat($fid, $msg));
|
||||
if ($tmpMsgId > 0) {
|
||||
WebSocketTmpMsg::whereId($tmpMsgId)->update(['send' => 1]);
|
||||
}
|
||||
@ -201,4 +194,22 @@ class PushTask extends AbstractTask
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化推送消息
|
||||
* @param $fid
|
||||
* @param $msg
|
||||
* @return string
|
||||
*/
|
||||
private static function pushMsgFormat($fid, $msg)
|
||||
{
|
||||
$encrypt = Base::json2array(Cache::get("User::encrypt:" . $fid));
|
||||
if ($encrypt['type'] == 'pgp') {
|
||||
$msg = [
|
||||
'type' => 'encrypt',
|
||||
'encrypted' => Doo::pgpEncryptApi($msg, $encrypt['key']),
|
||||
];
|
||||
}
|
||||
return Base::array2json($msg);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user