mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
perf: 优化通知类消息字符长度
This commit is contained in:
parent
4561efc3ce
commit
43a4e5741a
@ -1130,7 +1130,7 @@ class DialogController extends AbstractController
|
|||||||
'data' => [
|
'data' => [
|
||||||
'id' => $msg->id,
|
'id' => $msg->id,
|
||||||
'type' => $msg->type,
|
'type' => $msg->type,
|
||||||
'msg' => $msg->msg,
|
'msg' => $msg->quoteTextMsg(),
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
if (Base::isSuccess($res)) {
|
if (Base::isSuccess($res)) {
|
||||||
|
|||||||
@ -283,7 +283,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
'data' => [
|
'data' => [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'msg' => $this->msg,
|
'msg' => $this->quoteTextMsg(),
|
||||||
]
|
]
|
||||||
], $sender);
|
], $sender);
|
||||||
if (Base::isSuccess($res)) {
|
if (Base::isSuccess($res)) {
|
||||||
@ -328,7 +328,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
'data' => [
|
'data' => [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'msg' => $this->msg,
|
'msg' => $this->quoteTextMsg(),
|
||||||
'userids' => implode(",", $userids),
|
'userids' => implode(",", $userids),
|
||||||
]
|
]
|
||||||
], $sender);
|
], $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
|
* @param $text
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user