Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search with keyword fails #152

Open
lacivert opened this issue Sep 13, 2017 · 4 comments
Open

search with keyword fails #152

lacivert opened this issue Sep 13, 2017 · 4 comments

Comments

@lacivert
Copy link
Contributor

lacivert commented Sep 13, 2017

I try this query for search:

query = {keyword: '\\Flagged'}

client.search('INBOX', query, {byUid: true}).then((result) => {
  //... doSomething();
 })

I get this:

[DEBUG][2017-09-13T20:14:17.001Z][1][[email protected]][imap.mail.com] S: W5.p OK [READ-WRITE] SELECT completed
[DEBUG][2017-09-13T20:14:17.001Z][1][[email protected]][imap.mail.com] C: W4 UID SEARCH KEYWORD "\\Flagged"
[DEBUG][2017-09-13T20:14:17.002Z][1][[email protected]][imap.mail.com] Entering state: 4
[DEBUG][2017-09-13T20:14:17.129Z][1][[email protected]][imap.mail.com] S: W4 BAD expected atom instead of "end of data"
(node:23260) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: expected atom instead of "end of data"

Interestingly I found this online:
lefcha/imapfilter#110

And the answer says, the problem is about double quotation on KEYWORD line:

You are right, the double quotation shouldn't be there. Thank you very much for reporting this!

But I cannot find where to change and try again with single quotes instead of double ones.

Is the approach right? Or the problem is something else?

@andris9
Copy link
Member

andris9 commented Sep 14, 2017

If you are using standard flags, then you should consider not using the KEYWORD search term but the flag term:

query = {flagged: true}

For every standard flag there's flagname: true and unflagname: true

@lacivert
Copy link
Contributor Author

@andris9 thank you, but the same problem happens for custom flag as well.

var query = {keyword: '$transferred'};

client.search('INBOX', query, {byUid: true}).then((result) => {
  //... doSomething();
})

The result:

[DEBUG][2017-09-14T13:05:45.775Z][1][[email protected]][imap.mail.com] Connection established, ready to roll!
[DEBUG][2017-09-14T13:05:45.775Z][1][[email protected]][imap.mail.com] Searching in INBOX ...
[DEBUG][2017-09-14T13:05:45.777Z][1][[email protected]][imap.mail.com] Opening INBOX ...
[DEBUG][2017-09-14T13:05:45.777Z][1][[email protected]][imap.mail.com] C: W5.p SELECT "INBOX"
[DEBUG][2017-09-14T13:05:45.867Z][1][[email protected]][imap.mail.com] S: * 3 EXISTS
[DEBUG][2017-09-14T13:05:45.867Z][1][[email protected]][imap.mail.com] S: * 0 RECENT
[DEBUG][2017-09-14T13:05:45.868Z][1][[email protected]][imap.mail.com] S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
[DEBUG][2017-09-14T13:05:45.868Z][1][[email protected]][imap.mail.com] S: * OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen "\\*")] Unlimited
[DEBUG][2017-09-14T13:05:45.869Z][1][[email protected]][imap.mail.com] S: * OK [UNSEEN 1] Message 1 is first unseen
[DEBUG][2017-09-14T13:05:45.869Z][1][[email protected]][imap.mail.com] S: * OK [UIDNEXT 4] Predicted next UID
[DEBUG][2017-09-14T13:05:45.869Z][1][[email protected]][imap.mail.com] S: * OK [UIDVALIDITY 1489584140] UIDs valid
[DEBUG][2017-09-14T13:05:45.870Z][1][[email protected]][imap.mail.com] S: W5.p OK [READ-WRITE] SELECT completed
[DEBUG][2017-09-14T13:05:45.870Z][1][[email protected]][imap.mail.com] C: W4 UID SEARCH KEYWORD "$transferred"
[DEBUG][2017-09-14T13:05:45.871Z][1][[email protected]][imap.mail.com] Entering state: 4
[DEBUG][2017-09-14T13:05:45.936Z][1][[email protected]][imap.mail.com] S: W4 BAD expected atom instead of "end of data"
(node:23832) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: expected atom instead of "end of data"
(node:23832) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@lacivert
Copy link
Contributor Author

I tried with a keyword non-dollar sign on start as well: 'transferred', no luck

@andris9
Copy link
Member

andris9 commented Sep 14, 2017

I did some changes with the SEARCH builder, could you try the search-keyword-atom branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants