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 config object for emails content url #1402

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

DmyMi
Copy link
Contributor

@DmyMi DmyMi commented Feb 28, 2024

As different projects have differently named configuration fields - a way to unify them and show email data correctly

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@@ -485,7 +486,8 @@ public static void AddApplicationServices(this WebApplicationBuilder builder)
services.AddEmailSender(
builder.Environment.IsDevelopment(),
mailConfig.SendGridKey,
builder => builder.Bind(configuration.GetSection(EmailOptions.SectionName)));
builder => builder.Bind(configuration.GetSection(EmailOptions.SectionName)))
.AddEmailRendererConfiguration(new EmailContentConfig(configuration.GetSection("Hosts")["BackendUrl"]));
Copy link
Contributor

Choose a reason for hiding this comment

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

(Logic) configuration.GetSection("Hosts")["BackendUrl"] - here string keys are different from mentioned in AuthCommonServiceExtensions.cs. Is it intended to have same thing named differently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry to have come back to this PR after a few months :) but had to do other email refactorings first. Yes the reason to create the config object is to unify the string keys because in their own projects they have own logic to be used that way and we wanted to reuse the keys without dublicating.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes the reason to create the config object is to unify the string keys ...

If I get you correctly, some other commit to this PR should be done soon, where all string literals be done as EmailContentConfig class constants and reused in both WebApi and Auth library, right?

If so, could PR be in Draft mode until that commit is done?

@@ -31,7 +32,8 @@ public static void AddAuthCommon(this IServiceCollection services, Configuration
services.AddEmailSender(
isDevelopment,
mailConfig.SendGridKey,
builder => builder.Bind(config.GetSection(EmailOptions.SectionName)));
builder => builder.Bind(config.GetSection(EmailOptions.SectionName)))
.AddEmailRendererConfiguration(new EmailContentConfig(config.GetSection("Identity")["Authority"]));
Copy link
Contributor

Choose a reason for hiding this comment

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

(Code style) Please consider storing string literals in related classes (see f.e. EmailOptions.SectionName one line above). Especially, when they are reused more than twice

@DmyMi DmyMi force-pushed the dmin/update_email_config branch from 61e4cbf to 993c8b0 Compare May 27, 2024 09:29
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

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