|
1195 | 1195 | }
|
1196 | 1196 | },
|
1197 | 1197 | getSubGroupClients(dbInbounds, currentClient) {
|
1198 |
| - const response = { |
1199 |
| - inbounds: [], |
1200 |
| - clients: [], |
1201 |
| - editIds: [] |
| 1198 | + const response = { |
| 1199 | + inbounds: [], |
| 1200 | + clients: [], |
| 1201 | + editIds: [], |
| 1202 | + }; |
| 1203 | + |
| 1204 | + if (!Array.isArray(dbInbounds) || dbInbounds.length === 0) { |
| 1205 | + return response; |
| 1206 | + } |
| 1207 | + if (!currentClient || !currentClient.subId) { |
| 1208 | + return response; |
| 1209 | + } |
| 1210 | + |
| 1211 | + dbInbounds.forEach((dbInboundItem) => { |
| 1212 | + try { |
| 1213 | + const dbInbound = new DBInbound(dbInboundItem); |
| 1214 | + if (!dbInbound) { |
| 1215 | + return; |
1202 | 1216 | }
|
1203 |
| - if (dbInbounds && dbInbounds.length > 0 && currentClient) { |
1204 |
| - dbInbounds.forEach((dbInboundItem) => { |
1205 |
| - const dbInbound = new DBInbound(dbInboundItem); |
1206 |
| - if (dbInbound) { |
1207 |
| - const inbound = dbInbound.toInbound(); |
1208 |
| - if (inbound) { |
1209 |
| - const clients = inbound.clients; |
1210 |
| - if (clients.length > 0) { |
1211 |
| - clients.forEach((client) => { |
1212 |
| - if (client['subId'] === currentClient['subId']) { |
1213 |
| - client['inboundId'] = dbInboundItem.id |
1214 |
| - client['clientId'] = this.getClientId(dbInbound.protocol, client) |
1215 |
| - response.inbounds.push(dbInboundItem.id) |
1216 |
| - response.clients.push(client) |
1217 |
| - response.editIds.push(client['clientId']) |
1218 |
| - } |
1219 |
| - }) |
1220 |
| - } |
1221 |
| - } |
1222 |
| - } |
1223 |
| - }) |
| 1217 | + |
| 1218 | + const inbound = dbInbound.toInbound(); |
| 1219 | + if (!inbound || !Array.isArray(inbound.clients)) { |
| 1220 | + return; |
1224 | 1221 | }
|
1225 |
| - return response; |
1226 |
| - }, |
| 1222 | + |
| 1223 | + inbound.clients.forEach((client) => { |
| 1224 | + if (client.subId === currentClient.subId) { |
| 1225 | + client.inboundId = dbInboundItem.id; |
| 1226 | + client.clientId = this.getClientId(dbInbound.protocol, client); |
| 1227 | + |
| 1228 | + response.inbounds.push(dbInboundItem.id); |
| 1229 | + response.clients.push(client); |
| 1230 | + response.editIds.push(client.clientId); |
| 1231 | + } |
| 1232 | + }); |
| 1233 | + } catch (error) { |
| 1234 | + console.error("Error processing dbInboundItem:", dbInboundItem, error); |
| 1235 | + } |
| 1236 | + }); |
| 1237 | + |
| 1238 | + return response; |
| 1239 | + }, |
1227 | 1240 | getClientId(protocol, client) {
|
1228 | 1241 | switch (protocol) {
|
1229 | 1242 | case Protocols.TROJAN: return client.password;
|
|
0 commit comments