mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-03 19:58:16 +00:00
feat:发送文本消息接口 - 添加群发字段
This commit is contained in:
parent
6870a29ec9
commit
7147db0ef2
@ -718,6 +718,7 @@ class DialogController extends AbstractController
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
$dialog_id = intval(Request::input('dialog_id'));
|
$dialog_id = intval(Request::input('dialog_id'));
|
||||||
|
$dialog_ids = trim(Request::input('dialog_ids'));
|
||||||
$update_id = intval(Request::input('update_id'));
|
$update_id = intval(Request::input('update_id'));
|
||||||
$update_mark = !($user->bot && in_array(strtolower(trim(Request::input('update_mark'))), ['no', 'false', '0']));
|
$update_mark = !($user->bot && in_array(strtolower(trim(Request::input('update_mark'))), ['no', 'false', '0']));
|
||||||
$reply_id = intval(Request::input('reply_id'));
|
$reply_id = intval(Request::input('reply_id'));
|
||||||
@ -726,58 +727,64 @@ class DialogController extends AbstractController
|
|||||||
$silence = in_array(strtolower(trim(Request::input('silence'))), ['yes', 'true', '1']);
|
$silence = in_array(strtolower(trim(Request::input('silence'))), ['yes', 'true', '1']);
|
||||||
$markdown = in_array($text_type, ['md', 'markdown']);
|
$markdown = in_array($text_type, ['md', 'markdown']);
|
||||||
//
|
//
|
||||||
WebSocketDialog::checkDialog($dialog_id);
|
$result = [];
|
||||||
//
|
$dialogIds = $dialog_ids ? explode(',', $dialog_ids) : [$dialog_id];
|
||||||
if ($update_id > 0) {
|
foreach($dialogIds as $dialog_id) {
|
||||||
$action = $update_mark ? "update-$update_id" : "change-$update_id";
|
//
|
||||||
} elseif ($reply_id > 0) {
|
WebSocketDialog::checkDialog($dialog_id);
|
||||||
$action = "reply-$reply_id";
|
//
|
||||||
} else {
|
if ($update_id > 0) {
|
||||||
$action = "";
|
$action = $update_mark ? "update-$update_id" : "change-$update_id";
|
||||||
}
|
} elseif ($reply_id > 0) {
|
||||||
//
|
$action = "reply-$reply_id";
|
||||||
if (!$markdown) {
|
} else {
|
||||||
$text = WebSocketDialogMsg::formatMsg($text, $dialog_id);
|
$action = "";
|
||||||
}
|
|
||||||
$strlen = mb_strlen($text);
|
|
||||||
$noimglen = mb_strlen(preg_replace("/<img[^>]*?>/i", "", $text));
|
|
||||||
if ($strlen < 1) {
|
|
||||||
return Base::retError('消息内容不能为空');
|
|
||||||
}
|
|
||||||
if ($noimglen > 200000) {
|
|
||||||
return Base::retError('消息内容最大不能超过200000字');
|
|
||||||
}
|
|
||||||
if ($noimglen > 5000) {
|
|
||||||
// 内容过长转成文件发送
|
|
||||||
$path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
|
|
||||||
Base::makeDir(public_path($path));
|
|
||||||
$path = $path . md5($text) . ".htm";
|
|
||||||
$file = public_path($path);
|
|
||||||
file_put_contents($file, $text);
|
|
||||||
$size = filesize(public_path($path));
|
|
||||||
if (empty($size)) {
|
|
||||||
return Base::retError('消息发送保存失败');
|
|
||||||
}
|
}
|
||||||
$ext = $markdown ? 'md' : 'htm';
|
//
|
||||||
$fileData = [
|
if (!$markdown) {
|
||||||
'name' => "LongText-{$strlen}.{$ext}",
|
$text = WebSocketDialogMsg::formatMsg($text, $dialog_id);
|
||||||
'size' => $size,
|
}
|
||||||
'file' => $file,
|
$strlen = mb_strlen($text);
|
||||||
'path' => $path,
|
$noimglen = mb_strlen(preg_replace("/<img[^>]*?>/i", "", $text));
|
||||||
'url' => Base::fillUrl($path),
|
if ($strlen < 1) {
|
||||||
'thumb' => '',
|
return Base::retError('消息内容不能为空');
|
||||||
'width' => -1,
|
}
|
||||||
'height' => -1,
|
if ($noimglen > 200000) {
|
||||||
'ext' => $ext,
|
return Base::retError('消息内容最大不能超过200000字');
|
||||||
];
|
}
|
||||||
return WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid, false, false, $silence);
|
if ($noimglen > 5000) {
|
||||||
|
// 内容过长转成文件发送
|
||||||
|
$path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
|
||||||
|
Base::makeDir(public_path($path));
|
||||||
|
$path = $path . md5($text) . ".htm";
|
||||||
|
$file = public_path($path);
|
||||||
|
file_put_contents($file, $text);
|
||||||
|
$size = filesize(public_path($path));
|
||||||
|
if (empty($size)) {
|
||||||
|
return Base::retError('消息发送保存失败');
|
||||||
|
}
|
||||||
|
$ext = $markdown ? 'md' : 'htm';
|
||||||
|
$fileData = [
|
||||||
|
'name' => "LongText-{$strlen}.{$ext}",
|
||||||
|
'size' => $size,
|
||||||
|
'file' => $file,
|
||||||
|
'path' => $path,
|
||||||
|
'url' => Base::fillUrl($path),
|
||||||
|
'thumb' => '',
|
||||||
|
'width' => -1,
|
||||||
|
'height' => -1,
|
||||||
|
'ext' => $ext,
|
||||||
|
];
|
||||||
|
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid, false, false, $silence);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
$msgData = ['text' => $text];
|
||||||
|
if ($markdown) {
|
||||||
|
$msgData['type'] = 'md';
|
||||||
|
}
|
||||||
|
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'text', $msgData, $user->userid, false, false, $silence);
|
||||||
}
|
}
|
||||||
//
|
return $result;
|
||||||
$msgData = ['text' => $text];
|
|
||||||
if ($markdown) {
|
|
||||||
$msgData['type'] = 'md';
|
|
||||||
}
|
|
||||||
return WebSocketDialogMsg::sendMsg($action, $dialog_id, 'text', $msgData, $user->userid, false, false, $silence);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user