Skip to content

Commit

Permalink
(#125) (#126) update the event type enumerator in blazor applciation
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintAngeLs committed May 30, 2024
1 parent fca59c5 commit 3125097
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ 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);

// Publish related events
// 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}");





}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace MiniSpace.Services.Notifications.Application.Events.External
{
[Message("friends")]
[Contract]
public class PendingFriendAccepted : IEvent
{
public Guid RequesterId { get; }
Expand Down
15 changes: 13 additions & 2 deletions MiniSpace.Web/src/MiniSpace.Web/DTO/Enums/NotificationEventType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{
<div>
<p><strong>Message:</strong> @RenderMessage(notification)</p>
<p><strong>Message:</strong> @notification.Details </p>
<p><strong>Date:</strong> @notification.CreatedAt.ToString("dd MMM yyyy")</p>
<p><strong>Status:</strong> @notification.Status</p>
<input type="hidden" value="@notification.NotificationId" />
Expand Down
1 change: 1 addition & 0 deletions MiniSpace.Web/src/MiniSpace.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddScoped<IReportsService, ReportsService>();

}


// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
Expand Down

0 comments on commit 3125097

Please sign in to comment.