Kavita/API/Helpers/Converters/ServerSettingConverter.cs
Joseph Milazzo 2ae9f8c203
Private Email Service Support (#1028)
* Added ServerSettingKey's for SMTP and moved email service code to Kavita. Nothing integrated in the UI yet.

* Undo all the custom SMTP stuff and prepare for custom email service url.

* Foundation for email service to use a custom url is setup.

* Implemented the ability to hook up custom email url
2022-02-04 09:54:54 -08:00

55 lines
2.1 KiB
C#

using System.Collections.Generic;
using API.DTOs.Settings;
using API.Entities;
using API.Entities.Enums;
using AutoMapper;
namespace API.Helpers.Converters
{
public class ServerSettingConverter : ITypeConverter<IEnumerable<ServerSetting>, ServerSettingDto>
{
public ServerSettingDto Convert(IEnumerable<ServerSetting> source, ServerSettingDto destination, ResolutionContext context)
{
destination ??= new ServerSettingDto();
foreach (var row in source)
{
switch (row.Key)
{
case ServerSettingKey.CacheDirectory:
destination.CacheDirectory = row.Value;
break;
case ServerSettingKey.TaskScan:
destination.TaskScan = row.Value;
break;
case ServerSettingKey.LoggingLevel:
destination.LoggingLevel = row.Value;
break;
case ServerSettingKey.TaskBackup:
destination.TaskBackup = row.Value;
break;
case ServerSettingKey.Port:
destination.Port = int.Parse(row.Value);
break;
case ServerSettingKey.AllowStatCollection:
destination.AllowStatCollection = bool.Parse(row.Value);
break;
case ServerSettingKey.EnableOpds:
destination.EnableOpds = bool.Parse(row.Value);
break;
case ServerSettingKey.BaseUrl:
destination.BaseUrl = row.Value;
break;
case ServerSettingKey.BookmarkDirectory:
destination.BookmarksDirectory = row.Value;
break;
case ServerSettingKey.EmailServiceUrl:
destination.EmailServiceUrl = row.Value;
break;
}
}
return destination;
}
}
}