Исправление: том ./mods:/lampac/mods в compose и копии 10 модулей с enable:true; конфиг без SkipModules

This commit is contained in:
2026-10-02 12:11:49 +03:00
parent 8dcbc6bc52
commit 7b8e28b3bf
151 changed files with 68625 additions and 44 deletions
@@ -0,0 +1,26 @@
namespace Music;
public static class MusicAuthService
{
public static async Task<List<MusicAuthState>> GetStatesAsync(string profileId, CancellationToken cancellationToken = default)
{
var result = new List<MusicAuthState>();
foreach (var provider in MusicProviderRegistry.AuthProviders.Where(i => i.Enabled))
result.Add(await provider.GetStateAsync(profileId, cancellationToken));
return result;
}
public static Task<bool> SaveAsync(string provider, string payload, string profileId, CancellationToken cancellationToken = default)
{
var auth = MusicProviderRegistry.GetAuthProvider(provider);
return auth == null ? Task.FromResult(false) : auth.SaveAsync(payload, profileId, cancellationToken);
}
public static Task LogoutAsync(string provider, string profileId, CancellationToken cancellationToken = default)
{
var auth = MusicProviderRegistry.GetAuthProvider(provider);
return auth == null ? Task.CompletedTask : auth.LogoutAsync(profileId, cancellationToken);
}
}
@@ -0,0 +1,103 @@
using Microsoft.EntityFrameworkCore;
namespace Music;
public static class MusicAuthStorageService
{
public static async Task<T> GetAsync<T>(string profileId, string providerId, CancellationToken cancellationToken = default) where T : class
{
if (string.IsNullOrWhiteSpace(providerId))
return null;
using var db = MusicContext.Create();
string normalizedProfileId = NormalizeProfileId(profileId);
var row = await db.auth_credentials
.Where(i => i.provider_id == providerId && i.profile_id == normalizedProfileId)
.OrderByDescending(i => i.updated)
.FirstOrDefaultAsync(cancellationToken);
if (row == null && normalizedProfileId != string.Empty)
{
row = await db.auth_credentials
.Where(i => i.provider_id == providerId && i.profile_id == string.Empty)
.OrderByDescending(i => i.updated)
.FirstOrDefaultAsync(cancellationToken);
}
return row == null ? null : MusicJson.Deserialize<T>(row.payload);
}
public static async Task SaveAsync<T>(string profileId, string providerId, T payload, CancellationToken cancellationToken = default) where T : class
{
if (string.IsNullOrWhiteSpace(providerId) || payload == null)
return;
using var db = MusicContext.Create();
string normalizedProfileId = NormalizeProfileId(profileId);
var existing = await db.auth_credentials
.FirstOrDefaultAsync(i => i.profile_id == normalizedProfileId && i.provider_id == providerId, cancellationToken);
if (existing == null)
{
db.auth_credentials.Add(new MusicAuthCredentialSqlModel
{
profile_id = normalizedProfileId,
provider_id = providerId,
payload = MusicJson.Serialize(payload),
updated = DateTime.UtcNow
});
}
else
{
existing.profile_id = normalizedProfileId;
existing.payload = MusicJson.Serialize(payload);
existing.updated = DateTime.UtcNow;
db.auth_credentials.Update(existing);
}
var semaphore = new SemaphorManager(MusicContext.semaphoreKey, TimeSpan.FromSeconds(20));
try
{
if (await semaphore.WaitAsync())
await db.SaveChangesAsync(cancellationToken);
}
finally
{
semaphore.Release();
}
}
public static async Task DeleteAsync(string profileId, string providerId, CancellationToken cancellationToken = default)
{
if (string.IsNullOrWhiteSpace(providerId))
return;
using var db = MusicContext.Create();
string normalizedProfileId = NormalizeProfileId(profileId);
var existing = await db.auth_credentials
.Where(i => i.provider_id == providerId && (i.profile_id == normalizedProfileId || i.profile_id == string.Empty))
.ToListAsync(cancellationToken);
if (existing.Count == 0)
return;
db.auth_credentials.RemoveRange(existing);
var semaphore = new SemaphorManager(MusicContext.semaphoreKey, TimeSpan.FromSeconds(20));
try
{
if (await semaphore.WaitAsync())
await db.SaveChangesAsync(cancellationToken);
}
finally
{
semaphore.Release();
}
}
static string NormalizeProfileId(string profileId)
=> string.IsNullOrWhiteSpace(profileId) ? "global" : profileId.Trim().ToLowerInvariant();
}
@@ -0,0 +1,38 @@
using Microsoft.AspNetCore.Http;
using Shared.Models.Base;
using Shared.Services.Utilities;
namespace Music;
public static class MusicProfileIdentity
{
public static string Resolve(RequestModel requestInfo, HttpRequest request)
{
string profileId = requestInfo?.user_uid;
if (string.IsNullOrWhiteSpace(profileId) && request != null)
{
profileId = request.Query["uid"].FirstOrDefault() ?? request.Query["account_email"].FirstOrDefault();
if (string.IsNullOrWhiteSpace(profileId) && request.HasFormContentType)
{
try
{
profileId = request.Form["uid"].FirstOrDefault() ?? request.Form["account_email"].FirstOrDefault();
}
catch
{
}
}
}
if (!string.IsNullOrWhiteSpace(profileId))
return profileId.Trim().ToLowerInvariant();
string fingerprint = $"{requestInfo?.IP}|{requestInfo?.UserAgent}".Trim('|');
if (!string.IsNullOrWhiteSpace(fingerprint))
return $"anon:{CrypTo.md5(fingerprint)}";
return "global";
}
}