diff --git a/MiniSpace.Services.Friends/src/MiniSpace.Services.Friends.Application/Commands/Handlers/PendingFriendAcceptHandler.cs b/MiniSpace.Services.Friends/src/MiniSpace.Services.Friends.Application/Commands/Handlers/PendingFriendAcceptHandler.cs index b07d049f..01714224 100644 --- a/MiniSpace.Services.Friends/src/MiniSpace.Services.Friends.Application/Commands/Handlers/PendingFriendAcceptHandler.cs +++ b/MiniSpace.Services.Friends/src/MiniSpace.Services.Friends.Application/Commands/Handlers/PendingFriendAcceptHandler.cs @@ -46,7 +46,9 @@ public async Task HandleAsync(PendingFriendAccept command, CancellationToken can // Save the updated FriendRequest states await _studentRequestsRepository.UpdateAsync(command.RequesterId, inviterRequests.FriendRequests); await _studentRequestsRepository.UpdateAsync(command.FriendId, inviteeRequests.FriendRequests); - + + var pendingFriendAcceptedEvent = new PendingFriendAccepted(command.RequesterId, command.FriendId); + await _messageBroker.PublishAsync(pendingFriendAcceptedEvent); // Create Friend relationships in both directions CreateAndAddFriends(command.RequesterId, command.FriendId, FriendState.Accepted); @@ -54,8 +56,7 @@ public async Task HandleAsync(PendingFriendAccept command, CancellationToken can // var events = _eventMapper.MapAll(new Core.Events.PendingFriendAccepted(command.RequesterId, command.FriendId)); // await _messageBroker.PublishAsync(events); - var pendingFriendAcceptedEvent = new PendingFriendAccepted(command.RequesterId, command.FriendId); - await _messageBroker.PublishAsync(pendingFriendAcceptedEvent); + } private FriendRequest FindFriendRequest(StudentRequests inviter, StudentRequests invitee, Guid inviterId, Guid inviteeId) diff --git a/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Application/Events/External/Handlers/PendingFriendRequestAcceptedHandler.cs b/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Application/Events/External/Handlers/PendingFriendRequestAcceptedHandler.cs index 50301a03..7d7bc0f7 100644 --- a/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Application/Events/External/Handlers/PendingFriendRequestAcceptedHandler.cs +++ b/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Application/Events/External/Handlers/PendingFriendRequestAcceptedHandler.cs @@ -65,11 +65,6 @@ public async Task HandleAsync(PendingFriendAccepted @event, CancellationToken ca studentNotifications.AddNotification(notification); _logger.LogInformation($"Adding notification to StudentNotifications for UserId={@event.RequesterId}"); - await _studentNotificationsRepository.AddOrUpdateAsync(studentNotifications); - _logger.LogInformation($"Updated StudentNotifications for UserId={@event.RequesterId}"); - - - var notificationCreatedEvent = new NotificationCreated( notificationId: notification.NotificationId, userId: notification.UserId, @@ -83,6 +78,13 @@ public async Task HandleAsync(PendingFriendAccepted @event, CancellationToken ca await _messageBroker.PublishAsync(notificationCreatedEvent); _logger.LogInformation($"Published enhanced NotificationCreated event for UserId={notification.UserId}"); + await _studentNotificationsRepository.AddOrUpdateAsync(studentNotifications); + _logger.LogInformation($"Updated StudentNotifications for UserId={@event.RequesterId}"); + + + + + } } } diff --git a/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Application/Events/External/PendingFriendAccepted.cs b/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Application/Events/External/PendingFriendAccepted.cs index 366cddd5..1bcbb728 100644 --- a/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Application/Events/External/PendingFriendAccepted.cs +++ b/MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Application/Events/External/PendingFriendAccepted.cs @@ -3,7 +3,7 @@ namespace MiniSpace.Services.Notifications.Application.Events.External { - [Message("friends")] + [Contract] public class PendingFriendAccepted : IEvent { public Guid RequesterId { get; } diff --git a/MiniSpace.Web/src/MiniSpace.Web/DTO/Enums/NotificationEventType.cs b/MiniSpace.Web/src/MiniSpace.Web/DTO/Enums/NotificationEventType.cs index d258a617..d683c3a8 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/DTO/Enums/NotificationEventType.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/DTO/Enums/NotificationEventType.cs @@ -3,11 +3,22 @@ namespace MiniSpace.Web.DTO.Enums public enum NotificationEventType { NewFriendRequest, - NewPost, - NewEvent, FriendRequestAccepted, + NewEvent, + EventDeleted, + EventNewSignUp, + EventNewSignUpFriend, + StudentCancelledSignedUpToEvent, + StudentShowedInterestInEvent, + StudentCancelledInterestInEvent, + EventParticipantAdded, + EventParticipantRemoved, + PostCreated, + PostUpdated, MentionedInPost, EventReminder, + PasswordResetRequest, + UserSignUp, Other } } \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/DTO/Notifications/NotificationDto.cs b/MiniSpace.Web/src/MiniSpace.Web/DTO/Notifications/NotificationDto.cs index f1f65121..19fea184 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/DTO/Notifications/NotificationDto.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/DTO/Notifications/NotificationDto.cs @@ -16,5 +16,6 @@ public class NotificationDto public DateTime? UpdatedAt { get; set; } public Guid? RelatedEntityId { get; set; } public NotificationEventType EventType { get; set; } + public string Details { get; set; } } } \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Notifications/Notification.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Notifications/Notification.razor index 52938f6a..aeb7160f 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Notifications/Notification.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Notifications/Notification.razor @@ -26,6 +26,7 @@ {

Message: @RenderMessage(notification)

+

Message: @notification.Details

Date: @notification.CreatedAt.ToString("dd MMM yyyy")

Status: @notification.Status

diff --git a/MiniSpace.Web/src/MiniSpace.Web/Startup.cs b/MiniSpace.Web/src/MiniSpace.Web/Startup.cs index a80dae50..e4dc2e45 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Startup.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Startup.cs @@ -81,6 +81,7 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); } + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)