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
51 lines
1.9 KiB
C#
51 lines
1.9 KiB
C#
using ErrorOr;
|
|
using Mediator;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
using Musify.Application.Contracts;
|
|
using Musify.Domain.Entities;
|
|
|
|
namespace Musify.Application.Users
|
|
{
|
|
public record FollowUserCommand(long FollowerId, long FollowedId) : ICommand<ErrorOr<Success>>;
|
|
|
|
public class FollowUserCommandHandler(
|
|
IDatabase database,
|
|
ILogger<FollowUserCommandHandler> logger)
|
|
: ICommandHandler<FollowUserCommand, ErrorOr<Success>>
|
|
{
|
|
public async ValueTask<ErrorOr<Success>> Handle(FollowUserCommand request, CancellationToken cancellationToken)
|
|
{
|
|
if (request.FollowerId == request.FollowedId)
|
|
return Error.Validation(description: "A user cannot follow themselves.");
|
|
|
|
var followedExists = await database.Users
|
|
.AsNoTracking()
|
|
.AnyAsync(u => u.Id == request.FollowedId, cancellationToken);
|
|
if (!followedExists)
|
|
{
|
|
logger.LogInformation("User {FollowedId} not found", request.FollowedId);
|
|
return Error.NotFound(description: $"User {request.FollowedId} not found");
|
|
}
|
|
|
|
var alreadyFollowing = await database.UserFollows
|
|
.AsNoTracking()
|
|
.AnyAsync(f => f.FollowerId == request.FollowerId && f.FollowedId == request.FollowedId, cancellationToken);
|
|
if (alreadyFollowing)
|
|
return new Success();
|
|
|
|
await database.UserFollows.AddAsync(new UserFollow
|
|
{
|
|
FollowerId = request.FollowerId,
|
|
FollowedId = request.FollowedId
|
|
}, cancellationToken);
|
|
|
|
await database.SaveChangesAsync(cancellationToken);
|
|
|
|
logger.LogInformation("User {FollowerId} followed user {FollowedId}", request.FollowerId, request.FollowedId);
|
|
|
|
return new Success();
|
|
}
|
|
}
|
|
}
|