-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Cleanup the SMS settings #14171
Cleanup the SMS settings #14171
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,14 @@ | |
using Microsoft.Extensions.Localization; | ||
using OrchardCore.Navigation; | ||
using OrchardCore.Sms; | ||
using OrchardCore.Sms.Drivers; | ||
|
||
namespace OrchardCore.Admin; | ||
|
||
public class AdminMenu : INavigationProvider | ||
public class SmsAdminMenu : INavigationProvider | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could have kept it as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes the namespace should have been changed. But having SmsAdminMenu is better to me than AdminMenu. There are many AdminMenu classes in the project and makes it harder to search for a file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is what we do when possible for At least the namespace is wrong. |
||
{ | ||
protected readonly IStringLocalizer S; | ||
|
||
public AdminMenu(IStringLocalizer<AdminMenu> stringLocalizer) | ||
public SmsAdminMenu(IStringLocalizer<SmsAdminMenu> stringLocalizer) | ||
{ | ||
S = stringLocalizer; | ||
} | ||
|
@@ -29,7 +28,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) | |
.Add(S["SMS"], S["SMS"].PrefixPosition(), sms => sms | ||
.AddClass("sms") | ||
.Id("sms") | ||
.Action("Index", "Admin", new { area = "OrchardCore.Settings", groupId = SmsSettingsDisplayDriver.GroupId }) | ||
.Action("Index", "Admin", new { area = "OrchardCore.Settings", groupId = SmsConstants.SettingsGroupId }) | ||
.Permission(SmsPermissions.ManageSmsSettings) | ||
.LocalNav() | ||
) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,4 +5,6 @@ public class SmsConstants | |||||||||||||||||
public const string TwilioServiceName = "Twilio"; | ||||||||||||||||||
|
||||||||||||||||||
public const string ConsoleServiceName = "Console"; | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe another static class and fields so that we can use something like that Or keep the names in the options but don't register providers in the DI, only enlist types in place of resolution delegates, then activate the right one when resolving Lines 16 to 22 in 2349676
Or use directly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look at the way they providers are registers, we register a delegate not an instance. So the provider is not initialized until it is needed based on the DefaultProvider
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But you also have just before
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also a little typo, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea but isn't that definitions the type in the IoC it does not resolve it. It's is resolved at run time. Isn't it? I noticed the typo. I'll clean it up in the morning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing urgent, need to leave too, will see tomorrow. Yes, only resolved on demand, just to not add too much descriptors to lookup, but here only a few ones are added, for info at some point we decreased scoped services in favor of singletons, but still good to decrease both. I think that the twilio initialization need to be thread safe. |
||||||||||||||||||
|
||||||||||||||||||
public const string SettingsGroupId = "sms"; | ||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only for info as this PR is merged.
Not sure that's the best way to define constants.
Here could have been a const defined in the setiings =>
SmsSettings.GroupId
.Also I would have defined the constants and
SmsSettings
in theSms.Abstractions
.I saw a
SmsSettingsConfigurator
, why not using theConfiguration
term as we usualy do?In
TwilioSmsProvider
I sawEnsureClientIsIsInitializedAsync()
, does it need to be thread safe / atomic?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rather have it is constants because it is a value that should be used by all implementation. Implementation don't need to do a hard reference to the SMS module. I know you can simply type "sms". But I thought it would be better to have a reusable constant.
The twilio does not need to be atomic I just did it this way so I don't have to initialize the client multiple times is the same request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not against constants but how they are defined, for example I prefer
SmsSettings.GroupId
,SmsProvider.Twilio
and so on.Just saw that
EnsureClientIsIsInitializedAsync()
updates different fields of the twilio provider which is a singleton.