聊天,基本

This commit is contained in:
2025-11-21 17:03:52 +08:00
parent 57319e03ce
commit 8982010423
3 changed files with 76 additions and 33 deletions

View File

@@ -317,38 +317,33 @@ class GroupController extends ApiController
}
/**
* 设置群免打扰 (废弃)
* 设置群免打扰
*/
public function setDoNotDisturb(Request $request): Response
{
$groupId = $request->post('group_id');
$status = $request->post('status'); // 0=关闭1=开启
if (!$groupId) {
return $this->error('缺少group_id');
}
// 验证是否在群内
$isMember = Db::name('chat_group_member')->where([
'group_id' => $groupId,
'user_id' => $this->uid,
'quit_time' => null,
'is_kicked' => 0
])->exists();
])->find();
if (!$isMember) {
return $this->error('不在群内');
}
// 生成会话ID
$sessionId = Session::generateSessionId(2, $uid, $groupId);
// 更新免打扰状态
ChatDoNotDisturb::updateOrCreate(
['user_id' => $uid, 'session_id' => $sessionId],
['status' => $status, 'updated_at' => time()]
);
return json(['code' => 200, 'msg' => $status ? '开启免打扰成功' : '关闭免打扰成功']);
$res = Db::name('chat_group_member')->where([
'group_id' => $groupId,
'user_id' => $this->uid,
])->update(['is_dist' => $status]);
if($res) {
return $this->success();
}
return $this->error();
}
/**