Merge pull request #71 from amhsirak/develop
fix: incorrect browser & run references in robot schedule
This commit is contained in:
@@ -10,38 +10,34 @@ import Run from "../../models/Run";
|
|||||||
import { getDecryptedProxyConfig } from "../../routes/proxy";
|
import { getDecryptedProxyConfig } from "../../routes/proxy";
|
||||||
|
|
||||||
async function createWorkflowAndStoreMetadata(id: string, userId: string) {
|
async function createWorkflowAndStoreMetadata(id: string, userId: string) {
|
||||||
if (!id) {
|
|
||||||
id = uuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
const recording = await Robot.findOne({
|
|
||||||
where: {
|
|
||||||
'recording_meta.id': id
|
|
||||||
},
|
|
||||||
raw: true
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!recording || !recording.recording_meta || !recording.recording_meta.id) {
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
error: 'Recording not found'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const proxyConfig = await getDecryptedProxyConfig(userId);
|
|
||||||
let proxyOptions: any = {};
|
|
||||||
|
|
||||||
if (proxyConfig.proxy_url) {
|
|
||||||
proxyOptions = {
|
|
||||||
server: proxyConfig.proxy_url,
|
|
||||||
...(proxyConfig.proxy_username && proxyConfig.proxy_password && {
|
|
||||||
username: proxyConfig.proxy_username,
|
|
||||||
password: proxyConfig.proxy_password,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const recording = await Robot.findOne({
|
||||||
|
where: {
|
||||||
|
'recording_meta.id': id
|
||||||
|
},
|
||||||
|
raw: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!recording || !recording.recording_meta || !recording.recording_meta.id) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Recording not found'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const proxyConfig = await getDecryptedProxyConfig(userId);
|
||||||
|
let proxyOptions: any = {};
|
||||||
|
|
||||||
|
if (proxyConfig.proxy_url) {
|
||||||
|
proxyOptions = {
|
||||||
|
server: proxyConfig.proxy_url,
|
||||||
|
...(proxyConfig.proxy_username && proxyConfig.proxy_password && {
|
||||||
|
username: proxyConfig.proxy_username,
|
||||||
|
password: proxyConfig.proxy_password,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const browserId = createRemoteBrowserForRun({
|
const browserId = createRemoteBrowserForRun({
|
||||||
browser: chromium,
|
browser: chromium,
|
||||||
launchOptions: {
|
launchOptions: {
|
||||||
@@ -49,6 +45,7 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
|
|||||||
proxy: proxyOptions.server ? proxyOptions : undefined,
|
proxy: proxyOptions.server ? proxyOptions : undefined,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const runId = uuid();
|
||||||
|
|
||||||
const run = await Run.create({
|
const run = await Run.create({
|
||||||
status: 'Scheduled',
|
status: 'Scheduled',
|
||||||
@@ -57,10 +54,10 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
|
|||||||
robotMetaId: recording.recording_meta.id,
|
robotMetaId: recording.recording_meta.id,
|
||||||
startedAt: new Date().toLocaleString(),
|
startedAt: new Date().toLocaleString(),
|
||||||
finishedAt: '',
|
finishedAt: '',
|
||||||
browserId: id,
|
browserId,
|
||||||
interpreterSettings: { maxConcurrency: 1, maxRepeats: 1, debug: true },
|
interpreterSettings: { maxConcurrency: 1, maxRepeats: 1, debug: true },
|
||||||
log: '',
|
log: '',
|
||||||
runId: id,
|
runId,
|
||||||
serializableOutput: {},
|
serializableOutput: {},
|
||||||
binaryOutput: {},
|
binaryOutput: {},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user