tmp
This commit is contained in:
31
websocket.js
31
websocket.js
@@ -81,7 +81,7 @@ export default class WebSocketServerManager {
|
||||
}
|
||||
|
||||
if (msg.type === 'chat' || msg.type === 'clear') {
|
||||
if (msg.agent === 'escort-admin') {
|
||||
if (msg.agent === 'escort-admin') {
|
||||
const userInfo = await this.getUserInfo(msg.token, msg.userId);
|
||||
adminAgent.streamChat(userInfo, [msg], (source, type, content, id) => {
|
||||
ws.send(JSON.stringify({ source, type, content, id }));
|
||||
@@ -134,18 +134,23 @@ export default class WebSocketServerManager {
|
||||
}
|
||||
|
||||
async getUserInfo(token, userId) {
|
||||
if (!token && !userId) return null;
|
||||
try {
|
||||
if (!token && !userId) return null;
|
||||
|
||||
const url = "http://127.0.0.1:9010/user/userInfo";
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
token,
|
||||
userId
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
return data.data.user;
|
||||
const url = "http://127.0.0.1:9010/user/userInfo";
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
token,
|
||||
userId
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
return data.data.user;
|
||||
} catch (error) {
|
||||
console.error('Error fetching user info:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user