mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-28 21:20:31 +00:00
perf: 优化通知类消息字符长度
This commit is contained in:
parent
4561efc3ce
commit
43a4e5741a
@ -1130,7 +1130,7 @@ class DialogController extends AbstractController
|
||||
'data' => [
|
||||
'id' => $msg->id,
|
||||
'type' => $msg->type,
|
||||
'msg' => $msg->msg,
|
||||
'msg' => $msg->quoteTextMsg(),
|
||||
]
|
||||
]);
|
||||
if (Base::isSuccess($res)) {
|
||||
|
||||
@ -283,7 +283,7 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
'data' => [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'msg' => $this->msg,
|
||||
'msg' => $this->quoteTextMsg(),
|
||||
]
|
||||
], $sender);
|
||||
if (Base::isSuccess($res)) {
|
||||
@ -328,7 +328,7 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
'data' => [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'msg' => $this->msg,
|
||||
'msg' => $this->quoteTextMsg(),
|
||||
'userids' => implode(",", $userids),
|
||||
]
|
||||
], $sender);
|
||||
@ -490,6 +490,23 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回引用消息(如果是文本消息则截取)
|
||||
* @param int $strlen
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function quoteTextMsg($strlen = 30)
|
||||
{
|
||||
$msg = $this->msg;
|
||||
if ($this->type === 'text') {
|
||||
$msg['text'] = $this->previewTextMsg($msg['text']);
|
||||
if (mb_strlen($msg['text']) > $strlen) {
|
||||
$msg['text'] = mb_substr($msg['text'], 0, $strlen - 3) . "...";
|
||||
}
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回文本预览消息
|
||||
* @param $text
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user