Skip to content

Notification Library for Easify platform

License

Notifications You must be signed in to change notification settings

LittleBlocks/LittleBlocks.Notifications

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LittleBlocks - Notification Services

The project consist of several packages which facilitate sending notifications. It covers the following scenarios: Release CI

  1. Rendering the output message content (Current support is for handle bars using https://github.com/Antaris/FuManchu library)

  2. Sending messages to multiple audiences using Smtp protocol (It has been implemented using https://github.com/jstedfast/MailKit)

Usage

Installation

Using NuGet

Install-Package LittleBlocks.Notifications

Using dotnet cli

dotnet add package LittleBlocks.Notifications

Configuration

There is an extension which help to setup the service for IServiceCollection.

services.AddNotification(configuration)

which is adding the following services to the DI container

services.AddOptions().Configure<NotificationOptions>(configuration.GetSection(nameof(NotificationOptions)));
services.AddOptions().Configure<SmtpOptions>(configuration.GetSection(nameof(SmtpOptions)));

services.AddTransient<ITemplateProvider, FileBasedTemplateProvider>();
services.AddTransient<IMessagingService, MailKitMessagingService>();
services.AddTransient<ITemplateContentRenderer, HandleBarsTemplateContentRenderer>();
services.AddTransient<ITemplateRenderer, TemplateRenderer>();
services.AddTransient<INotificationService, NotificationService>();

You should notice every one of the services can be customize in order to implement something different.

Also the following sections need to be added to the appsettings.json file.

"NotificationOptions": {
    "Sender": "sender email address",
    "Profiles": [
        {
            "ProfileName": "profile name",
            "Audiences": [
                {"Email": "email or distribution group name" }
            ]
        },
    ],
    "Templates": [
        {
            "Name": "template name",
            "Path": "template default location relative to application"
        },
    ]
},
"SmtpOptions": {
    "Server": "Smtp server name",
    "LocalDomain": "LittleBlocks",
    "Port": "Optional. Default to 25"
}

Then you can inject INotificationService to your classes to send the email.

Note: Use Relay Messaging so there is no setup to be made on application servers to support smtp. Also the sender can be a fake email address or even a descriptive email address.

About

Notification Library for Easify platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.9%
  • Harbour 0.1%