fix fromMe in chat.fetchMessages (#2314)
* fix fromMe * Fix Test * fix crash in getchat --------- Co-authored-by: Shir Serlui <70711723+shirser121@users.noreply.github.com>
This commit is contained in:
parent
776c1b152e
commit
096e84b0a9
2 changed files with 11 additions and 1 deletions
|
|
@ -187,7 +187,7 @@ class Chat extends Base {
|
||||||
if (m.isNotification) {
|
if (m.isNotification) {
|
||||||
return false; // dont include notification messages
|
return false; // dont include notification messages
|
||||||
}
|
}
|
||||||
if (searchOptions && searchOptions.fromMe && m.id.fromMe !== searchOptions.fromMe) {
|
if (searchOptions && searchOptions.fromMe !== undefined && m.id.fromMe !== searchOptions.fromMe) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,16 @@ describe('Chat', function () {
|
||||||
expect(fetchedMsg.body).to.equal(msg.body);
|
expect(fetchedMsg.body).to.equal(msg.body);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can use fromMe=true when fetching messages sent in a chat to get only bot messages', async function () {
|
||||||
|
const messages = await chat.fetchMessages({fromMe: true});
|
||||||
|
expect(messages).to.have.lengthOf(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can use fromMe=false when fetching messages sent in a chat to get only non bot messages', async function () {
|
||||||
|
const messages = await chat.fetchMessages({fromMe: false});
|
||||||
|
expect(messages).to.have.lengthOf(0);
|
||||||
|
});
|
||||||
|
|
||||||
it('can get the related contact', async function () {
|
it('can get the related contact', async function () {
|
||||||
const contact = await chat.getContact();
|
const contact = await chat.getContact();
|
||||||
expect(contact).to.be.instanceOf(Contact);
|
expect(contact).to.be.instanceOf(Contact);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue