[go: up one dir, main page]

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

v1: add support for raw search fields #334

Open
wants to merge 5 commits into
base: v1
Choose a base branch
from

Conversation

ahornerr
Copy link

Hi there!

This is my first contribution to this library and I will say it's quite powerful!

I dug around this morning looking for ways to add arbitrary raw attributes to the search queries and was unable to do so. After further consideration it seems the best way would be to add native X-GM-RAW support to this library!

The specification can be found here https://developers.google.com/gmail/imap/imap-extensions but simply put, we can add a X-GM-RAW attribute to the search query.

I find this necessary to my use case and I believe others may also find it useful. I've added the correct logic and tests.

Thanks!

@codecov
Copy link
codecov bot commented Jan 18, 2020

Codecov Report

Merging #334 into master will increase coverage by 0.11%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #334      +/-   ##
==========================================
+ Coverage    73.4%   73.52%   +0.11%     
==========================================
  Files          32       32              
  Lines        3516     3531      +15     
==========================================
+ Hits         2581     2596      +15     
  Misses        642      642              
  Partials      293      293
Impacted Files Coverage Δ
search.go 64.4% <88.88%> (+2.27%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c79bafa...ff937cd. Read the comment docs.

Copy link
Collaborator
@foxcpp foxcpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks sane. Though, I think it is better to think about adding support for raw fields in the SEARCH command. There are more Gmail-specific search keys: X-GM-MSGID, X-GM-THRID, X-GM-LABELS.

@foxcpp foxcpp requested a review from emersion January 18, 2020 21:45
@emersion
Copy link
Owner

Agreed. I really don't want to support GMail's nonstandard flags upstream.

@ahornerr
Copy link
Author

@foxcpp @emersion This seems like a reasonable (and more flexible) request. I will make some changes.

@ahornerr
Copy link
Author

@emersion @foxcpp I've made some changes to generalize the raw search functionality. Originally I had Raw as a map[string][]interface{} but this made testing and repeatability tricky as Maps in Go are unsorted. By specifying them as an array we can ensure that they're always sorted in the same order. Let me know what you think!

@ahornerr ahornerr changed the title Added support for Gmail's X-GM-RAW search fields Added support for raw search fields Jan 19, 2020
@ahornerr ahornerr changed the title Added support for raw search fields Add support for raw search fields Jan 19, 2020
@ahornerr
Copy link
Author

Actually I don't think this will work. As is my current approach adds parenthesis around the value which Gmail doesn't interpret as a good command.

UID SEARCH CHARSET UTF-8 ... X-GM-RAW ("filename:docx OR filename:xlsx")
BAD Could not parse command

I'll have to go back to the drawing board with this and correct my issue.

@ahornerr
Copy link
Author

I've pushed up a better solution that I'm happy with.

@emersion emersion changed the base branch from master to v1 April 14, 2023 10:27
@emersion emersion changed the title Add support for raw search fields v1: add support for raw search fields Apr 15, 2024
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

Successfully merging this pull request may close these issues.

3 participants