channel-worker 1.3.1 → 1.3.2
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/nst-manager.js +11 -7
- package/package.json +1 -1
package/lib/nst-manager.js
CHANGED
|
@@ -46,16 +46,17 @@ class NstManager {
|
|
|
46
46
|
profiles = res.data;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const match = profiles.find(p => p.name === name);
|
|
49
|
+
const match = profiles.find(p => p.name?.toLowerCase() === name.toLowerCase());
|
|
50
50
|
if (match) return match.profileId || match._id;
|
|
51
51
|
|
|
52
|
-
// Fallback: fetch
|
|
53
|
-
const rawRes = await fetch(
|
|
52
|
+
// Fallback: fetch profiles via local API with exact name search
|
|
53
|
+
const rawRes = await fetch(`http://localhost:8848/api/v2/profiles/?keyword=${encodeURIComponent(name)}&limit=100`, {
|
|
54
54
|
headers: { 'x-api-key': this.apiKey },
|
|
55
55
|
});
|
|
56
56
|
const rawData = await rawRes.json();
|
|
57
57
|
const allProfiles = rawData?.data?.docs || rawData?.data || [];
|
|
58
|
-
|
|
58
|
+
console.log(`[nst] Fallback search for "${name}": found ${allProfiles.length} profiles`);
|
|
59
|
+
const fallback = allProfiles.find(p => p.name?.toLowerCase() === name.toLowerCase());
|
|
59
60
|
if (fallback) return fallback.profileId || fallback._id;
|
|
60
61
|
|
|
61
62
|
return null;
|
|
@@ -73,7 +74,7 @@ class NstManager {
|
|
|
73
74
|
return existing;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
console.log(`[nst]
|
|
77
|
+
console.log(`[nst] WARNING: Profile "${name}" NOT FOUND — creating new profile...`);
|
|
77
78
|
const res = await this.client.profiles().createProfile({
|
|
78
79
|
name,
|
|
79
80
|
platform: 'Windows',
|
|
@@ -122,9 +123,12 @@ class NstManager {
|
|
|
122
123
|
|
|
123
124
|
// Ensure profile language is en-US to prevent auto-translate
|
|
124
125
|
try {
|
|
125
|
-
await
|
|
126
|
-
|
|
126
|
+
const res = await fetch(`http://localhost:8848/api/v2/profiles/${profileId}`, {
|
|
127
|
+
method: 'PATCH',
|
|
128
|
+
headers: { 'Content-Type': 'application/json', 'x-api-key': this.apiKey },
|
|
129
|
+
body: JSON.stringify({ fingerprint: { language: 'en-US' } }),
|
|
127
130
|
});
|
|
131
|
+
if (!res.ok) console.warn(`[nst] Could not update profile language: ${res.status}`);
|
|
128
132
|
} catch (err) {
|
|
129
133
|
console.warn(`[nst] Could not update profile language:`, err.message);
|
|
130
134
|
}
|