using JobsMedical.Web.Models;

namespace JobsMedical.Web.Services.Scraping;

/// <summary>One raw post pulled from a source (a Telegram message, a Divar ad, etc.).
/// Lat/Lng are an APPROXIMATE location when the source exposes one (e.g. Divar's privacy-fuzzed
/// map center) — used to place an aggregated facility on the map / enable «near me».
/// PostedAt is the post's ORIGINAL publish time when the source exposes it (Telegram &lt;time&gt;,
/// Bale message date…) — used to drop stale applicant ads at ingest. Null when unknown.</summary>
public record ScrapedItem(string Source, string RawText, string? SourceUrl = null,
                          double? Lat = null, double? Lng = null, DateTime? PostedAt = null);

/// <summary>
/// A pluggable source the ingestion engine pulls from. Configuration (enabled, channels, tokens)
/// comes from the DB-backed <see cref="AppSetting"/> passed in — set in the admin panel, not env.
/// A disabled/unconfigured source returns an empty list.
/// </summary>
public interface IListingSource
{
    string Name { get; }
    Task<IReadOnlyList<ScrapedItem>> FetchAsync(AppSetting settings, CancellationToken ct = default);
}
