修复:channels.php 移除 int 类型提示,改用强转比较防兼容性问题
int $id 类型提示在某些 PHP 版本下对字符串参数可能失败,
统一改为 (int) 强转比较,与 App.Models.User.{id} 写法一致。
This commit is contained in:
@@ -664,7 +664,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const myName = window.chatContext.username;
|
const myName = window.chatContext.username;
|
||||||
const myId = window.chatContext.userId;
|
const myId = window.chatContext.userId;
|
||||||
window.Echo.private(`user.${myId}`)
|
window.Echo.private(`user.${myId}`)
|
||||||
.listen('.FriendAdded', (e) => {
|
.listen('.FriendAdded', (e) => {
|
||||||
// 用居中大卡弹窗通知(有无互相好友显示不同文案和按钮)
|
// 用居中大卡弹窗通知(有无互相好友显示不同文案和按钮)
|
||||||
@@ -708,7 +708,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const myName = window.chatContext.username;
|
const myName = window.chatContext.username;
|
||||||
const myId = window.chatContext.userId;
|
const myId = window.chatContext.userId;
|
||||||
const roomId = window.chatContext.roomId;
|
const roomId = window.chatContext.roomId;
|
||||||
|
|
||||||
// 监听私有用户频道(单独推给某人,用数字 ID 避免中文名频道非法)
|
// 监听私有用户频道(单独推给某人,用数字 ID 避免中文名频道非法)
|
||||||
@@ -1248,7 +1248,7 @@
|
|||||||
contentInput.focus();
|
contentInput.focus();
|
||||||
} else {
|
} else {
|
||||||
window.chatDialog.alert('发送失败: ' + (data.message || JSON.stringify(data.errors)), '操作失败',
|
window.chatDialog.alert('发送失败: ' + (data.message || JSON.stringify(data.errors)), '操作失败',
|
||||||
'#cc4444');
|
'#cc4444');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.chatDialog.alert('网络连接错误,消息发送失败!', '网络错误', '#cc4444');
|
window.chatDialog.alert('网络连接错误,消息发送失败!', '网络错误', '#cc4444');
|
||||||
|
|||||||
+2
-2
@@ -29,6 +29,6 @@ Broadcast::channel('room.{roomId}', function ($user, $roomId) {
|
|||||||
|
|
||||||
// 用户私有频道鉴权(好友通知:FriendAdded / FriendRemoved / BannerNotification)
|
// 用户私有频道鉴权(好友通知:FriendAdded / FriendRemoved / BannerNotification)
|
||||||
// 使用数字 ID 命名频道,避免中文用户名导致 Pusher 频道名验证失败。
|
// 使用数字 ID 命名频道,避免中文用户名导致 Pusher 频道名验证失败。
|
||||||
Broadcast::channel('user.{id}', function ($user, int $id) {
|
Broadcast::channel('user.{id}', function ($user, $id) {
|
||||||
return (int) $user->id === $id;
|
return (int) $user->id === (int) $id;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user