channel-worker 1.6.16 → 1.6.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api-client.js +1 -1
- package/lib/command-poller.js +22 -0
- package/lib/nst-manager.js +5 -1
- package/package.json +1 -1
package/lib/api-client.js
CHANGED
|
@@ -65,7 +65,7 @@ class ApiClient {
|
|
|
65
65
|
|
|
66
66
|
// Commands
|
|
67
67
|
async getNextCommand(workerId) {
|
|
68
|
-
const workerTypes = 'launch_profile,close_profile,launch_veo3_profile,save_file,set_thumbnail,set_tags,set_file_input,click_and_upload,type_text,verify_logins,update_extension,sync_youtube_stats,restart_worker';
|
|
68
|
+
const workerTypes = 'launch_profile,close_profile,launch_veo3_profile,set_profile_proxy,save_file,set_thumbnail,set_tags,set_file_input,click_and_upload,type_text,verify_logins,update_extension,sync_youtube_stats,restart_worker';
|
|
69
69
|
return this.request('GET', `/workers/commands?worker_id=${workerId}&types=${encodeURIComponent(workerTypes)}`);
|
|
70
70
|
}
|
|
71
71
|
|
package/lib/command-poller.js
CHANGED
|
@@ -78,6 +78,9 @@ class CommandPoller {
|
|
|
78
78
|
case 'launch_veo3_profile':
|
|
79
79
|
await this.handleLaunchVeo3Profile(command);
|
|
80
80
|
break;
|
|
81
|
+
case 'set_profile_proxy':
|
|
82
|
+
await this.handleSetProfileProxy(command);
|
|
83
|
+
break;
|
|
81
84
|
default:
|
|
82
85
|
// Other commands (scan_facebook_pages, etc.) handled by extension
|
|
83
86
|
console.log(`[commands] Skipping ${command.type} — handled by extension`);
|
|
@@ -246,6 +249,25 @@ class CommandPoller {
|
|
|
246
249
|
}
|
|
247
250
|
}
|
|
248
251
|
|
|
252
|
+
async handleSetProfileProxy(command) {
|
|
253
|
+
const { nst_profile_id, proxy, os } = command.payload || {};
|
|
254
|
+
console.log(`[commands] Setting proxy for profile ${nst_profile_id}`);
|
|
255
|
+
try {
|
|
256
|
+
if (!this.nst) {
|
|
257
|
+
const apiKey = await this.api.getSetting('nst_api_key');
|
|
258
|
+
if (apiKey) this.nst = new NstManager(apiKey);
|
|
259
|
+
else throw new Error('Nstbrowser API key not configured.');
|
|
260
|
+
}
|
|
261
|
+
// Ensure profile exists first
|
|
262
|
+
await this.nst.ensureProfile(nst_profile_id, { os: os || 'windows', proxy: proxy || null });
|
|
263
|
+
await this.api.updateCommand(command._id, { status: 'done' });
|
|
264
|
+
console.log(`[commands] Proxy set for ${nst_profile_id}`);
|
|
265
|
+
} catch (err) {
|
|
266
|
+
console.error(`[commands] Failed to set proxy: ${err.message}`);
|
|
267
|
+
await this.api.updateCommand(command._id, { status: 'failed', error: err.message });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
249
271
|
async _ensureContentCreatorExt(extPath) {
|
|
250
272
|
const fs = require('fs');
|
|
251
273
|
const path = require('path');
|
package/lib/nst-manager.js
CHANGED
|
@@ -136,8 +136,12 @@ class NstManager {
|
|
|
136
136
|
headers: { 'Content-Type': 'application/json', 'x-api-key': this.apiKey },
|
|
137
137
|
body: JSON.stringify(proxyConfig),
|
|
138
138
|
});
|
|
139
|
+
const text = await res.text();
|
|
140
|
+
console.log(`[nst] setProxy ${method} ${res.status}: ${text.substring(0, 200)}`);
|
|
139
141
|
if (res.ok) { console.log(`[nst] Proxy saved to profile (${method})`); return; }
|
|
140
|
-
} catch {
|
|
142
|
+
} catch (e) {
|
|
143
|
+
console.warn(`[nst] setProxy ${method} error: ${e.message}`);
|
|
144
|
+
}
|
|
141
145
|
}
|
|
142
146
|
console.warn(`[nst] Failed to save proxy to profile — will still use at launch time`);
|
|
143
147
|
}
|