feat(job-search): read providers from DB and suppress link when none enabled
JobTokenService.CreateTokenAsync queries cvSearch.JobProviders for any enabled row; returns null (no token created) when the table is empty or all providers are disabled. TriggerStartAsync snapshots enabled providers from DB at session-start time, preserving the existing snapshot contract. CvMatcherController guards link-building on a non-null TokenId so the "Start a job search" CTA is omitted from match emails when no providers are configured. JobSearchSettings.Providers list removed — provider config now lives exclusively in the DB. CvSearchJobTask.GetProviders falls back to an empty list with a warning (snapshot should always be populated from DB). Closes #35 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -204,20 +204,27 @@ public sealed class CvSearchJobTask : IJobTask
|
||||
|
||||
/// <summary>
|
||||
/// Deserialises the provider configuration snapshot stored on the session.
|
||||
/// Falls back to the current live config when the snapshot is absent or unparseable.
|
||||
/// Providers are always snapshotted from the DB at session-creation time, so the snapshot
|
||||
/// should always be present. Returns an empty list (with a warning) when it is missing or corrupt.
|
||||
/// </summary>
|
||||
private List<JobProviderConfig> GetProviders(string? providerConfigJson)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(providerConfigJson)) return _settings.Providers.Where(p => p.Enabled).ToList();
|
||||
if (string.IsNullOrWhiteSpace(providerConfigJson))
|
||||
{
|
||||
_logger.LogWarning("Session has no provider config snapshot — returning empty provider list");
|
||||
return [];
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return JsonSerializer.Deserialize<List<JobProviderConfig>>(providerConfigJson,
|
||||
new JsonSerializerOptions(JsonSerializerDefaults.Web))
|
||||
?? _settings.Providers.Where(p => p.Enabled).ToList();
|
||||
?? [];
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return _settings.Providers.Where(p => p.Enabled).ToList();
|
||||
_logger.LogWarning(ex, "Failed to deserialise provider config snapshot — returning empty provider list");
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user