[CHANGE] Fixed auditing, storing images from account import
This commit is contained in:
@@ -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");
|
||||
}*/
|
||||
}
|
Reference in New Issue
Block a user