2023-02-19 00:43:43 +01:00
|
|
|
using PrivaPub.Models.Data;
|
|
|
|
|
using PrivaPub.StaticServices;
|
2023-02-18 08:52:17 +01:00
|
|
|
|
2023-02-19 00:43:43 +01:00
|
|
|
namespace PrivaPub.Services.ClientToServer.Public
|
2023-02-18 08:52:17 +01:00
|
|
|
{
|
2026-11-10 01:24:43 +01:00
|
|
|
public class DataService(
|
|
|
|
|
DbEntities dbCollections,
|
|
|
|
|
AppConfigurationService appConfigurationService) : IDataService
|
2023-02-18 08:52:17 +01:00
|
|
|
{
|
2026-10-17 02:56:57 +02:00
|
|
|
// the build's ref (its tag, or the branch a manual deploy ran from), as /build.json and NodeInfo name it
|
2023-02-18 08:52:17 +01:00
|
|
|
public string GetCurrentVersion() =>
|
2026-10-17 02:56:57 +02:00
|
|
|
string.IsNullOrEmpty(BuildInfo.Ref) ? BuildInfo.Commit : BuildInfo.Ref;
|
2023-02-18 08:52:17 +01:00
|
|
|
|
2023-02-19 00:43:43 +01:00
|
|
|
public async Task<IEnumerable<Language>> GetLanguages(CancellationToken cancellationToken)
|
2023-02-18 08:52:17 +01:00
|
|
|
{
|
2026-11-10 01:24:43 +01:00
|
|
|
return (await dbCollections.Languages
|
|
|
|
|
.Match(l => appConfigurationService.AppConfiguration.SupportedLanguages.Contains(l.International2Code))
|
2023-02-19 00:43:43 +01:00
|
|
|
.ExecuteAsync(cancellationToken)).OrderBy(l => l.NativeName).ToArray();
|
2023-02-18 08:52:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|