fix getSubGroupClients for enable/disable and edit clients.

This commit is contained in:
AghayeCoder 2025-01-31 17:27:09 +03:30
parent a787ab497c
commit 46ba4c4518

View File

@ -1198,30 +1198,43 @@
const response = { const response = {
inbounds: [], inbounds: [],
clients: [], clients: [],
editIds: [] editIds: [],
};
if (!Array.isArray(dbInbounds) || dbInbounds.length === 0) {
return response;
} }
if (dbInbounds && dbInbounds.length > 0 && currentClient) { if (!currentClient || !currentClient.subId) {
return response;
}
dbInbounds.forEach((dbInboundItem) => { dbInbounds.forEach((dbInboundItem) => {
try {
const dbInbound = new DBInbound(dbInboundItem); const dbInbound = new DBInbound(dbInboundItem);
if (dbInbound) { if (!dbInbound) {
return;
}
const inbound = dbInbound.toInbound(); const inbound = dbInbound.toInbound();
if (inbound) { if (!inbound || !Array.isArray(inbound.clients)) {
const clients = inbound.clients; return;
if (clients.length > 0) {
clients.forEach((client) => {
if (client['subId'] === currentClient['subId']) {
client['inboundId'] = dbInboundItem.id
client['clientId'] = this.getClientId(dbInbound.protocol, client)
response.inbounds.push(dbInboundItem.id)
response.clients.push(client)
response.editIds.push(client['clientId'])
} }
})
inbound.clients.forEach((client) => {
if (client.subId === currentClient.subId) {
client.inboundId = dbInboundItem.id;
client.clientId = this.getClientId(dbInbound.protocol, client);
response.inbounds.push(dbInboundItem.id);
response.clients.push(client);
response.editIds.push(client.clientId);
} }
});
} catch (error) {
console.error("Error processing dbInboundItem:", dbInboundItem, error);
} }
} });
})
}
return response; return response;
}, },
getClientId(protocol, client) { getClientId(protocol, client) {