fmbiete / Z-Push-contrib

Z-Push fork with changes that I will try to contrib
GNU Affero General Public License v3.0
135 stars 62 forks source link

Search (IMAP): Unknown search criterion: BEFORE #247

Closed basbebe closed 8 years ago

basbebe commented 8 years ago

I have set up an IMAP backend and I know that dovecot's its with lucent works in it.

However, z-Push doesn't let me search from my iPhone.

This is what i get in my logs:

05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->Logon(): User 'XYZ' is authenticated on '{10.0.0.3:993/imap/ssl/novalidate-cert}'
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] ZPush::CommandNeedsPlainInput(16): false
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] StringStreamWrapper::Open(): len = 0
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] StringStreamWrapper::Open(): Using php://temp
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] StringStreamWrapper::Open(): len = 0
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] StringStreamWrapper::Open(): Using php://temp
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->GetMailboxSearchResults()
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] FileStateMachine->GetState() on file: '/usr/local/lib/z-push/k/7/vra7la9o317nf6lq0hsookk77k-bs-1451321984'
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->getImapIdFromFolderId('f342e2c2') = INBOX
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->GetMailboxSearchResults: Filter < BEFORE "2015-12-06T02:15:18.000Z" TEXT "SEARCHTEXT">
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->GetMailboxSearchResults: Recursive search INBOX
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->getFolderIdFromImapId('Junk') = 5dd1af53
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->getFolderIdFromImapId('Archive') = 3a2c6e22
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->getFolderIdFromImapId('Notes') = 84bd7446
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->getFolderIdFromImapId('Trash') = f530f6eb
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->getFolderIdFromImapId('Drafts') = b0924b95
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->getFolderIdFromImapId('Sent') = b51da160
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->getFolderIdFromImapId('INBOX') = f342e2c2
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->GetMailboxSearchResults: No messages found!
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] WBXMLEncoder->startWBXML() type: vnd.ms-sync.wbxml
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] WBXMLEncoder->endTag() WBXML output completed
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] Flushing 30, headers already sent? no
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->close_connection(): IMAP said: Unknown search criterion: BEFORE
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->close_connection(): IMAP said: Unknown search criterion: BEFORE
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->close_connection(): IMAP said: Unknown search criterion: BEFORE
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->close_connection(): IMAP said: Unknown search criterion: BEFORE
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->close_connection(): IMAP said: Unknown search criterion: BEFORE
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->close_connection(): IMAP said: Unknown search criterion: BEFORE
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->close_connection(): IMAP said: Unknown search criterion: BEFORE
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] BackendIMAP->close_connection(): disconnected from IMAP server
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] FileStateMachine->SetState() written 747 bytes on file: '/usr/local/lib/z-push/k/7/vra7la9o317nf6lq0hsookk77k-bs-1451321984'
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] LoopDetection->ProcessLoopDetectionTerminate()
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] Memory usage information: 1996600/2359296 - Execution time: 1.0534 - HTTP responde code: 200
05/01/2016 18:42:25 [26464] [DEBUG] [mail@xxx.yy] -------- End
fmbiete commented 8 years ago

I would say that your IMAP server doesn't support the BEFORE keyword https://tools.ietf.org/html/rfc3501#page-49

You can test it executing manually the SEARCH. This page explains how to do it: https://www.skytale.net/blog/archives/23-Manual-IMAP.html

basbebe commented 8 years ago

I checked and my IMAP server does understand the BEFORE keyword. However it doesn't understand the Date specification as it seems: 2015-12-06T02:15:18.000Z This one works: 2015-12-06 http://wiki2.dovecot.org/Tools/Doveadm/SearchQuery#section_date_specification

fmbiete commented 8 years ago

The referenced commit should fix the issue. We will discard the time/timezone information since it's not really useful and will break.

Let me know if it works.

basbebe commented 8 years ago

Search works now, thank you! However, I see in the logs that dovecot returns the search results pretty quickly but it takes a really long time for them to appear on the device. Is that normal behavior?

fmbiete commented 8 years ago

Yes, that's normal. The device has to parse all the messages found and is not really fast (even with the quad-cores, phones are slow).

basbebe commented 8 years ago

Thanks!