nodejs-insta-private-api-mqtt 1.3.16 → 1.3.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/README.md +44 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -292,7 +292,7 @@ There are two practical, compatible flows you can use depending on your client h
|
|
|
292
292
|
2. Call the direct broadcast / configure_photo or configure_video HTTP endpoint to create the message server-side. MQTT will then deliver the server-created message to connected clients.
|
|
293
293
|
- Use this if you prefer to avoid relying on the realtime command to create messages.
|
|
294
294
|
|
|
295
|
-
> Summary: **Always rupload via HTTP.** Then
|
|
295
|
+
> Summary: **Always rupload via HTTP.** Then **use the HTTP configure/broadcast endpoints as the primary, reliable method** to attach media to threads. Publishing an MQTT `send_item` referencing `upload_id` may work as a best-effort fallback on some servers, but it is not guaranteed. MQTT never carries the raw media bytes, only metadata/reference.
|
|
296
296
|
|
|
297
297
|
---
|
|
298
298
|
|
|
@@ -422,7 +422,7 @@ await mqtt.publish({
|
|
|
422
422
|
**A:** No — MQTT is not used for large raw bytes. The app uploads bytes via rupload HTTP.
|
|
423
423
|
|
|
424
424
|
- **Q:** *If I publish the MQTT `send_item` with `upload_id`, will the message appear in the thread?*
|
|
425
|
-
**A:**
|
|
425
|
+
**A:** Sometimes the realtime server accepts an MQTT `send_item` referencing a valid `upload_id`, but this behavior is not universally reliable across server versions, accounts, or configurations. For production reliability prefer the HTTP broadcast/configure endpoints; keep MQTT reference as a best-effort fallback.
|
|
426
426
|
|
|
427
427
|
- **Q:** *Do I need to call `/direct_v2/threads/broadcast/...` if I published MQTT?*
|
|
428
428
|
**A:** Often not — the APK pattern uses MQTT for the attach request. However, for absolute compatibility or for older server behavior, the HTTP configure/broadcast endpoints are a safe fallback.
|
|
@@ -2197,27 +2197,49 @@ async function sendVideoAsMqttReference({ ig, mqtt, videoBuffer, threadId, capti
|
|
|
2197
2197
|
|
|
2198
2198
|
const serverUploadId = (uploadResponse && uploadResponse.upload_id) ? uploadResponse.upload_id : uploadId;
|
|
2199
2199
|
|
|
2200
|
-
//
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
topic: constants.Topics.SEND_MESSAGE.id,
|
|
2216
|
-
qosLevel: 1,
|
|
2217
|
-
payload,
|
|
2200
|
+
// ATTACH VIA HTTP BROADCAST (preferred, reliable)
|
|
2201
|
+
// Attempt REST broadcast first (most reliable). This will create the direct message server-side
|
|
2202
|
+
// and let MQTT/clients receive the created message as normal sync.
|
|
2203
|
+
try {
|
|
2204
|
+
const broadcastResponse = await ig.request.send({
|
|
2205
|
+
url: '/direct_v2/threads/broadcast/upload_photo/',
|
|
2206
|
+
method: 'POST',
|
|
2207
|
+
form: {
|
|
2208
|
+
upload_id: serverUploadId,
|
|
2209
|
+
action: 'send_item',
|
|
2210
|
+
thread_ids: JSON.stringify([String(threadId)]),
|
|
2211
|
+
caption: caption || '',
|
|
2212
|
+
client_context: clientContext,
|
|
2213
|
+
},
|
|
2214
|
+
timeout: 60000,
|
|
2218
2215
|
});
|
|
2219
|
-
|
|
2220
|
-
|
|
2216
|
+
return { upload_id: serverUploadId, broadcastResponse };
|
|
2217
|
+
} catch (err) {
|
|
2218
|
+
// If REST broadcast fails for transient reasons, fall back to attempting an MQTT reference publish.
|
|
2219
|
+
// NOTE: MQTT 'reference' publish is not guaranteed to be accepted on all server versions or accounts.
|
|
2220
|
+
// Keep it as a fallback only — the HTTP broadcast above is the recommended, reliable method.
|
|
2221
|
+
try {
|
|
2222
|
+
const json = JSON.stringify({
|
|
2223
|
+
action: 'send_item',
|
|
2224
|
+
thread_id: String(threadId),
|
|
2225
|
+
item_type: 'media',
|
|
2226
|
+
upload_id: serverUploadId,
|
|
2227
|
+
text: caption || '',
|
|
2228
|
+
client_context: clientContext,
|
|
2229
|
+
timestamp: Date.now(),
|
|
2230
|
+
});
|
|
2231
|
+
const payload = await compressDeflate(json);
|
|
2232
|
+
await mqtt.publish({
|
|
2233
|
+
topic: constants.Topics.SEND_MESSAGE.id,
|
|
2234
|
+
qosLevel: 1,
|
|
2235
|
+
payload,
|
|
2236
|
+
});
|
|
2237
|
+
return { upload_id: serverUploadId, mqttFallback: true };
|
|
2238
|
+
} catch (err2) {
|
|
2239
|
+
// last-resort: return upload id and both errors for debugging
|
|
2240
|
+
return { upload_id: serverUploadId, broadcastError: err?.message || String(err), mqttError: err2?.message || String(err2) };
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2221
2243
|
}
|
|
2222
2244
|
```
|
|
2223
2245
|
|
|
@@ -2268,10 +2290,6 @@ async function sendVideoViaRestBroadcast({ ig, videoBuffer, threadId, caption =
|
|
|
2268
2290
|
}
|
|
2269
2291
|
```
|
|
2270
2292
|
|
|
2271
|
-
### FAQ notes
|
|
2272
|
-
- **Does MQTT send the file?** No — MQTT only transports the JSON reference (`upload_id`) telling the server to attach that already-uploaded file into the thread.
|
|
2273
|
-
- **Why use MQTT for reference instead of REST broadcast?** MQTT gives near-realtime messaging semantics; the server applies the `upload_id` to the thread (same result), but the heavy binary upload must be done via HTTP `rupload`.
|
|
2274
|
-
- **Can you skip rupload and only send MQTT?** No — server needs the binary available under the `upload_id`. If you send only MQTT without previously uploading, the server won't have the file to attach.
|
|
2275
2293
|
|
|
2276
2294
|
---
|
|
2277
2295
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodejs-insta-private-api-mqtt",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17",
|
|
4
4
|
"description": "Complete Instagram MQTT protocol with FULL iOS + Android support. 33 device presets (21 iOS + 12 Android). iPhone 16/15/14/13/12, iPad Pro, Samsung, Pixel, Huawei. Real-time DM messaging, view-once media extraction, sub-500ms latency.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|