From 0adbdbdf1b5a0141702dc133db16325bf11c5f15 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 4 Jul 2023 11:59:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=A8=E5=91=98=E7=BE=A4=E7=A6=81?= =?UTF-8?q?=E8=A8=80=E4=BB=85=E7=AE=A1=E7=90=86=E5=91=98=E5=8F=AF=E5=8F=91?= =?UTF-8?q?=E8=A8=80=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/WebSocketDialog.php | 2 +- app/Models/WebSocketDialogMsg.php | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Models/WebSocketDialog.php b/app/Models/WebSocketDialog.php index d7a9099b4..a96570ff5 100644 --- a/app/Models/WebSocketDialog.php +++ b/app/Models/WebSocketDialog.php @@ -389,7 +389,7 @@ class WebSocketDialog extends AbstractModel case 'all': throw new ApiException('当前会话全员禁言'); case 'user': - if (!User::find($userid)?->checkAdmin()) { + if (!User::find($userid)?->isAdmin()) { throw new ApiException('当前会话禁言'); } } diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index 549dbcea5..f52144760 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -774,14 +774,14 @@ class WebSocketDialogMsg extends AbstractModel * @param int $dialog_id 会话ID(即 聊天室ID) * @param string $type 消息类型 * @param array $msg 发送的消息 - * @param int $sender 发送的会员ID(默认自己,0为系统) + * @param int|null $sender 发送的会员ID(默认自己,0为系统) * @param bool $push_self 推送-是否推给自己 * @param bool $push_retry 推送-失败后重试1次(有时候在事务里执行,数据还没生成时会出现找不到消息的情况) * @param bool|null $push_silence 推送-静默 * - type = [text|file|record|meeting] 默认为:false * @return array */ - public static function sendMsg($action, $dialog_id, $type, $msg, $sender = 0, $push_self = false, $push_retry = false, $push_silence = null) + public static function sendMsg($action, $dialog_id, $type, $msg, $sender = null, $push_self = false, $push_retry = false, $push_silence = null) { $link = 0; $mtype = $type; @@ -810,13 +810,15 @@ class WebSocketDialogMsg extends AbstractModel // $update_id = preg_match("/^update-(\d+)$/", $action, $match) ? $match[1] : 0; $reply_id = preg_match("/^reply-(\d+)$/", $action, $match) ? $match[1] : 0; - $sender = $sender ?: User::userid(); + $sender = $sender === null ? User::userid() : $sender; // $dialog = WebSocketDialog::find($dialog_id); if (empty($dialog)) { throw new ApiException('获取会话失败'); } - $dialog->checkMute($sender); + if ($sender > 0) { + $dialog->checkMute($sender); + } // if ($update_id) { // 修改