[CHANGE] Fixed auditing, storing images from account import

This commit is contained in:
max
2025-09-15 00:23:57 +02:00
parent e82736a45f
commit 0056a14f79
16 changed files with 201 additions and 47 deletions

View File

@@ -46,20 +46,29 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger<ClientServ
LogEvent("Failed to store client no ID!", LogSeverity.Warning);
return ResultError.Fail("Client does not have an ID, cannot save to library database!");
}
if (channelInfo != null)
{
var imagesResult = await _libraryService.FetchChannelImagesAsync(channelInfo);
if (!imagesResult.IsSuccess)
{
logger.LogWarning("Failed to fetch channel images!");
}
}
var channelResult = await _libraryService.GetChannelByIdAsync(client.Id, cancellationToken);
ChannelEntity? channel;
ChannelEntity? channelEntity;
try
{
if (channelResult.IsSuccess)
{
channel = channelResult.Value;
UpdateChannelEntity(client, channel, channelInfo);
channelEntity = channelResult.Value;
UpdateChannelEntity(client, channelEntity, channelInfo);
}
else
{
channel = CreateNewChannelFromClient(client, channelInfo);
channelEntity = CreateNewChannelFromClient(client, channelInfo);
}
}
catch (Exception e)
@@ -68,7 +77,7 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger<ClientServ
return ResultError.Error(e);
}
var saveResult = await _libraryService.SaveChannelAsync(channel, cancellationToken);
var saveResult = await _libraryService.SaveChannelAsync(channelEntity, cancellationToken);
return saveResult;
}
@@ -113,7 +122,7 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger<ClientServ
{
if (channelInfo == null)
{
throw new ArgumentNullException(nameof(channelInfo), "Channel information required to store new client/account.");
throw new ArgumentNullException(nameof(channelInfo), "Channel information is required to store new client/account.");
}
var cookies = new List<HttpCookieEntity>();
@@ -147,7 +156,7 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger<ClientServ
var channel = new ChannelEntity
{
Id = client.Id,
Id = channelInfo.Id,
Name = channelInfo.ChannelName,
Handle = channelInfo.Handle,
Description = channelInfo.Description,
@@ -155,14 +164,4 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger<ClientServ
};
return channel;
}
/*public async Task<Result<YouTubeClient>> LoadClientByIdAsync(string id)
{
if (string.IsNullOrWhiteSpace(id))
{
return ResultError.Fail("Client ID is empty!");
}
return ResultError.Fail("Not implemented");
}*/
}