Renames and changes

This commit is contained in:
2026-03-28 15:32:36 +01:00
parent 3132b139f7
commit 7709fe737f
28 changed files with 236 additions and 241 deletions
@@ -32,10 +32,10 @@ namespace Musify.Application.PlayLists.Handlers
Name = request.Name,
NormalizedName = request.Name.Trim().ToUpperInvariant(),
Description = request.Description,
OriginalPictureKeyName = playListConfiguration.Routes.PresetOriginalPicture,
SmallPictureKeyName = playListConfiguration.Routes.PresetSmallPicture,
MediumPictureKeyName = playListConfiguration.Routes.PresetMediumPicture,
LargePictureKeyName = playListConfiguration.Routes.PresetLargePicture,
OriginalPictureName = playListConfiguration.Routes.PresetOriginalPicture,
SmallPictureName = playListConfiguration.Routes.PresetSmallPicture,
MediumPictureName = playListConfiguration.Routes.PresetMediumPicture,
LargePictureName = playListConfiguration.Routes.PresetLargePicture,
};
var setPictureResult = request.Picture is null
@@ -63,12 +63,12 @@ namespace Musify.Application.PlayLists.Handlers
if (!uploadResult.IsSuccess)
{
logger.LogError("Failed to upload picture for PlayList with Id={PlayListId} to storage. Storage handler returned error: {ErrorMessage}",
logger.LogError("Failed to upload picture for PlayList with Id={PlayListId} to storage. Storage handler returned error={ErrorMessage}",
playList.Id, string.Join("; ", uploadResult.Errors));
return Result.Error($"Failed to upload picture for PlayList with Id {playList.Id} to storage.");
}
playList.OriginalPictureKeyName = pictureName;
playList.OriginalPictureName = pictureName;
logger.LogInformation("Playlist image uploaded successfully for PlayList with Id={PlayListId}.", playList.Id);
try
@@ -30,15 +30,15 @@ namespace Musify.Application.PlayLists.Handlers
var keysToRemove = new List<string>();
if (playList.SmallPictureKeyName != playListConfiguration.Routes.PresetSmallPicture)
if (playList.SmallPictureName != playListConfiguration.Routes.PresetSmallPicture)
keysToRemove.Add(Path.Combine(playListConfiguration.Routes.SmallPicturesPath,
playList.SmallPictureKeyName));
if (playList.MediumPictureKeyName != playListConfiguration.Routes.PresetMediumPicture)
playList.SmallPictureName));
if (playList.MediumPictureName != playListConfiguration.Routes.PresetMediumPicture)
keysToRemove.Add(Path.Combine(playListConfiguration.Routes.MediumPicturesPath,
playList.MediumPictureKeyName));
if (playList.LargePictureKeyName != playListConfiguration.Routes.PresetLargePicture)
playList.MediumPictureName));
if (playList.LargePictureName != playListConfiguration.Routes.PresetLargePicture)
keysToRemove.Add(Path.Combine(playListConfiguration.Routes.LargePicturesPath,
playList.LargePictureKeyName));
playList.LargePictureName));
foreach (var key in keysToRemove)
{
@@ -48,7 +48,7 @@ namespace Musify.Application.PlayLists.Handlers
{
if (publishResult.IsNotFound())
{
logger.LogWarning("File with key={KeyName} not found in storage while trying to publish remove file event for PlayList with id={PlayListId}.", key, playList.Id);
logger.LogWarning("File with key={Key} not found in storage while trying to publish remove file event for PlayList with id={PlayListId}.", key, playList.Id);
continue;
}
@@ -62,19 +62,19 @@ namespace Musify.Application.PlayLists.Handlers
return Result.NoContent();
}
async Task<Result> TryPublishRemoveFileEventAsync(Guid playListId, string keyName, CancellationToken cancellationToken)
async Task<Result> TryPublishRemoveFileEventAsync(Guid playListId, string key, CancellationToken cancellationToken)
{
try
{
await eventBus.PublishAsync(new RemoveFileEvent(
storageConfiguration.BucketName,
keyName), cancellationToken);
key), cancellationToken);
return Result.Success();
}
catch (Exception exception)
{
logger.LogError(exception, "Failed to publish remove file event for PlayList id={PlayListId} and key={KeyName}.", playListId, keyName);
logger.LogError(exception, "Failed to publish remove file event for PlayList id={PlayListId} and key={Key}.", playListId, key);
return Result.Error($"Failed to publish remove file event for PlayList with id {playListId}.");
}
}
@@ -23,13 +23,13 @@ namespace Musify.Application.PlayLists.Handlers
if (playList is null)
{
logger.LogInformation("PlayList with id {PlayListId} not found", request.PlayListId);
logger.LogInformation("PlayList with id={PlayListId} not found", request.PlayListId);
return Result.NotFound();
}
if (playList.UserId != request.UserId)
{
logger.LogWarning("User with id {UserId} is not the owner of the PlayList with id {PlayListId}", request.UserId, request.PlayListId);
logger.LogWarning("User with id={UserId} is not the owner of the PlayList with id={PlayListId}", request.UserId, request.PlayListId);
return Result.Unauthorized();
}
@@ -51,20 +51,20 @@ namespace Musify.Application.PlayLists.Handlers
return Result.Success(PlayListResponse.FromEntity(playList));
}
if (playList.SmallPictureKeyName != playListConfiguration.Routes.PresetSmallPicture)
if (playList.SmallPictureName != playListConfiguration.Routes.PresetSmallPicture)
await PublishRemoveFileEvent(Path.Combine(
playListConfiguration.Routes.SmallPicturesPath,
playList.SmallPictureKeyName),
playList.SmallPictureName),
cancellationToken);
if (playList.MediumPictureKeyName != playListConfiguration.Routes.PresetMediumPicture)
if (playList.MediumPictureName != playListConfiguration.Routes.PresetMediumPicture)
await PublishRemoveFileEvent(Path.Combine(
playListConfiguration.Routes.MediumPicturesPath,
playList.MediumPictureKeyName),
playList.MediumPictureName),
cancellationToken);
if (playList.LargePictureKeyName != playListConfiguration.Routes.PresetLargePicture)
if (playList.LargePictureName != playListConfiguration.Routes.PresetLargePicture)
await PublishRemoveFileEvent(Path.Combine(
playListConfiguration.Routes.LargePicturesPath,
playList.LargePictureKeyName),
playList.LargePictureName),
cancellationToken);
var newImageId = Guid.NewGuid();
@@ -74,7 +74,7 @@ namespace Musify.Application.PlayLists.Handlers
var uploadResult = await UploadFile(request.NewPicture, newImageStorageKey, cancellationToken);
if (!uploadResult.IsSuccess)
{
logger.LogError("Failed to upload picture for PlayList with Id={PlayListId} to storage. Storage handler returned error: {ErrorMessage}",
logger.LogError("Failed to upload picture for PlayList with Id={PlayListId} to storage. Storage handler returned error?={ErrorMessage}",
playList.Id, string.Join("; ", uploadResult.Errors));
return Result.Error($"Failed to upload picture for PlayList with Id {playList.Id} to storage.");
}
@@ -85,14 +85,14 @@ namespace Musify.Application.PlayLists.Handlers
}
catch (Exception exception)
{
logger.LogError(exception, "Failed to publish update picture event for PlayList with id {PlayListId}.", playList.Id);
logger.LogError(exception, "Failed to publish update picture event for PlayList with id={PlayListId}.", playList.Id);
return Result.Error($"Failed to publish update picture event for PlayList with id {playList.Id}.");
}
database.PlayLists.Update(playList);
await database.SaveChangesAsync(cancellationToken);
logger.LogInformation("Updated PlayList with id={PlayListId} and picture key {PictureKey}.", playList.Id, newImageStorageKey);
logger.LogInformation("Updated PlayList with id={PlayListId} and picture key={PictureKey}.", playList.Id, newImageStorageKey);
return Result.Success(PlayListResponse.FromEntity(playList));
}
@@ -110,7 +110,7 @@ namespace Musify.Application.PlayLists.Handlers
}
catch (Exception exception)
{
logger.LogError(exception, "Failed to publish remove file event for key {Key}.", key);
logger.LogError(exception, "Failed to publish remove file event for key={Key}.", key);
return Result.Error($"Failed to publish remove file event for key {key}.");
}
}
@@ -18,9 +18,9 @@ namespace Musify.Application.PlayLists.Responses
playList.Id,
playList.Name,
playList.Description,
playList.SmallPictureKeyName,
playList.MediumPictureKeyName,
playList.LargePictureKeyName,
playList.SmallPictureName,
playList.MediumPictureName,
playList.LargePictureName,
playList.CreatedDate,
playList.UpdatedDate);
}