diff --git a/src/structures/Chat.js b/src/structures/Chat.js index f60aea1..9c09422 100644 --- a/src/structures/Chat.js +++ b/src/structures/Chat.js @@ -187,7 +187,7 @@ class Chat extends Base { if (m.isNotification) { 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 true; diff --git a/tests/structures/chat.js b/tests/structures/chat.js index 6148485..a0b5296 100644 --- a/tests/structures/chat.js +++ b/tests/structures/chat.js @@ -61,6 +61,16 @@ describe('Chat', function () { 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 () { const contact = await chat.getContact(); expect(contact).to.be.instanceOf(Contact);