mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
803 B
21 lines
803 B
using ErsatzTV.Core; |
|
using ErsatzTV.Core.Interfaces.Jellyfin; |
|
using ErsatzTV.Core.Jellyfin; |
|
using Newtonsoft.Json; |
|
|
|
namespace ErsatzTV.Infrastructure.Jellyfin; |
|
|
|
public class JellyfinSecretStore : IJellyfinSecretStore |
|
{ |
|
public Task<Unit> DeleteAll() => SaveSecrets(new JellyfinSecrets()); |
|
|
|
public Task<JellyfinSecrets> ReadSecrets() => |
|
File.ReadAllTextAsync(FileSystemLayout.JellyfinSecretsPath) |
|
.Map(JsonConvert.DeserializeObject<JellyfinSecrets>) |
|
.Map(s => Optional(s).IfNone(new JellyfinSecrets())); |
|
|
|
public Task<Unit> SaveSecrets(JellyfinSecrets secrets) => |
|
Some(JsonConvert.SerializeObject(secrets)).Match( |
|
s => File.WriteAllTextAsync(FileSystemLayout.JellyfinSecretsPath, s).ToUnit(), |
|
Task.FromResult(Unit.Default)); |
|
}
|
|
|