Skip to content

Conversation

sjennolkaya
Copy link

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

@Copilot 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" : ""));

@rnwood rnwood self-requested a review March 29, 2025 09:32
@rnwood
Copy link
Owner

rnwood commented Mar 29, 2025

Thanks for your contribution here.

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

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.

2 participants