fix: 全员群禁言仅管理员可发言无效的问题

This commit is contained in:
kuaifan 2023-07-04 11:59:26 +08:00
parent 13560616c8
commit 0adbdbdf1b
2 changed files with 7 additions and 5 deletions

View File

@ -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('当前会话禁言');
}
}

View File

@ -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) {
// 修改