@eryxenx/insta-chat 2.0.6 → 2.0.7

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/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ All notable changes to `@eryxenx/insta-chat` are documented here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/) and uses
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [2.0.7] - 2026-10-11
8
+
9
+ ### Fixed
10
+
11
+ - **`unsendMessage` silently failed for a message the bot did not send in this
12
+ process.** The thread of the id being unsent was resolved only from the
13
+ in-memory `messageID -> threadID` map, so unsending a message sent before a
14
+ restart (or a reply to someone else's message) threw `Unknown thread for
15
+ message` internally and returned `false` — `/unsend` appeared to do nothing.
16
+ `unsendMessage(messageID, callback?, threadID?)` now accepts the thread
17
+ explicitly, and the normalizer remembers the replied-to message id (whose
18
+ thread is known) so the map lookup succeeds. The thread the message was seen
19
+ in is always a safe explicit value for `/unsend`.
20
+
7
21
  ## [2.0.6] - 2026-10-10
8
22
 
9
23
  ### Added
package/DOCS.md CHANGED
@@ -58,7 +58,7 @@ Facebook-Chat-API shape. Its methods live one-per-file under
58
58
 
59
59
  | Group | Methods |
60
60
  |-------|---------|
61
- | messaging | `sendMessage(form, threadID, cb?, replyToMessage?)`, `sendMessageSync`, `editMessage(text, messageID)`, `unsendMessage(messageID)`, `setMessageReaction(emoji, messageID, cb?, threadID?)`, `sendTypingIndicator`, `markAsRead`, `shareContact`, `resolvePhotoUrl` |
61
+ | messaging | `sendMessage(form, threadID, cb?, replyToMessage?)`, `sendMessageSync`, `editMessage(text, messageID)`, `unsendMessage(messageID, cb?, threadID?)`, `setMessageReaction(emoji, messageID, cb?, threadID?)`, `sendTypingIndicator`, `markAsRead`, `shareContact`, `resolvePhotoUrl` |
62
62
  | threads | `getThreadInfo`, `getThreadList`, `getThreadHistory` |
63
63
  | users | `getUserInfo`, `getUID`, `getProfilePictureUrl` |
64
64
  | account | `getCurrentUserID`, `getAppState`, `getCookies`, `setOptions` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eryxenx/insta-chat",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": " Unofficial Instagram Chat API for Node.js | Build Instagram DM bots on personal accounts \u2014 send messages, media, voice notes, reactions, edit & unsend, listen for incoming chats. No browser at runtime",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "CHANGELOG.md"
24
24
  ],
25
25
  "scripts": {
26
- "test": "node test/smoke.js && node test/antiSuspension.test.js && node test/replyContent.test.js && node test/edit.test.js && node test/sendReply.test.js && node test/client.test.js && node test/relayError.test.js && node test/safetyWiring.test.js && node test/mediaOrder.test.js && node test/sessionSafety.test.js && node test/emptySend.test.js && node test/pollFloor.test.js",
26
+ "test": "node test/smoke.js && node test/antiSuspension.test.js && node test/replyContent.test.js && node test/edit.test.js && node test/sendReply.test.js && node test/client.test.js && node test/relayError.test.js && node test/safetyWiring.test.js && node test/mediaOrder.test.js && node test/sessionSafety.test.js && node test/emptySend.test.js && node test/pollFloor.test.js && node test/unsend.test.js",
27
27
  "build": "node scripts/build.js"
28
28
  },
29
29
  "keywords": [
@@ -5,12 +5,16 @@
5
5
  * Original author credit must be retained in all copies and derivatives.
6
6
  */
7
7
 
8
- // fca.unsendMessage(messageID) — the thread is resolved from the id.
8
+ // fca.unsendMessage(messageID, callback, threadID) — the thread may be passed
9
+ // explicitly; otherwise it is resolved from the id. A bot that only knows the
10
+ // replied-to message id (it did not send that message in this process, e.g.
11
+ // after a restart) cannot resolve the thread, so the explicit thread is what
12
+ // makes /unsend work reliably.
9
13
  module.exports = function (client) {
10
- return async function unsendMessage(messageID, callback) {
14
+ return async function unsendMessage(messageID, callback, threadID) {
11
15
  const cb = typeof callback === "function" ? callback : null;
12
16
  try {
13
- const tid = client._resolveThread(messageID);
17
+ const tid = client._resolveThread(messageID, threadID);
14
18
  const ok = await client.api.unsendMessage(tid, String(messageID));
15
19
  if (cb) cb(null, ok);
16
20
  return ok;
@@ -29,7 +29,7 @@ class InstaContext {
29
29
  }
30
30
 
31
31
  unsend(messageID, callback) {
32
- return this.client.unsendMessage(messageID, callback);
32
+ return this.client.unsendMessage(messageID, callback, this.threadID);
33
33
  }
34
34
 
35
35
  edit(text, messageID, callback) {
@@ -139,6 +139,12 @@ class EventNormalizer {
139
139
  // client must know which thread it belongs to.
140
140
  if (typeof this.client.rememberThread === "function") {
141
141
  this.client.rememberThread(event.messageID, threadID);
142
+ // Remember the replied-to message too: /unsend resolves its thread from
143
+ // that id, and the bot may be unssending a message it sent in an earlier
144
+ // process (so it is not in _msgThread otherwise).
145
+ if (event.messageReply && event.messageReply.messageID) {
146
+ this.client.rememberThread(event.messageReply.messageID, threadID);
147
+ }
142
148
  }
143
149
 
144
150
  return event;