Catspeak.Shared.Notification
2.7.1
dotnet add package Catspeak.Shared.Notification --version 2.7.1
NuGet\Install-Package Catspeak.Shared.Notification -Version 2.7.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Catspeak.Shared.Notification" Version="2.7.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Catspeak.Shared.Notification" Version="2.7.1" />
<PackageReference Include="Catspeak.Shared.Notification" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Catspeak.Shared.Notification --version 2.7.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Catspeak.Shared.Notification, 2.7.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Catspeak.Shared.Notification@2.7.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Catspeak.Shared.Notification&version=2.7.1
#tool nuget:?package=Catspeak.Shared.Notification&version=2.7.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Catspeak.Shared.Notification
Shared notification services for Catspeak applications. Supports Firestore in-app notifications, SMTP email (via MailKit), and background processing via System.Threading.Channels.
Features
- INotificationService - High-level notification API
- INotificationOrchestrator - Queue-based background processing
- IFirestoreNotificationService - Firestore in-app notifications
- IEmailSender - SMTP email sending via MailKit
- OtpEmailTemplate - Static helper for OTP email templates
- Background processing -
System.Threading.Channelsfor async notification dispatch
Installation
dotnet add package Catspeak.Shared.Notification
Configuration
// Program.cs or Startup.cs
builder.Services.AddCatspeakNotification(options =>
{
options.Provider = NotificationProvider.Firestore;
options.Firestore.ProjectId = "your-firestore-project-id";
options.Smtp.Host = "smtp.gmail.com";
options.Smtp.Port = 587;
options.Smtp.Username = "your-smtp-user";
options.Smtp.Password = "your-smtp-password";
options.Smtp.FromEmail = "noreply@catspeak.com.vn";
options.Smtp.FromName = "Cat Speak";
options.Smtp.ReplyToEmail = "support@catspeak.com.vn";
options.Smtp.ReplyToName = "Cat Speak Support";
// Fallback transport (personal Gmail). Used only when the primary
// provider fails and the message allows fallback (never broadcast).
options.Smtp.FallbackHost = "smtp.gmail.com";
options.Smtp.FallbackPort = 587;
options.Smtp.FallbackUsername = "catspeak.vn@gmail.com";
options.Smtp.FallbackPassword = "<gmail-app-password>";
options.Smtp.FallbackFromEmail = "catspeak.vn@gmail.com";
// Internal recipients (read by admin-notification flows).
options.AdminEmails.Support = "support@catspeak.com.vn";
options.AdminEmails.Tech = "tech@catspeak.com.vn";
});
Configuration Keys (flat structure)
| Key | Description |
|---|---|
Firestore:ProjectId |
Google Firestore project ID |
Smtp:Host |
SMTP server host |
Smtp:Port |
SMTP server port (default: 587) |
Smtp:Username |
SMTP auth username |
Smtp:Password |
SMTP auth password |
Smtp:FromEmail |
Sender email address |
Smtp:FromName |
Sender display name (default: "Cat Speak") |
Smtp:ReplyToEmail |
Reply-To email address |
Smtp:ReplyToName |
Reply-To display name |
Smtp:FallbackHost |
Fallback SMTP host (personal Gmail). Empty = no fallback |
Smtp:FallbackPort |
Fallback SMTP port (default: 587) |
Smtp:FallbackUsername |
Fallback SMTP username (defaults to Smtp:Username) |
Smtp:FallbackPassword |
Fallback SMTP password (defaults to Smtp:Password) |
Smtp:FallbackFromEmail |
Fallback sender address. Empty = no fallback |
Smtp:FallbackFromName |
Fallback sender name (default: "Cat Speak") |
AdminEmails:Support |
Internal support inbox (contact/instructor-apply notices) |
AdminEmails:Tech |
Internal tech inbox (bug-report notices) |
Monitoring
Email failover and broadcast retries emit structured logs with stable event IDs.
Alert when FallbackUsed spikes (primary provider throttling) or BroadcastDropped appears:
| EventId | Name | Meaning |
|---|---|---|
| 6101 | PrimarySendRetrying |
Primary send failed transiently, backing off before retry |
| 6102 | FallbackUsed |
Retries exhausted, message rerouted to Gmail fallback (X-Fallback: gmail) |
| 6103 | BroadcastRequeued |
Broadcast has no fallback, requeued once (emailRetryCount) |
| 6104 | BroadcastDropped |
Broadcast failed after the single requeue, message dropped |
Suggested alert: more than 10 FallbackUsed (6102) in 5 minutes → primary quota/auth issue, check Resend dashboard.
Usage
Send In-App Notification
var notificationService = serviceProvider.GetRequiredService<INotificationService>();
await notificationService.SendNotificationAsync(new NotificationRequest
{
UserId = 123,
Title = "Welcome!",
Body = "Your account has been created.",
Type = "welcome",
Channel = NotificationChannels.InApp
});
Send Email Notification
await notificationService.SendNotificationAsync(new NotificationRequest
{
UserId = 123,
Channel = NotificationChannels.Email,
EmailAddress = "user@example.com",
EmailSubject = "Verify your email",
EmailHtmlBody = "<h1>Your OTP: 123456</h1>"
});
Send OTP Email
var (subject, htmlBody) = OtpEmailTemplate.GenerateOtpEmail(
username: "JohnDoe",
otp: "123456",
expiryMinutes: 10,
purpose: "Password Reset");
await emailSender.SendEmailAsync("user@example.com", subject, htmlBody);
Queue Background Notification
var orchestrator = serviceProvider.GetRequiredService<INotificationOrchestrator>();
await orchestrator.EnqueueAsync(new NotificationMessage
{
UserId = 123,
Title = "New message",
Body = "You have a new message",
Type = "chat",
Channel = NotificationChannels.Both,
EmailAddress = "user@example.com",
EmailSubject = "New message from Chat",
EmailHtmlBody = "<p>You have a new message</p>"
});
Dependencies
- Google.Cloud.Firestore
- MailKit
- Microsoft.Extensions.DependencyInjection.Abstractions
- Microsoft.Extensions.Logging.Abstractions
- Microsoft.Extensions.Options
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Google.Cloud.Firestore (>= 4.3.0)
- MailKit (>= 4.16.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.