Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytes1027 committed Apr 8, 2024
2 parents c9b529e + 59491b6 commit c881d49
Show file tree
Hide file tree
Showing 46 changed files with 4,596 additions and 815 deletions.
2 changes: 1 addition & 1 deletion FU.API/FU.API.Tests/RelationServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ public async void HandleRelationAction_WithValidUsersAndAction_CantRemoveBlocked

private static RelationService CreateRelationService(AppDbContext context)
{
return new RelationService(context);
return new RelationService(context, new ChatService(context));
}
}
3 changes: 3 additions & 0 deletions FU.API/FU.API/DTOs/Post/PostResponseDTO.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace FU.API.DTOs.Post;

using FU.API.DTOs.Chat;
using FU.API.Models;

public class PostResponseDTO
Expand All @@ -25,4 +26,6 @@ public class PostResponseDTO
public ICollection<string> Tags { get; set; } = new HashSet<string>();

public bool HasJoined { get; set; } = false;

public MessageResponseDTO? LastMessage { get; set; }
}
7 changes: 6 additions & 1 deletion FU.API/FU.API/Helpers/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace FU.API.Helpers;

public static class Mapper
{
public static UserProfile ToProfile(this ApplicationUser appUser)
public static UserProfile ToProfile(this ApplicationUser appUser, Message? lastChatMessage = null)
{
return new UserProfile()
{
Expand All @@ -24,6 +24,7 @@ public static UserProfile ToProfile(this ApplicationUser appUser)
IsOnline = appUser.IsOnline,
FavoriteGames = appUser.FavoriteGames.Select(g => g.Game).ToList(),
FavoriteTags = appUser.FavoriteTags.Select(t => t.Tag).ToList(),
LastMessage = lastChatMessage?.ToDto(),
};
}

Expand Down Expand Up @@ -107,6 +108,8 @@ public static UserQuery ToUserQuery(this UserSearchRequestDTO dto)
query.SortType = arr[0] switch
{
"username" => UserSortType.Username,
"dob" => UserSortType.DOB,
"chatactivity" => UserSortType.ChatActivity,
_ => UserSortType.Username,
};

Expand Down Expand Up @@ -177,6 +180,7 @@ public static PostQuery ToPostQuery(this PostSearchRequestDTO dto)
"soonest" => PostSortType.EarliestToScheduledTime,
"newest" => PostSortType.NewestCreated,
"title" => PostSortType.Title,
"chatactivity" => PostSortType.ChatActivity,
_ => PostSortType.NewestCreated
};

Expand Down Expand Up @@ -207,6 +211,7 @@ public static PostResponseDTO ToDto(this Post post, bool hasJoined = false)
Creator = post.Creator == null ? new UserProfile { Username = "Deleted User" } : post.Creator.ToProfile(),
Tags = post.Tags.Select(t => t.Tag.Name).ToList(),
HasJoined = hasJoined,
LastMessage = post.Chat.LastMessage?.ToDto(),
};
}

Expand Down
Loading

0 comments on commit c881d49

Please sign in to comment.