channel-worker 1.6.16 → 1.6.17
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/command-poller.js +22 -0
- package/package.json +1 -1
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');
|