dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.99k stars 1.14k forks source link

ig.directThread.getByParticipants returns empty items #1430

Open tonydtran opened 3 years ago

tonydtran commented 3 years ago

Form

Put an [x] if you meet the condition, else leave [ ].

Requirements

Description

A specific description of your bug, so it's understandable to anyone. If you have pictures or videos to upload, please add a link like this: [title](url).

When I try to retrieve messages sent from specific users by using directThread.getByParticipants, I correctly receive the thread but the items property is empty. I checked in my instagram app and there is a text message. I tried with different accounts, different proxies and so on. I don't have this problem using ig.feed.directInbox or ig.feed.directPending.

Code

Add a meaningful section of your code here. If you are using TypeScript replace js with typescript.

router.post('/user', async function(req, res, next) {
  const { pk } = req.body;

  try {
    const result = await ig.directThread.getByParticipants([pk]);
    if (result.thread) {
      res.json({ messages: result.thread });
    } else {
      res.json({ messages: [] });
    }
  } catch(e) {
    const message = e.message;
    res.errorMessage = message;
  } finally {
    next();
  }
});

Thanks for your help

Nerixyz commented 3 years ago

Is the items property an empty array ([]), undefined or null?

Regardless of the value, you still have the thread's thread_id. You can use this to get the thread-feed.