Backend: - New Likes feature (toggle/get liked tracks) and endpoints - User follow/unfollow, listening stats, public user profile - Playlist visibility (public/private) support - Various auth and DTO/response adjustments to support the above Frontend (web-player): - New design system pass: theme tokens/mode (light/dark), glass menu, tabs bar, player dock/extras/queue components, mix tiles, artist link - New routes: Liked, public user profile (/u/[id]), likes API proxy - Search refactor: shared SearchBox component used by TopBar and MobileHeader (search now reachable on mobile), live results as you type instead of requiring Enter, dropped the "Buscando…" quick-result preview - Removed now-unused components (MobileNav, CoverBadge, MixBentoTile, PlayPauseOverlay, SuggestionsTable, userDirectory) - Design handoff reference docs added under web-player/design_handoff_musify_player and web-player/docs/design-system-refactor-plan.md
64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
using System.Text.Json.Serialization;
|
|
using ErrorOr;
|
|
using Mediator;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Musify.Application.Contracts;
|
|
using Musify.Application.Serialization;
|
|
|
|
namespace Musify.Application.Users
|
|
{
|
|
public record GetUserProfileQuery(long UserId) : IQuery<ErrorOr<UserProfileResponse>>;
|
|
|
|
public record UserProfileResponse(
|
|
[property: JsonConverter(typeof(LongAsStringConverter))] long Id,
|
|
string Name,
|
|
string? FirstName,
|
|
string? SecondName,
|
|
string? ProfilePictureUrl,
|
|
DateTime CreatedAt,
|
|
int FollowersCount,
|
|
int FollowingCount);
|
|
|
|
public class GetUserProfileQueryHandler(IDatabase database)
|
|
: IQueryHandler<GetUserProfileQuery, ErrorOr<UserProfileResponse>>
|
|
{
|
|
public async ValueTask<ErrorOr<UserProfileResponse>> Handle(GetUserProfileQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var user = await database.Users
|
|
.AsNoTracking()
|
|
.Where(u => u.Id == request.UserId)
|
|
.Select(u => new
|
|
{
|
|
u.Id,
|
|
u.Name,
|
|
u.FirstName,
|
|
u.SecondName,
|
|
u.ProfilePictureUrl,
|
|
u.CreatedAt
|
|
})
|
|
.SingleOrDefaultAsync(cancellationToken);
|
|
|
|
if (user is null)
|
|
return Error.NotFound();
|
|
|
|
var followersCount = await database.UserFollows
|
|
.AsNoTracking()
|
|
.CountAsync(f => f.FollowedId == request.UserId, cancellationToken);
|
|
|
|
var followingCount = await database.UserFollows
|
|
.AsNoTracking()
|
|
.CountAsync(f => f.FollowerId == request.UserId, cancellationToken);
|
|
|
|
return new UserProfileResponse(
|
|
user.Id,
|
|
user.Name,
|
|
user.FirstName,
|
|
user.SecondName,
|
|
user.ProfilePictureUrl,
|
|
user.CreatedAt,
|
|
followersCount,
|
|
followingCount);
|
|
}
|
|
}
|
|
}
|