Fixed routes and bugs
This commit is contained in:
@@ -4,10 +4,6 @@ namespace Musify.Application.Contracts.Infrastructure
|
|||||||
{
|
{
|
||||||
public interface IPictureHandler
|
public interface IPictureHandler
|
||||||
{
|
{
|
||||||
public string FileExtension { get; }
|
Task<Result<Stream>> ResizePictureAsWebpAsync(Stream pictureStream, int width, int height, CancellationToken cancellationToken);
|
||||||
|
|
||||||
public string ContentType { get; }
|
|
||||||
|
|
||||||
Task<Result<Stream>> ResizePictureAsync(Stream pictureStream, int width, int height, CancellationToken cancellationToken);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,13 +4,13 @@
|
|||||||
Guid PlayListId,
|
Guid PlayListId,
|
||||||
string SourceBucketName,
|
string SourceBucketName,
|
||||||
string SourceKeyName,
|
string SourceKeyName,
|
||||||
string SmallPictureKeyName,
|
string SmallPictureRoute,
|
||||||
int SmallPictureWidth,
|
int SmallPictureWidth,
|
||||||
int SmallPictureHeight,
|
int SmallPictureHeight,
|
||||||
string MediumPictureKeyName,
|
string MediumPictureRoute,
|
||||||
int MediumPictureWidth,
|
int MediumPictureWidth,
|
||||||
int MediumPictureHeight,
|
int MediumPictureHeight,
|
||||||
string LargePictureKeyName,
|
string LargePictureRoute,
|
||||||
int LargePictureWidth,
|
int LargePictureWidth,
|
||||||
int LargePictureHeight);
|
int LargePictureHeight);
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ using Musify.Domain.Entities;
|
|||||||
|
|
||||||
namespace Musify.Application.PlayLists.Handlers
|
namespace Musify.Application.PlayLists.Handlers
|
||||||
{
|
{
|
||||||
public class CreatePlayListCommandHandler(IEventBus eventBus, IDatabase database, IStorageHandler storageHandler, IPictureHandler pictureHandler,
|
public class CreatePlayListCommandHandler(IEventBus eventBus, IDatabase database, IStorageHandler storageHandler,
|
||||||
ILogger<CreatePlayListCommandHandler> logger, ApplicationStorageConfiguration storageConfiguration, PlayListConfiguration playListConfiguration)
|
ILogger<CreatePlayListCommandHandler> logger, ApplicationStorageConfiguration storageConfiguration, PlayListConfiguration playListConfiguration)
|
||||||
: IRequestHandler<CreatePlayListCommand, Task<Result<PlayListResponse>> >
|
: IRequestHandler<CreatePlayListCommand, Task<Result<PlayListResponse>> >
|
||||||
{
|
{
|
||||||
@@ -68,7 +68,7 @@ namespace Musify.Application.PlayLists.Handlers
|
|||||||
return Result.Error($"Failed to upload picture for PlayList with Id {playList.Id} to storage.");
|
return Result.Error($"Failed to upload picture for PlayList with Id {playList.Id} to storage.");
|
||||||
}
|
}
|
||||||
|
|
||||||
playList.OriginalPictureKeyName = pictureStorageKey;
|
playList.OriginalPictureKeyName = pictureName;
|
||||||
logger.LogInformation("Playlist image uploaded successfully for PlayList with Id={PlayListId}.", playList.Id);
|
logger.LogInformation("Playlist image uploaded successfully for PlayList with Id={PlayListId}.", playList.Id);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -97,24 +97,17 @@ namespace Musify.Application.PlayLists.Handlers
|
|||||||
|
|
||||||
async Task PublishUpdateEvent(string originalPictureKeyName, PlayList playList, CancellationToken cancellationToken)
|
async Task PublishUpdateEvent(string originalPictureKeyName, PlayList playList, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var smallPictureKeyName = Path.Combine(playListConfiguration.Routes.SmallPicturesPath,
|
|
||||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
|
||||||
var mediumPictureKeyName = Path.Combine(playListConfiguration.Routes.MediumPicturesPath,
|
|
||||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
|
||||||
var largePictureKeyName = Path.Combine(playListConfiguration.Routes.LargePicturesPath,
|
|
||||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
|
||||||
|
|
||||||
await eventBus.PublishAsync(new UpdatePlayListPictureEvent(
|
await eventBus.PublishAsync(new UpdatePlayListPictureEvent(
|
||||||
playList.Id,
|
playList.Id,
|
||||||
storageConfiguration.BucketName,
|
storageConfiguration.BucketName,
|
||||||
originalPictureKeyName,
|
originalPictureKeyName,
|
||||||
smallPictureKeyName,
|
playListConfiguration.Routes.SmallPicturesPath,
|
||||||
playListConfiguration.PicturesSizes.SmallPictureWidth,
|
playListConfiguration.PicturesSizes.SmallPictureWidth,
|
||||||
playListConfiguration.PicturesSizes.SmallPictureHeight,
|
playListConfiguration.PicturesSizes.SmallPictureHeight,
|
||||||
mediumPictureKeyName,
|
playListConfiguration.Routes.MediumPicturesPath,
|
||||||
playListConfiguration.PicturesSizes.MediumPictureWidth,
|
playListConfiguration.PicturesSizes.MediumPictureWidth,
|
||||||
playListConfiguration.PicturesSizes.MediumPictureHeight,
|
playListConfiguration.PicturesSizes.MediumPictureHeight,
|
||||||
largePictureKeyName,
|
playListConfiguration.Routes.LargePicturesPath,
|
||||||
playListConfiguration.PicturesSizes.LargePictureWidth,
|
playListConfiguration.PicturesSizes.LargePictureWidth,
|
||||||
playListConfiguration.PicturesSizes.LargePictureHeight), cancellationToken);
|
playListConfiguration.PicturesSizes.LargePictureHeight), cancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Musify.Application.PlayLists.Handlers
|
|||||||
{
|
{
|
||||||
public class UpdatePlayListCommandHandler(IEventBus eventBus, IDatabase database, IStorageHandler storageHandler,
|
public class UpdatePlayListCommandHandler(IEventBus eventBus, IDatabase database, IStorageHandler storageHandler,
|
||||||
ILogger<UpdatePlayListCommandHandler> logger, ApplicationStorageConfiguration storageConfiguration,
|
ILogger<UpdatePlayListCommandHandler> logger, ApplicationStorageConfiguration storageConfiguration,
|
||||||
PlayListConfiguration playListConfiguration, IPictureHandler pictureHandler)
|
PlayListConfiguration playListConfiguration)
|
||||||
: IRequestHandler<UpdatePlayListCommand, Task<Result<PlayListResponse>> >
|
: IRequestHandler<UpdatePlayListCommand, Task<Result<PlayListResponse>> >
|
||||||
{
|
{
|
||||||
public async Task<Result<PlayListResponse>> Handle(UpdatePlayListCommand request, CancellationToken cancellationToken)
|
public async Task<Result<PlayListResponse>> Handle(UpdatePlayListCommand request, CancellationToken cancellationToken)
|
||||||
@@ -129,27 +129,17 @@ namespace Musify.Application.PlayLists.Handlers
|
|||||||
|
|
||||||
async Task PublishUpdateEvent(string originalPictureKeyName, PlayList playList, CancellationToken cancellationToken)
|
async Task PublishUpdateEvent(string originalPictureKeyName, PlayList playList, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var smallPictureKeyName = Path.Combine(
|
|
||||||
playListConfiguration.Routes.SmallPicturesPath,
|
|
||||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
|
||||||
var mediumPictureKeyName = Path.Combine(
|
|
||||||
playListConfiguration.Routes.MediumPicturesPath,
|
|
||||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
|
||||||
var largePictureKeyName = Path.Combine(
|
|
||||||
playListConfiguration.Routes.LargePicturesPath,
|
|
||||||
Guid.NewGuid() + pictureHandler.FileExtension);
|
|
||||||
|
|
||||||
await eventBus.PublishAsync(new UpdatePlayListPictureEvent(
|
await eventBus.PublishAsync(new UpdatePlayListPictureEvent(
|
||||||
playList.Id,
|
playList.Id,
|
||||||
storageConfiguration.BucketName,
|
storageConfiguration.BucketName,
|
||||||
originalPictureKeyName,
|
originalPictureKeyName,
|
||||||
smallPictureKeyName,
|
playListConfiguration.Routes.SmallPicturesPath,
|
||||||
playListConfiguration.PicturesSizes.SmallPictureWidth,
|
playListConfiguration.PicturesSizes.SmallPictureWidth,
|
||||||
playListConfiguration.PicturesSizes.SmallPictureHeight,
|
playListConfiguration.PicturesSizes.SmallPictureHeight,
|
||||||
mediumPictureKeyName,
|
playListConfiguration.Routes.MediumPicturesPath,
|
||||||
playListConfiguration.PicturesSizes.MediumPictureWidth,
|
playListConfiguration.PicturesSizes.MediumPictureWidth,
|
||||||
playListConfiguration.PicturesSizes.MediumPictureHeight,
|
playListConfiguration.PicturesSizes.MediumPictureHeight,
|
||||||
largePictureKeyName,
|
playListConfiguration.Routes.LargePicturesPath,
|
||||||
playListConfiguration.PicturesSizes.LargePictureWidth,
|
playListConfiguration.PicturesSizes.LargePictureWidth,
|
||||||
playListConfiguration.PicturesSizes.LargePictureHeight), cancellationToken);
|
playListConfiguration.PicturesSizes.LargePictureHeight), cancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
executeContext.CancellationToken);
|
executeContext.CancellationToken);
|
||||||
|
|
||||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
|
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
|
||||||
var workingDirectory = executeContext.GetVariable<string>(executeContext.Arguments.WorkingDirectoryVariableName);
|
var workingDirectory = executeContext.GetVariable<string>(executeContext.Arguments.WorkingDirectoryVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
|
||||||
if (string.IsNullOrWhiteSpace(sourceFilePath) || string.IsNullOrWhiteSpace(workingDirectory))
|
|
||||||
throw new InvalidOperationException("Transcode activity requires source file path and working directory variables.");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Musify.Application.Contracts.Infrastructure;
|
|||||||
using Musify.Domain.Entities;
|
using Musify.Domain.Entities;
|
||||||
using Musify.Infrastructure.MassTransit.Arguments;
|
using Musify.Infrastructure.MassTransit.Arguments;
|
||||||
using Musify.Infrastructure.MassTransit.Logs;
|
using Musify.Infrastructure.MassTransit.Logs;
|
||||||
using Musify.Infrastructure.MassTransit.Activities;
|
|
||||||
|
|
||||||
namespace Musify.Infrastructure.MassTransit.Activities.Audio
|
namespace Musify.Infrastructure.MassTransit.Activities.Audio
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,9 +32,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
executeContext.CancellationToken);
|
executeContext.CancellationToken);
|
||||||
|
|
||||||
var destinationPath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
|
var destinationPath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
|
||||||
if (string.IsNullOrWhiteSpace(destinationPath))
|
ArgumentNullException.ThrowIfNull(destinationPath, nameof(destinationPath));
|
||||||
throw new InvalidOperationException(
|
|
||||||
$"Download activity requires variable '{executeContext.Arguments.DestinationFilePathVariableName}' with destination file path.");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,16 +32,10 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
executeContext.CancellationToken);
|
executeContext.CancellationToken);
|
||||||
|
|
||||||
var folderPath = executeContext.GetVariable<string>(executeContext.Arguments.SourceDirectoryVariableName);
|
var folderPath = executeContext.GetVariable<string>(executeContext.Arguments.SourceDirectoryVariableName);
|
||||||
if (string.IsNullOrWhiteSpace(folderPath))
|
ArgumentNullException.ThrowIfNull(folderPath, nameof(folderPath));
|
||||||
throw new InvalidOperationException(
|
|
||||||
$"Transfer activity requires variable '{executeContext.Arguments.SourceDirectoryVariableName}' with source directory path.");
|
|
||||||
|
|
||||||
var destinationKeyName = executeContext.Arguments.DestinationKeyName;
|
var destinationKeyName = executeContext.Arguments.DestinationKeyName;
|
||||||
if (string.IsNullOrWhiteSpace(destinationKeyName) && !string.IsNullOrWhiteSpace(executeContext.Arguments.DestinationKeyNameVariableName))
|
ArgumentNullException.ThrowIfNull(destinationKeyName, nameof(destinationKeyName));
|
||||||
destinationKeyName = executeContext.GetVariable<string>(executeContext.Arguments.DestinationKeyNameVariableName);
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(destinationKeyName))
|
|
||||||
throw new InvalidOperationException("Transfer activity requires a destination key name from arguments or variables.");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
|
|||||||
executeContext.CancellationToken);
|
executeContext.CancellationToken);
|
||||||
|
|
||||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.FilePathVariableName);
|
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.FilePathVariableName);
|
||||||
if (string.IsNullOrEmpty(sourceFilePath))
|
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
|
||||||
throw new InvalidOperationException($"Upload activity requires variable '{executeContext.Arguments.FilePathVariableName}' with source file path.");
|
|
||||||
var fileName = Path.GetFileName(sourceFilePath);
|
var fileName = Path.GetFileName(sourceFilePath);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
+10
-11
@@ -13,6 +13,8 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
{
|
{
|
||||||
public const string ExecuteEndpointName = "generate-picture-workflow-paths";
|
public const string ExecuteEndpointName = "generate-picture-workflow-paths";
|
||||||
|
|
||||||
|
internal const string ResizedPictureFileExtension = ".webp";
|
||||||
|
|
||||||
public async Task<ExecutionResult> Execute(ExecuteContext<GeneratePictureWorkflowPathsArguments> executeContext)
|
public async Task<ExecutionResult> Execute(ExecuteContext<GeneratePictureWorkflowPathsArguments> executeContext)
|
||||||
{
|
{
|
||||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||||
@@ -32,19 +34,16 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var destinationFolderName = Guid.NewGuid().ToString();
|
var destinationFolderName = Guid.NewGuid().ToString();
|
||||||
var originalFileName = Path.GetFileName(executeContext.Arguments.SourceKeyName);
|
|
||||||
var sourceFileExtension = Path.GetExtension(originalFileName);
|
|
||||||
var workingDirectory = Path.Combine(executeContext.Arguments.TemporaryRootDirectory, destinationFolderName);
|
var workingDirectory = Path.Combine(executeContext.Arguments.TemporaryRootDirectory, destinationFolderName);
|
||||||
|
|
||||||
var sourceFileName = Guid.NewGuid().ToString() + sourceFileExtension;
|
var sourceFilePath = Path.Combine(
|
||||||
var smallPictureFileName = Guid.NewGuid().ToString() + sourceFileExtension;
|
workingDirectory, Guid.NewGuid().ToString() + Path.GetExtension(executeContext.Arguments.SourceKeyName));
|
||||||
var mediumPictureFileName = Guid.NewGuid().ToString() + sourceFileExtension;
|
var smallPictureFilePath = Path.Combine(
|
||||||
var largePictureFileName = Guid.NewGuid().ToString() + sourceFileExtension;
|
workingDirectory, Guid.NewGuid().ToString() + ResizedPictureFileExtension);
|
||||||
|
var mediumPictureFilePath = Path.Combine(
|
||||||
var sourceFilePath = Path.Combine(workingDirectory, sourceFileName);
|
workingDirectory, Guid.NewGuid().ToString() + ResizedPictureFileExtension);
|
||||||
var smallPictureFilePath = Path.Combine(workingDirectory, smallPictureFileName);
|
var largePictureFilePath = Path.Combine(
|
||||||
var mediumPictureFilePath = Path.Combine(workingDirectory, mediumPictureFileName);
|
workingDirectory, Guid.NewGuid().ToString() + ResizedPictureFileExtension);
|
||||||
var largePictureFilePath = Path.Combine(workingDirectory, largePictureFileName);
|
|
||||||
|
|
||||||
Directory.CreateDirectory(workingDirectory);
|
Directory.CreateDirectory(workingDirectory);
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
executeContext.CancellationToken);
|
executeContext.CancellationToken);
|
||||||
|
|
||||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
|
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
|
||||||
var destinationFilePath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
|
var destinationFilePath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(destinationFilePath, nameof(destinationFilePath));
|
||||||
if (string.IsNullOrWhiteSpace(sourceFilePath) || string.IsNullOrWhiteSpace(destinationFilePath))
|
|
||||||
throw new InvalidOperationException("Resize activity requires source and destination file path variables.");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -48,7 +47,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
|
|
||||||
await using var fileStream = File.OpenRead(sourceFilePath);
|
await using var fileStream = File.OpenRead(sourceFilePath);
|
||||||
|
|
||||||
var resizedPicture = await pictureHandler.ResizePictureAsync(
|
var resizedPicture = await pictureHandler.ResizePictureAsWebpAsync(
|
||||||
fileStream,
|
fileStream,
|
||||||
executeContext.Arguments.Width,
|
executeContext.Arguments.Width,
|
||||||
executeContext.Arguments.Height,
|
executeContext.Arguments.Height,
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
0,
|
0,
|
||||||
executeContext.CancellationToken);
|
executeContext.CancellationToken);
|
||||||
|
|
||||||
|
var smallResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.SmallPictureVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(smallResizedVariable, nameof(smallResizedVariable));
|
||||||
|
var mediumResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.MediumPictureVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(mediumResizedVariable, nameof(mediumResizedVariable));
|
||||||
|
var largeResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.LargePictureVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(largeResizedVariable, nameof(largeResizedVariable));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var playList = await database.PlayLists.FindAsync(
|
var playList = await database.PlayLists.FindAsync(
|
||||||
@@ -52,9 +59,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
playList.LargePictureKeyName);
|
playList.LargePictureKeyName);
|
||||||
|
|
||||||
playList.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKeyName);
|
playList.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKeyName);
|
||||||
playList.SmallPictureKeyName = Path.GetFileName(executeContext.Arguments.SmallPictureKeyName);
|
playList.SmallPictureKeyName = Path.GetFileName(smallResizedVariable);
|
||||||
playList.MediumPictureKeyName = Path.GetFileName(executeContext.Arguments.MediumPictureKeyName);
|
playList.MediumPictureKeyName = Path.GetFileName(mediumResizedVariable);
|
||||||
playList.LargePictureKeyName = Path.GetFileName(executeContext.Arguments.LargePictureKeyName);
|
playList.LargePictureKeyName = Path.GetFileName(largeResizedVariable);
|
||||||
|
|
||||||
database.PlayLists.Update(playList);
|
database.PlayLists.Update(playList);
|
||||||
await database.SaveChangesAsync(executeContext.CancellationToken);
|
await database.SaveChangesAsync(executeContext.CancellationToken);
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
0,
|
0,
|
||||||
executeContext.CancellationToken);
|
executeContext.CancellationToken);
|
||||||
|
|
||||||
|
var smallResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.SmallPictureVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(smallResizedVariable, nameof(smallResizedVariable));
|
||||||
|
var mediumResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.MediumPictureVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(mediumResizedVariable, nameof(mediumResizedVariable));
|
||||||
|
var largeResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.LargePictureVariableName);
|
||||||
|
ArgumentNullException.ThrowIfNull(largeResizedVariable, nameof(largeResizedVariable));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var track = await database.Tracks.FindAsync(
|
var track = await database.Tracks.FindAsync(
|
||||||
@@ -52,9 +59,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
|||||||
track.LargePictureKeyName);
|
track.LargePictureKeyName);
|
||||||
|
|
||||||
track.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKeyName);
|
track.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKeyName);
|
||||||
track.SmallPictureKeyName = Path.GetFileName(executeContext.Arguments.SmallPictureKeyName);
|
track.SmallPictureKeyName = Path.GetFileName(smallResizedVariable);
|
||||||
track.MediumPictureKeyName = Path.GetFileName(executeContext.Arguments.MediumPictureKeyName);
|
track.MediumPictureKeyName = Path.GetFileName(mediumResizedVariable);
|
||||||
track.LargePictureKeyName = Path.GetFileName(executeContext.Arguments.LargePictureKeyName);
|
track.LargePictureKeyName = Path.GetFileName(largeResizedVariable);
|
||||||
|
|
||||||
database.Tracks.Update(track);
|
database.Tracks.Update(track);
|
||||||
await database.SaveChangesAsync(executeContext.CancellationToken);
|
await database.SaveChangesAsync(executeContext.CancellationToken);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
public record UpdatePlayListPictureArguments(
|
public record UpdatePlayListPictureArguments(
|
||||||
Guid PlayListId,
|
Guid PlayListId,
|
||||||
string OriginalPictureKeyName,
|
string OriginalPictureKeyName,
|
||||||
string SmallPictureKeyName,
|
string SmallPictureVariableName,
|
||||||
string MediumPictureKeyName,
|
string MediumPictureVariableName,
|
||||||
string LargePictureKeyName);
|
string LargePictureVariableName);
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
public record UpdateTrackPictureArguments(
|
public record UpdateTrackPictureArguments(
|
||||||
Guid TrackId,
|
Guid TrackId,
|
||||||
string OriginalPictureKeyName,
|
string OriginalPictureKeyName,
|
||||||
string SmallPictureKeyName,
|
string SmallPictureVariableName,
|
||||||
string MediumPictureKeyName,
|
string MediumPictureVariableName,
|
||||||
string LargePictureKeyName);
|
string LargePictureVariableName);
|
||||||
}
|
}
|
||||||
+13
-14
@@ -1,6 +1,5 @@
|
|||||||
using MassTransit;
|
using MassTransit;
|
||||||
using MassTransit.Courier.Contracts;
|
using MassTransit.Courier.Contracts;
|
||||||
using MimeMapping;
|
|
||||||
using Musify.Application.Events;
|
using Musify.Application.Events;
|
||||||
using Musify.Infrastructure.Configuration;
|
using Musify.Infrastructure.Configuration;
|
||||||
using Musify.Infrastructure.MassTransit.Activities;
|
using Musify.Infrastructure.MassTransit.Activities;
|
||||||
@@ -29,19 +28,15 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
|||||||
message.LargePictureHeight,
|
message.LargePictureHeight,
|
||||||
correlationId);
|
correlationId);
|
||||||
|
|
||||||
routingSlipBuilder.AddSubscription(
|
|
||||||
MessagingHelper.BuildConsumerUri(RoutingSlipCleanUpConsumer.QueueName),
|
|
||||||
RoutingSlipEvents.Completed | RoutingSlipEvents.Faulted);
|
|
||||||
|
|
||||||
routingSlipBuilder.AddActivity(
|
routingSlipBuilder.AddActivity(
|
||||||
ActivityNames.UpdateTrackPicture,
|
ActivityNames.UpdateTrackPicture,
|
||||||
MessagingHelper.BuildExecuteActivityUri(UpdateTrackPictureActivity.ExecuteEndpointName),
|
MessagingHelper.BuildExecuteActivityUri(UpdateTrackPictureActivity.ExecuteEndpointName),
|
||||||
new UpdateTrackPictureArguments(
|
new UpdateTrackPictureArguments(
|
||||||
message.TrackId,
|
message.TrackId,
|
||||||
message.SourceKeyName,
|
message.SourceKeyName,
|
||||||
message.SmallPictureRoute,
|
RoutingSlipVariableNames.Picture.SmallResizedFilePath,
|
||||||
message.MediumPictureRoute,
|
RoutingSlipVariableNames.Picture.MediumResizedFilePath,
|
||||||
message.LargePictureRoute));
|
RoutingSlipVariableNames.Picture.LargeResizedFilePath));
|
||||||
|
|
||||||
return routingSlipBuilder;
|
return routingSlipBuilder;
|
||||||
}
|
}
|
||||||
@@ -51,13 +46,13 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
|||||||
var routingSlipBuilder = BuildPictureWorkflow(
|
var routingSlipBuilder = BuildPictureWorkflow(
|
||||||
message.SourceBucketName,
|
message.SourceBucketName,
|
||||||
message.SourceKeyName,
|
message.SourceKeyName,
|
||||||
message.SmallPictureKeyName,
|
message.SmallPictureRoute,
|
||||||
message.SmallPictureWidth,
|
message.SmallPictureWidth,
|
||||||
message.SmallPictureHeight,
|
message.SmallPictureHeight,
|
||||||
message.MediumPictureKeyName,
|
message.MediumPictureRoute,
|
||||||
message.MediumPictureWidth,
|
message.MediumPictureWidth,
|
||||||
message.MediumPictureHeight,
|
message.MediumPictureHeight,
|
||||||
message.LargePictureKeyName,
|
message.LargePictureRoute,
|
||||||
message.LargePictureWidth,
|
message.LargePictureWidth,
|
||||||
message.LargePictureHeight,
|
message.LargePictureHeight,
|
||||||
correlationId);
|
correlationId);
|
||||||
@@ -68,9 +63,9 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
|||||||
new UpdatePlayListPictureArguments(
|
new UpdatePlayListPictureArguments(
|
||||||
message.PlayListId,
|
message.PlayListId,
|
||||||
message.SourceKeyName,
|
message.SourceKeyName,
|
||||||
message.SmallPictureKeyName,
|
RoutingSlipVariableNames.Picture.SmallResizedFilePath,
|
||||||
message.MediumPictureKeyName,
|
RoutingSlipVariableNames.Picture.MediumResizedFilePath,
|
||||||
message.LargePictureKeyName));
|
RoutingSlipVariableNames.Picture.LargeResizedFilePath));
|
||||||
|
|
||||||
return routingSlipBuilder;
|
return routingSlipBuilder;
|
||||||
}
|
}
|
||||||
@@ -91,6 +86,10 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
|||||||
{
|
{
|
||||||
var routingSlipBuilder = new RoutingSlipBuilder(NewId.NextGuid());
|
var routingSlipBuilder = new RoutingSlipBuilder(NewId.NextGuid());
|
||||||
|
|
||||||
|
routingSlipBuilder.AddSubscription(
|
||||||
|
MessagingHelper.BuildConsumerUri(RoutingSlipCleanUpConsumer.QueueName),
|
||||||
|
RoutingSlipEvents.Completed | RoutingSlipEvents.Faulted);
|
||||||
|
|
||||||
routingSlipBuilder.AddVariable(RoutingSlipVariableNames.Workflow.CorrelationId, correlationId ?? Guid.Empty);
|
routingSlipBuilder.AddVariable(RoutingSlipVariableNames.Workflow.CorrelationId, correlationId ?? Guid.Empty);
|
||||||
|
|
||||||
routingSlipBuilder.AddActivity(
|
routingSlipBuilder.AddActivity(
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ namespace Musify.Infrastructure.MassTransit
|
|||||||
internal const string MediumResizedFilePath = "Picture.MediumResizedFilePath";
|
internal const string MediumResizedFilePath = "Picture.MediumResizedFilePath";
|
||||||
internal const string LargeResizedFilePath = "Picture.LargeResizedFilePath";
|
internal const string LargeResizedFilePath = "Picture.LargeResizedFilePath";
|
||||||
internal const string DestinationFolderName = "Picture.DestinationFolderName";
|
internal const string DestinationFolderName = "Picture.DestinationFolderName";
|
||||||
|
|
||||||
internal const string SmallPictureKeyName = "Picture.SmallPictureKeyName";
|
|
||||||
internal const string MediumPictureKeyName = "Picture.MediumPictureKeyName";
|
|
||||||
internal const string LargePictureKeyName = "Picture.LargePictureKeyName";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,7 @@ namespace Musify.Infrastructure.Pictures
|
|||||||
public class PictureHandler(ILogger<PictureHandler> logger)
|
public class PictureHandler(ILogger<PictureHandler> logger)
|
||||||
: IPictureHandler
|
: IPictureHandler
|
||||||
{
|
{
|
||||||
public string FileExtension => "webp";
|
public async Task<Result<Stream>> ResizePictureAsWebpAsync(Stream pictureStream, int width, int height, CancellationToken cancellationToken)
|
||||||
|
|
||||||
public string ContentType => "image/webp";
|
|
||||||
|
|
||||||
public async Task<Result<Stream>> ResizePictureAsync(Stream pictureStream, int width, int height, CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user