Repository navigation
feat: refactor mailer client wiring and add validation wrapper - #2130
Merged
Merged
Conversation
This change simplifies how MailClient instances are constructed and used: - Introduce `NewMailClient` to encapsulate creation of the default `MailmeMailer` or `noopMailClient` based on configuration. - Add `NewMailerWithClient` to allow injecting a custom `MailClient`. - Extract email validation into `emailValidatorMailClient`, which wraps another `MailClient` and ensures `Validate` is always called before sending. Removed inline validation logic from `MailmeMailer`. - Update `TemplateMailer` to consistently use `MailClient` instead of the previous `Mailer` field. - Extend `noopMailClient` with an optional `Delay` field to simulate latency in tests. - Clean up struct definitions by removing redundant `EmailValidator` from `MailmeMailer`. Together, these changes make the mailer package easier to extend, improve separation of concerns, and provide hooks for testing latency and swapping in custom mail clients.
cstockton
force-pushed
the
cs/feat-mailer-cleanup-p1
branch
from
August 24, 2025 16:39
824caaf to
c686fe6
Compare
Pull Request Test Coverage Report for Build 17275011397Details
💛 - Coveralls |
hf
approved these changes
Aug 27, 2025
hf
pushed a commit
that referenced
this pull request
Aug 28, 2025
🤖 I have created a release *beep* *boop* --- ## [2.179.0](v2.178.0...v2.179.0) (2025-08-28) ### Features * add oauth2 client support ([#2098](#2098)) ([8fae015](8fae015)) * experimental own linking domains per provider ([#2119](#2119)) ([747bf3b](747bf3b)) * fetch email from snapchat oauth provider if available for consistency ([#2110](#2110)) ([7507822](7507822)) * implement link identity with oidc / native sign in ([#2108](#2108)) ([5f0ec87](5f0ec87)) * implements email-less accounts with oauth ([#2105](#2105)) ([9a61dae](9a61dae)) * introduce request-scoped background tasks & async mail sending ([#2126](#2126)) ([2c8ea61](2c8ea61)) * refactor mailer client wiring and add validation wrapper ([#2130](#2130)) ([68c40a6](68c40a6)) * support multiple `aud` for the external providers ([#2117](#2117)) ([ca5792e](ca5792e)) * use `slices.Contains` instead of for loops ([#2111](#2111)) ([9f22682](9f22682)) ### Bug Fixes * add `id-token` permission to ci ([#2143](#2143)) ([79209c0](79209c0)) * add missing param ([#2125](#2125)) ([c0b75f6](c0b75f6)) * change s3 artifact upload role ([#2145](#2145)) ([767e371](767e371)) * remove requirement of empty content-type on 204 ([#2128](#2128)) ([ecc97e0](ecc97e0)) * run release-please again ([#2144](#2144)) ([2560f14](2560f14)) * stripped binary now includes version ([#2147](#2147)) ([609f169](609f169)) * update copyright year in LICENSE ([#2142](#2142)) ([67fe0b0](67fe0b0)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
fadymak
pushed a commit
that referenced
this pull request
Sep 30, 2025
This change simplifies how MailClient instances are constructed and used: - Introduce `NewMailClient` to encapsulate creation of the default `MailmeMailer` or `noopMailClient` based on configuration. - Add `NewMailerWithClient` to allow injecting a custom `MailClient`. - Extract email validation into `emailValidatorMailClient`, which wraps another `MailClient` and ensures `Validate` is always called before sending. Removed inline validation logic from `MailmeMailer`. - Update `TemplateMailer` to consistently use `MailClient` instead of the previous `Mailer` field. - Extend `noopMailClient` with an optional `Delay` field to simulate latency in tests. - Clean up struct definitions by removing redundant `EmailValidator` from `MailmeMailer`. Together, these changes make the mailer package easier to extend, improve separation of concerns, and provide hooks for testing latency and swapping in custom mail clients. Co-authored-by: Chris Stockton <[email protected]>
fadymak
pushed a commit
that referenced
this pull request
Sep 30, 2025
🤖 I have created a release *beep* *boop* --- ## [2.179.0](v2.178.0...v2.179.0) (2025-08-28) ### Features * add oauth2 client support ([#2098](#2098)) ([8fae015](8fae015)) * experimental own linking domains per provider ([#2119](#2119)) ([747bf3b](747bf3b)) * fetch email from snapchat oauth provider if available for consistency ([#2110](#2110)) ([7507822](7507822)) * implement link identity with oidc / native sign in ([#2108](#2108)) ([5f0ec87](5f0ec87)) * implements email-less accounts with oauth ([#2105](#2105)) ([9a61dae](9a61dae)) * introduce request-scoped background tasks & async mail sending ([#2126](#2126)) ([2c8ea61](2c8ea61)) * refactor mailer client wiring and add validation wrapper ([#2130](#2130)) ([68c40a6](68c40a6)) * support multiple `aud` for the external providers ([#2117](#2117)) ([ca5792e](ca5792e)) * use `slices.Contains` instead of for loops ([#2111](#2111)) ([9f22682](9f22682)) ### Bug Fixes * add `id-token` permission to ci ([#2143](#2143)) ([79209c0](79209c0)) * add missing param ([#2125](#2125)) ([c0b75f6](c0b75f6)) * change s3 artifact upload role ([#2145](#2145)) ([767e371](767e371)) * remove requirement of empty content-type on 204 ([#2128](#2128)) ([ecc97e0](ecc97e0)) * run release-please again ([#2144](#2144)) ([2560f14](2560f14)) * stripped binary now includes version ([#2147](#2147)) ([609f169](609f169)) * update copyright year in LICENSE ([#2142](#2142)) ([67fe0b0](67fe0b0)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change simplifies how MailClient instances are constructed and used:
NewMailClientto encapsulate creation of the defaultMailmeMailerornoopMailClientbased on configuration.NewMailerWithClientto allow injecting a customMailClient.emailValidatorMailClient, which wraps anotherMailClientand ensuresValidateis always called before sending. Removed inline validation logic fromMailmeMailer.TemplateMailerto consistently useMailClientinstead of the previousMailerfield.noopMailClientwith an optionalDelayfield to simulate latency in tests.EmailValidatorfromMailmeMailer.Together, these changes make the mailer package easier to extend, improve separation of concerns, and provide hooks for testing latency and swapping in custom mail clients.