FIX: Ping route adapted to use connection_id

This commit is contained in:
rodrigo.zamboni
2022-09-05 11:01:18 -03:00
parent 8c85172554
commit 080c8fc52a
4 changed files with 39 additions and 17 deletions
@@ -52,10 +52,7 @@ export class ConnectionTestController {
user: user.user_id,
customer: user.customer_name,
});
return this.connectionTestService.connectionTestPing(
body,
user.customer_name,
);
return this.connectionTestService.connectionTestPing(body, user);
}
@Post('credentials')
@@ -36,7 +36,7 @@ export class ConnectionTestService {
async connectionTestPing(
body: ConnectionTestPingReq,
customer_name: string,
user: RequestUser,
): Promise<ConnectionTestPingRes> {
const {
host: endpoint,
@@ -45,16 +45,41 @@ export class ConnectionTestService {
network_config_id,
connection_id,
} = body;
return lastValueFrom(
this.connectionTestReadClient.ConnectionTestPing({
customer_name,
endpoint,
network_config_id,
plugin,
port: port ? port.toString() : undefined,
connection_id,
}),
);
const { user_id, customer_id, customer_name } = user;
const info = { customer_name, customer_id, user_id };
if (connection_id) {
const con = await this.connectionsService.getConnectionDetails({
body,
info,
});
const conPayload = JSON.parse(con.connection.properties);
const { plugin, network_config_id } = con.connection;
const { host, port, endpoint } = conPayload;
console.log(plugin);
return lastValueFrom(
this.connectionTestReadClient.ConnectionTestPing({
customer_name,
endpoint: endpoint || host,
network_config_id,
plugin,
port: port ? port.toString() : undefined,
connection_id,
}),
);
} else {
return lastValueFrom(
this.connectionTestReadClient.ConnectionTestPing({
customer_name,
endpoint,
network_config_id,
plugin,
port: port ? port.toString() : undefined,
connection_id,
}),
);
}
}
async connectionTestCredentials(
body: ConnectionTestCredentialsReq,
+1 -1
View File
@@ -185,7 +185,7 @@ export class ConnectionClientService implements OnModuleInit {
meta.add('user_id', info.user_id);
meta.add('details', info.details);
const { id } = body;
const id = body.connection_id || body.id;
return lastValueFrom(
this.connectionServiceRead.GetConnectionDetails({ id }, meta),
+1 -1
View File
File diff suppressed because one or more lines are too long