Files
social-media/backend/Modules/Notifications/Services/NotificationEventWriter.cs
Jonathan Bourdon df3e602015
Some checks failed
Backend CI/CD / build_and_deploy (push) Has been cancelled
Frontend CI/CD / build_and_deploy (push) Has been cancelled
feat: pivot to social media workflow app
2026-04-24 12:58:35 -04:00

31 lines
1.0 KiB
C#

using Socialize.Modules.Notifications.Contracts;
using Socialize.Modules.Notifications.Data;
namespace Socialize.Modules.Notifications.Services;
public class NotificationEventWriter(
AppDbContext dbContext)
: INotificationEventWriter
{
public async Task WriteAsync(NotificationEventWriteModel model, CancellationToken cancellationToken = default)
{
NotificationEvent notificationEvent = new()
{
Id = Guid.NewGuid(),
WorkspaceId = model.WorkspaceId,
ContentItemId = model.ContentItemId,
EventType = model.EventType,
EntityType = model.EntityType,
EntityId = model.EntityId,
Message = model.Message,
RecipientUserId = model.RecipientUserId,
RecipientEmail = model.RecipientEmail,
MetadataJson = model.MetadataJson,
CreatedAt = DateTimeOffset.UtcNow,
};
dbContext.NotificationEvents.Add(notificationEvent);
await dbContext.SaveChangesAsync(cancellationToken);
}
}