Skip to content

Commit

Permalink
(#433) users: update notificationPreffernece dto and commands
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintAngeLs committed Oct 11, 2024
1 parent ed5efe2 commit 8af5559
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task HandleAsync(UpdateUserNotificationPreferences command, Cancell
var commandJson = JsonSerializer.Serialize(command);
Console.WriteLine($"Received UpdateUserNotificationPreferences command: {commandJson}");

// Create the updated NotificationPreferences object
// Create the updated NotificationPreferences object, including new properties
var notificationPreferences = new NotificationPreferences(
command.SystemLogin,
command.InterestBasedEvents,
Expand All @@ -38,12 +38,15 @@ public async Task HandleAsync(UpdateUserNotificationPreferences command, Cancell
command.EventsIAmInterestedInNotification,
command.EventsIAmSignedUpToNotification,
command.PostsOfPeopleIFollowNotification,
command.EventNotificationForPeopleIFollow
command.EventNotificationForPeopleIFollow,
command.NewFriendsRequests,
command.MyRequestsAccepted,
command.FriendsPostsNotifications
);

await _userNotificationPreferencesRepository.UpdateNotificationPreferencesAsync(command.StudentId, notificationPreferences);
await _userNotificationPreferencesRepository.UpdateNotificationPreferencesAsync(command.UserId, notificationPreferences);

var student = await _studentRepository.GetAsync(command.StudentId);
var student = await _studentRepository.GetAsync(command.UserId);
if (student != null)
{
student.SetEmailNotifications(command.EmailNotifications);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace MiniSpace.Services.Students.Application.Commands
{
public class UpdateUserNotificationPreferences : ICommand
{
public Guid StudentId { get; set; }
public Guid UserId { get; set; }
public bool EmailNotifications { get; set; }

public bool SystemLogin { get; set; }
Expand All @@ -23,12 +23,18 @@ public class UpdateUserNotificationPreferences : ICommand
public bool PostsOfPeopleIFollowNotification { get; set; }
public bool EventNotificationForPeopleIFollow { get; set; }

public UpdateUserNotificationPreferences(Guid studentId, bool emailNotifications, bool systemLogin, bool interestBasedEvents,
// New properties for friend requests and post notifications
public bool NewFriendsRequests { get; set; }
public bool MyRequestsAccepted { get; set; }
public bool FriendsPostsNotifications { get; set; }

public UpdateUserNotificationPreferences(Guid userId, bool emailNotifications, bool systemLogin, bool interestBasedEvents,
bool eventNotifications, bool commentsNotifications, bool postsNotifications, bool eventRecommendation,
bool friendsRecommendation, bool friendsPosts, bool postsRecommendation, bool eventsIAmInterestedInNotification,
bool eventsIAmSignedUpToNotification, bool postsOfPeopleIFollowNotification, bool eventNotificationForPeopleIFollow)
bool eventsIAmSignedUpToNotification, bool postsOfPeopleIFollowNotification, bool eventNotificationForPeopleIFollow,
bool newFriendsRequests, bool myRequestsAccepted, bool friendsPostsNotifications)
{
StudentId = studentId;
UserId = userId;
EmailNotifications = emailNotifications;
SystemLogin = systemLogin;
InterestBasedEvents = interestBasedEvents;
Expand All @@ -44,6 +50,10 @@ public UpdateUserNotificationPreferences(Guid studentId, bool emailNotifications
EventsIAmSignedUpToNotification = eventsIAmSignedUpToNotification;
PostsOfPeopleIFollowNotification = postsOfPeopleIFollowNotification;
EventNotificationForPeopleIFollow = eventNotificationForPeopleIFollow;

NewFriendsRequests = newFriendsRequests;
MyRequestsAccepted = myRequestsAccepted;
FriendsPostsNotifications = friendsPostsNotifications;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace MiniSpace.Services.Students.Application.Dto
[ExcludeFromCodeCoverage]
public class NotificationPreferencesDto
{
public Guid StudentId { get; set; }
public Guid UserId { get; set; }
public bool SystemLogin { get; set; }
public bool InterestBasedEvents { get; set; }
public bool EventNotifications { get; set; }
Expand All @@ -22,6 +22,10 @@ public class NotificationPreferencesDto
public bool PostsOfPeopleIFollowNotification { get; set; }
public bool EventNotificationForPeopleIFollow { get; set; }

public bool NewFriendsRequests { get; set; }
public bool MyRequestsAccepted { get; set; }
public bool FriendsPostsNotifications { get; set; }

public NotificationPreferencesDto()
{
SystemLogin = false;
Expand All @@ -38,15 +42,20 @@ public NotificationPreferencesDto()
EventsIAmSignedUpToNotification = false;
PostsOfPeopleIFollowNotification = false;
EventNotificationForPeopleIFollow = false;

NewFriendsRequests = false;
MyRequestsAccepted = false;
FriendsPostsNotifications = false;
}

public NotificationPreferencesDto(Guid studentId, bool systemLogin, bool interestBasedEvents, bool eventNotifications,
public NotificationPreferencesDto(Guid userId, bool systemLogin, bool interestBasedEvents, bool eventNotifications,
bool commentsNotifications, bool postsNotifications, bool eventRecommendation,
bool friendsRecommendation, bool friendsPosts, bool postsRecommendation,
bool eventsIAmInterestedInNotification, bool eventsIAmSignedUpToNotification,
bool postsOfPeopleIFollowNotification, bool eventNotificationForPeopleIFollow)
bool postsOfPeopleIFollowNotification, bool eventNotificationForPeopleIFollow,
bool newFriendsRequests, bool myRequestsAccepted, bool friendsPostsNotifications)
{
StudentId = studentId;
UserId = userId;
SystemLogin = systemLogin;
InterestBasedEvents = interestBasedEvents;
EventNotifications = eventNotifications;
Expand All @@ -61,6 +70,10 @@ public NotificationPreferencesDto(Guid studentId, bool systemLogin, bool interes
EventsIAmSignedUpToNotification = eventsIAmSignedUpToNotification;
PostsOfPeopleIFollowNotification = postsOfPeopleIFollowNotification;
EventNotificationForPeopleIFollow = eventNotificationForPeopleIFollow;

NewFriendsRequests = newFriendsRequests;
MyRequestsAccepted = myRequestsAccepted;
FriendsPostsNotifications = friendsPostsNotifications;
}
}
}

0 comments on commit 8af5559

Please sign in to comment.