perf: 支持通过接口发送通知和模板消息

This commit is contained in:
kuaifan
2024-12-03 13:53:34 +08:00
parent 96c64fbb91
commit 76bf46c152
5 changed files with 146 additions and 14 deletions

View File

@@ -610,7 +610,8 @@ class WebSocketDialogMsg extends AbstractModel
return "[{$action}] " . self::previewMsg($data['msg']['data']);
case 'notice':
return Base::cutStr(Doo::translate($data['msg']['notice']), 50);
$notice = $data['msg']['source'] === 'api' ? $data['msg']['notice'] : Doo::translate($data['msg']['notice']);
return Base::cutStr($notice, 50);
case 'template':
return self::previewTemplateMsg($data['msg']);
@@ -679,13 +680,15 @@ class WebSocketDialogMsg extends AbstractModel
return $msg['title_raw'];
}
if ($msg['type'] === 'task_list' && count($msg['list']) === 1) {
return Doo::translate($msg['title']) . ": " . Base::cutStr($msg['list'][0]['name'], 50);
$title = $msg['source'] === 'api' ? $msg['title'] : Doo::translate($msg['title']);
return $title . ": " . Base::cutStr($msg['list'][0]['name'], 50);
}
if (!empty($msg['title'])) {
return Doo::translate($msg['title']);
return $msg['source'] === 'api' ? $msg['title'] : Doo::translate($msg['title']);
}
if ($msg['type'] === 'content' && is_string($msg['content']) && $msg['content'] !== '') {
return Base::cutStr(Doo::translate($msg['content']), 50);
$content = $msg['source'] === 'api' ? $msg['content'] : Doo::translate($msg['content']);
return Base::cutStr($content, 50);
}
return Doo::translate('未知的消息');
}