Skip to content

Add new find method to api#1631

Closed
sjennolkaya wants to merge 4 commits intornwood:masterfrom
sjennolkaya:add-new-find-method-to-api
Closed

Add new find method to api#1631
sjennolkaya wants to merge 4 commits intornwood:masterfrom
sjennolkaya:add-new-find-method-to-api

Conversation

@sjennolkaya
Copy link
Copy Markdown

Added new method "Find" to the api, now we can search with different criteria (to, subject, content, datefrom).

@rnwood rnwood requested a review from Copilot March 29, 2025 09:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new search endpoint to the API by introducing a Find method in the MessagesController, enabling searches by various email criteria. Key changes include:

  • A new Find method in MessagesController using search criteria for filtering messages.
  • The creation of a SearchMessagesCriteria record in the ApiModel.
  • Additional tests in MessagesControllerTests to validate the new search functionality.

Reviewed Changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

File Description
Rnwood.Smtp4dev/Controllers/MessagesController.cs Added the Find method with search functionality and new ordering logic
Rnwood.Smtp4dev/ApiModel/SearchMessagesCriteria.cs Introduced a new record to encapsulate search criteria parameters
Rnwood.Smtp4dev.Tests/Controllers/MessagesControllerTests.cs Added tests validating the new Find method and adjusted existing test helper methods
Files not reviewed (2)
  • Rnwood.Smtp4dev/Properties/launchSettings.json: Language not supported
  • smtpserver/Rnwood.SmtpServer.Tests/Rnwood.SmtpServer.Tests.csproj: Language not supported
Comments suppressed due to low confidence (2)

Rnwood.Smtp4dev/Controllers/MessagesController.cs:103

  • [nitpick] The Find method is used for searching and does not modify any data; consider using [HttpGet] or [HttpPost] (with an appropriate request body binding) to better align with REST conventions.
[HttpPut]

Rnwood.Smtp4dev/Controllers/MessagesController.cs:109

  • Dynamically constructing the ordering parameter from a string may lead to runtime issues if an invalid sortColumn is provided. Consider implementing a mapping from allowed sort values to expressions to ensure type safety.
.OrderBy(sortColumn + (sortIsDescending ? " DESC" : ""));

Comment thread Rnwood.Smtp4dev.Tests/Controllers/MessagesControllerTests.cs
@rnwood rnwood self-requested a review March 29, 2025 09:32
@rnwood
Copy link
Copy Markdown
Owner

rnwood commented Mar 29, 2025

Thanks for your contribution here.

My only question is why use PUT instead of POST here?

@rnwood rnwood closed this Mar 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 7, 2026

Thank you for your contribution to smtp4dev! 🎉

Before we can merge your pull request, we need you to sign our Contributor License Agreement (CLA).

📝 Please read the CLA: Contributor License Agreement

✍️ To sign the CLA, please comment on this PR with exactly:

I have read the CLA Document and I hereby sign the CLA

This is a one-time requirement for new contributors. Thank you for your understanding! 🙏


I have read the CLA Document and I hereby sign the CLA


Sjennol Kaya seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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