-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
My suggested changes to ensure better separation between copied and l…
…ocal code Allow copied code from core to use #if LOCALTEST This makes it simpler to maintain (almost) the code in multiple repositories greatly simplifying maintanance when copying changes.
- Loading branch information
Showing
9 changed files
with
94 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/Notifications/Core/Configuration/NotificationOrderConfig.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Altinn.Notifications.Core.Configuration; | ||
|
||
/// <summary> | ||
/// Configuration class for notification orders | ||
/// </summary> | ||
public class NotificationOrderConfig | ||
{ | ||
/// <summary> | ||
/// Default from address for email notifications | ||
/// </summary> | ||
public string DefaultEmailFromAddress { get; set; } = string.Empty; | ||
} |
2 changes: 1 addition & 1 deletion
2
src/Notifications/Core/Models/Notification/SendOperationResult.cs
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
#nullable enable | ||
using Altinn.Notifications.Core.Configuration; | ||
using Altinn.Notifications.Core.Models; | ||
using Altinn.Notifications.Core.Models.NotificationTemplate; | ||
using Altinn.Notifications.Core.Models.Orders; | ||
using Altinn.Notifications.Core.Repository.Interfaces; | ||
using Altinn.Notifications.Core.Services.Interfaces; | ||
|
||
using Microsoft.Extensions.Options; | ||
|
||
namespace Altinn.Notifications.Core.Services; | ||
|
||
/// <summary> | ||
|
@@ -20,12 +23,12 @@ public class EmailNotificationOrderService : IEmailNotificationOrderService | |
/// <summary> | ||
/// Initializes a new instance of the <see cref="EmailNotificationOrderService"/> class. | ||
/// </summary> | ||
public EmailNotificationOrderService(IOrderRepository repository, IGuidService guid, IDateTimeService dateTime) | ||
public EmailNotificationOrderService(IOrderRepository repository, IGuidService guid, IDateTimeService dateTime, IOptions<NotificationOrderConfig> config) | ||
{ | ||
_repository = repository; | ||
_guid = guid; | ||
_dateTime = dateTime; | ||
_defaultFromAddress = "[email protected]"; | ||
_defaultFromAddress = config.Value.DefaultEmailFromAddress; | ||
} | ||
|
||
/// <inheritdoc/> | ||
|
This file contains 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
30 changes: 30 additions & 0 deletions
30
src/Notifications/LocalTestNotifications/NotificationsServiceExtentions.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Altinn.Notifications.Core.Configuration; | ||
using Altinn.Notifications.Core.Repository.Interfaces; | ||
using Altinn.Notifications.Core.Services; | ||
using Altinn.Notifications.Core.Services.Interfaces; | ||
using Altinn.Notifications.Extensions; | ||
using Altinn.Notifications.Models; | ||
using Altinn.Notifications.Validators; | ||
using FluentValidation; | ||
using LocalTest.Notifications.Persistence.Repository; | ||
|
||
namespace LocalTest.Notifications.LocalTestNotifications; | ||
|
||
public static class NotificationsServiceExtentions | ||
{ | ||
public static void AddNotificationServices(this IServiceCollection services, string baseUrl) | ||
{ | ||
// Notifications services | ||
ValidatorOptions.Global.LanguageManager.Enabled = false; | ||
ResourceLinkExtensions.Initialize(baseUrl); | ||
|
||
services.Configure<NotificationOrderConfig>((c) => c.DefaultEmailFromAddress = "[email protected]"); | ||
|
||
services | ||
.AddSingleton<IValidator<EmailNotificationOrderRequestExt>, EmailNotificationOrderRequestValidator>() | ||
.AddSingleton<IOrderRepository, LocalOrderRepository>() | ||
.AddSingleton<IGuidService, GuidService>() | ||
.AddSingleton<IDateTimeService, DateTimeService>() | ||
.AddSingleton<IEmailNotificationOrderService, EmailNotificationOrderService>(); | ||
} | ||
} |
This file contains 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