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

Add support for search query params to /latest endpoints #206

Closed
matchai opened this issue Nov 9, 2023 · 4 comments
Closed

Add support for search query params to /latest endpoints #206

matchai opened this issue Nov 9, 2023 · 4 comments

Comments

@matchai
Copy link

matchai commented Nov 9, 2023

When testing with emails, I'll often want to pull up the latest email sent by my test runner, but with tests running in parallel, /latest.html can bring about race conditions, showing the wrong email.

By allowing /latest endpoints to support search-like query params, I can avoid these race conditions by filtering by the sender or recipient, which can be unique per test.

@matchai matchai changed the title Add support for search query params to /latest Add support for search query params to /latest endpoints Nov 9, 2023
@axllent
Copy link
Owner

axllent commented Nov 10, 2023

Hi @matchai. I understand the issue you are having with a race condition. You can actually do this already, although it uses two API calls:

  1. /api/v1/search?query=<query>&limit=1 would return the latest message summary (JSON array) matching your query. This summary would include the database ID of the message.
  2. Using the ID, you could then fetch /view/<ID>.html

Does this not do what you are trying to achieve?

@matchai
Copy link
Author

matchai commented Nov 10, 2023

That totally works. As a presumably common use-case, it would be great to have a convenient way to do it at once.
No worries though if you consider it to be out of scope for the project ☺️

@axllent
Copy link
Owner

axllent commented Nov 11, 2023

@matchai I have just added this feature in v1.10.0. You can find more info on https://mailpit.axllent.org/docs/integration/. Please confirm this does what you expect?

@axllent
Copy link
Owner

axllent commented Nov 19, 2023

I'm closing this issue now as support for optional query parameters in /view/latest.html?query=... and /view/latest.txt?query=... was released a week ago in the previous version on Mailpit. Please feel free to reopen this issue if you experience any issues.

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