perf: [notice|tag|todo]类型的消息静默推送

This commit is contained in:
kuaifan
2022-07-08 14:45:42 +08:00
parent d9696d2398
commit 97d041076d
3 changed files with 52 additions and 29 deletions

View File

@@ -593,18 +593,20 @@ class WebSocketDialogMsg extends AbstractModel
/**
* 发送消息、修改消息
* @param string $action 动作
* - reply-98回复消息ID-98
* - update-99更新消息ID-99
* @param int $dialog_id 会话ID即 聊天室ID
* @param string $type 消息类型
* @param array $msg 发送的消息
* @param int $sender 发送的会员ID默认自己0为系统
* @param bool $push_self 是否推给自己
* @param bool $push_retry 推送失败后重试1次有时候在事务里执行数据还没生成时会出现找不到消息的情况
* @param string $action 动作
* - reply-98回复消息ID=98
* - update-99更新消息ID=99
* @param int $dialog_id 会话ID即 聊天室ID
* @param string $type 消息类型
* @param array $msg 发送的消息
* @param int $sender 发送的会员ID默认自己0为系统
* @param bool $push_self 推送-是否推给自己
* @param bool $push_retry 推送-失败后重试1次有时候在事务里执行数据还没生成时会出现找不到消息的情况
* @param bool|null $push_silence 推送-静默
* - type = [notice|tag|todo] 默认为true
* @return array
*/
public static function sendMsg($action, $dialog_id, $type, $msg, $sender = 0, $push_self = false, $push_retry = false)
public static function sendMsg($action, $dialog_id, $type, $msg, $sender = 0, $push_self = false, $push_retry = false, $push_silence = null)
{
$link = 0;
$mtype = $type;
@@ -620,6 +622,9 @@ class WebSocketDialogMsg extends AbstractModel
$mtype = 'image';
}
}
if ($push_silence === null) {
$push_silence = in_array($type, ['notice', 'tag', 'todo']);
}
//
$update_id = preg_match("/^update-(\d+)$/", $action, $match) ? $match[1] : 0;
$reply_id = preg_match("/^reply-(\d+)$/", $action, $match) ? $match[1] : 0;
@@ -691,6 +696,9 @@ class WebSocketDialogMsg extends AbstractModel
if ($push_retry) {
$task->setMsgNotExistRetry(true);
}
if ($push_silence) {
$task->setSilence($push_silence);
}
Task::deliver($task);
//
return Base::retSuccess('发送成功', $dialogMsg);