-
Notifications
You must be signed in to change notification settings - Fork 88
User/omolemo/notifications framework #2479
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
Open
OmolemoBlessingLethuloe
wants to merge
6
commits into
main
Choose a base branch
from
user/omolemo/notifications-framework
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+7.19 KB
shesha-core/src/Shesha.Application/ConfigMigrations/package20241125_1033.shaconfig
Binary file not shown.
Binary file added
BIN
+3.89 KB
shesha-core/src/Shesha.Application/ConfigMigrations/package20241127_1431.shaconfig
Binary file not shown.
Binary file added
BIN
+24.6 KB
shesha-core/src/Shesha.Application/ConfigMigrations/package20241127_2044.shaconfig
Binary file not shown.
Binary file added
BIN
+9.51 KB
shesha-core/src/Shesha.Application/ConfigMigrations/package20241127_2131.shaconfig
Binary file not shown.
89 changes: 0 additions & 89 deletions
89
shesha-core/src/Shesha.Application/NotificationMessages/Dto/NotificationMessageDto.cs
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
...ha-core/src/Shesha.Application/NotificationMessages/Dto/NotificationTemplateMapProfile.cs
This file was deleted.
Oops, something went wrong.
53 changes: 18 additions & 35 deletions
53
shesha-core/src/Shesha.Application/NotificationMessages/NotificationMessageAppService.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,34 @@ | ||
using Abp.Domain.Repositories; | ||
using Shesha.Domain; | ||
using Shesha.Domain.Enums; | ||
using Shesha.DynamicEntities.Dtos; | ||
using Shesha.NotificationMessages.Dto; | ||
using Shesha.Notifications; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shesha.NotificationMessages; | ||
|
||
/// <summary> | ||
/// Notifications audit service | ||
/// </summary> | ||
public class NotificationMessageAppService : SheshaCrudServiceBase<NotificationMessage, NotificationMessageDto, Guid> | ||
namespace Shesha.NotificationMessages | ||
{ | ||
private readonly IShaNotificationDistributer _distributer; | ||
|
||
public NotificationMessageAppService(IRepository<NotificationMessage, Guid> repository, IShaNotificationDistributer distributer) : base(repository) | ||
{ | ||
_distributer = distributer; | ||
} | ||
|
||
/// <summary> | ||
/// Resend notification message with specified <paramref name="id"/> | ||
/// Notifications audit service | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <returns></returns> | ||
public async Task<bool> Resend(Guid id) | ||
public class NotificationMessageAppService : SheshaCrudServiceBase<NotificationMessage, DynamicDto<NotificationMessage, Guid>, Guid> | ||
{ | ||
var notificationMessage = await Repository.GetAsync(id); | ||
|
||
var dto = ObjectMapper.Map<NotificationMessageDto>(notificationMessage); | ||
await _distributer.ResendMessageAsync(dto); | ||
|
||
return true; | ||
} | ||
|
||
public async Task<DynamicDto<NotificationMessage, Guid>> MarkAsReadAsync(Guid id) | ||
{ | ||
if (id == Guid.Empty) | ||
throw new ArgumentNullException(nameof(id)); | ||
public NotificationMessageAppService(IRepository<NotificationMessage, Guid> repository) : base(repository) | ||
{ | ||
} | ||
|
||
var entity = await SaveOrUpdateEntityAsync<NotificationMessage>(id, item => | ||
public async Task<DynamicDto<NotificationMessage, Guid>> MarkAsReadAsync(Guid id) | ||
{ | ||
item.Opened = true; | ||
item.LastOpened = DateTime.UtcNow; | ||
}); | ||
if (id == Guid.Empty) | ||
throw new ArgumentNullException(nameof(id)); | ||
|
||
var entity = await SaveOrUpdateEntityAsync(id, (Action<NotificationMessage>)(item => | ||
{ | ||
item.ReadStatus = RefListNotificationReadStatus.Read; | ||
item.FirstDateRead = DateTime.UtcNow; | ||
})); | ||
|
||
return await MapToDynamicDtoAsync<NotificationMessage, Guid>(entity); | ||
return await MapToDynamicDtoAsync<NotificationMessage, Guid>(entity); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
shesha-core/src/Shesha.Application/Notifications/Configuration/Email/EmailSettings.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Shesha.Domain; | ||
|
||
namespace Shesha.Notifications.Configuration.Email | ||
{ | ||
/// <summary> | ||
/// Email settings | ||
/// </summary> | ||
public class EmailSettings | ||
{ | ||
/// <summary> | ||
/// If true, all emails are enabled | ||
/// </summary> | ||
public bool EmailsEnabled { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public NotificationGatewayConfig PreferredGateway { get; set; } | ||
|
||
/// <summary> | ||
/// If not null or empty the all outgoing emails will be sent to this email address, is used for testing only | ||
/// </summary> | ||
public string RedirectAllMessagesTo { get; set; } | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ha-core/src/Shesha.Application/Notifications/Configuration/Email/Gateways/SmtpSettings.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
namespace Shesha.Notifications.Configuration.Email.Gateways | ||
{ | ||
/// <summary> | ||
/// SMTP settings | ||
/// </summary> | ||
public class SmtpSettings | ||
{ | ||
/// <summary> | ||
/// SMTP Host name/IP. | ||
/// </summary> | ||
public string Host { get; set; } | ||
|
||
/// <summary> | ||
/// SMTP Port. | ||
/// </summary> | ||
public int Port { get; set; } | ||
|
||
/// <summary> | ||
/// User name to login to SMTP server. | ||
/// </summary> | ||
public string UserName { get; set; } | ||
|
||
/// <summary> | ||
/// Password to login to SMTP server. | ||
/// </summary> | ||
public string Password { get; set; } | ||
|
||
/// <summary> | ||
/// Domain name to login to SMTP server. | ||
/// </summary> | ||
public string Domain { get; set; } | ||
|
||
/// <summary> | ||
/// Domain name to login to Incoming server. | ||
/// </summary> | ||
public string IncomingServer { get; set; } | ||
|
||
/// <summary> | ||
/// Is SSL enabled? | ||
/// </summary> | ||
public bool EnableSsl { get; set; } | ||
|
||
/// <summary> | ||
/// Default from address. | ||
/// </summary> | ||
public string DefaultFromAddress { get; set; } | ||
|
||
/// <summary> | ||
/// Default display name. | ||
/// </summary> | ||
public string DefaultFromDisplayName { get; set; } | ||
|
||
/// <summary> | ||
/// Use SMTP relay | ||
/// If true, indicate that SMTP relay service will be used where it's needed (e.g. if the application needs to notify one person about the action that was performed by another person then real person's email address will be used for the 'from' address, otherwise 'Site Email' will be used) | ||
/// </summary> | ||
public bool UseSmtpRelay { get; set; } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ha-core/src/Shesha.Application/Notifications/Configuration/Email/IEmailGatewaySettings.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Shesha.Notifications.Configuration.Email.Gateways; | ||
using Shesha.Notifications.Configuration.Sms.Gateways; | ||
using Shesha.Settings; | ||
using Shesha.Sms; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shesha.Notifications.Configuration.Email | ||
{ | ||
[Category("Email Gateways")] | ||
public interface IEmailGatewaySettings: ISettingAccessors | ||
{ | ||
/// <summary> | ||
/// SMS Settings | ||
/// </summary> | ||
[Display(Name = "SMTP Gateway")] | ||
[Setting(NotificationGatewaySettingNames.SmtpGatewaySettings, EditorFormName = "smtp-gateway-settings")] | ||
ISettingAccessor<SmtpSettings> SmtpSettings { get; } | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
shesha-core/src/Shesha.Application/Notifications/Configuration/INotificationSettings.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Shesha.Notifications.Configuration.Email; | ||
using Shesha.Notifications.Configuration.Sms; | ||
using Shesha.Settings; | ||
using System.ComponentModel; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Shesha.Notifications.Configuration | ||
{ | ||
/// <summary> | ||
/// SMS Settings | ||
/// </summary> | ||
[Category("Notifications")] | ||
public interface INotificationSettings : ISettingAccessors | ||
{ | ||
/// <summary> | ||
/// SMS Settings | ||
/// </summary> | ||
[Display(Name = "Notifications Channels")] | ||
[Setting(NotificationSettingNames.NotificationSettings, EditorFormName = "notification-settings")] | ||
ISettingAccessor<NotificationSettings> NotificationSettings { get; } | ||
|
||
/// <summary> | ||
/// SMS Settings | ||
/// </summary> | ||
[Display(Name = "SMS Settings")] | ||
[Setting(NotificationSettingNames.SmsSettings, EditorFormName = "sms-settings")] | ||
ISettingAccessor<SmsSettings> SmsSettings { get; } | ||
|
||
/// <summary> | ||
/// SMTP Settings | ||
/// </summary> | ||
[Display(Name = "Email Settings")] | ||
[Setting(NotificationSettingNames.EmailSettings, EditorFormName = "email-settings")] | ||
ISettingAccessor<EmailSettings> EmailSettings { get; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ore/src/Shesha.Application/Notifications/Configuration/NotificationGatewaySettingNames.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shesha.Notifications.Configuration | ||
{ | ||
public static class NotificationGatewaySettingNames | ||
{ | ||
public const string ClickatellGatewaySettings = "Shesha.Notifications.Sms.Clickatell.Settings"; | ||
|
||
public const string SmtpGatewaySettings = "Shesha.Notifications.Email.Smtp.Settings"; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
shesha-core/src/Shesha.Application/Notifications/Configuration/NotificationSettingNames.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shesha.Notifications.Configuration | ||
{ | ||
public static class NotificationSettingNames | ||
{ | ||
public const string NotificationSettings = "Shesha.Notification.Settings"; | ||
|
||
public const string SmsSettings = "Shesha.Notification.SMS.Settings"; | ||
|
||
public const string EmailSettings = "Shesha.Notification.Email.Settings"; | ||
} | ||
} |
Oops, something went wrong.
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.
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.
EmailSettings is a settings class and it should be serializable, but NotificationGatewayConfig is an entity, it can't be serialized and saved as a setting. We can save only some kind of unique identifier here.
Please check naming of the property as well.
Preferred
means that we have some default implementation which are used when a gateway is not specified explicitly.Most probably the property should be
GatewayName
,GatewayTypeName
orGatewayUid