From 7e17e7ccb39d441332c2278f65c97ce130daaba9 Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Sat, 20 Jun 2026 19:50:12 +0330 Subject: [PATCH] Stop leaking the shared placeholder facility's phone onto unrelated shifts/jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shift/Job 426-style pages showed 09910540686 — the «نامشخص / ثبت نشده» placeholder facility's phone, set once and shown on every unnamed-facility listing (and in the contact modal), even though it isn't that ad's number. Now the facility phone/Bale is only used as a fallback when the facility is a REAL named employer (SeoJsonLd.HasRealEmployer); otherwise fall back to the Divar source link (if any) or «شماره ثبت نشده». Fixed in the /contact modal endpoint and both detail-page inline reveals. Co-Authored-By: Claude Opus 4.8 --- src/JobsMedical.Web/Pages/Jobs/Details.cshtml | 2 +- .../Pages/Shifts/Details.cshtml | 2 +- src/JobsMedical.Web/Program.cs | 22 +++++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/JobsMedical.Web/Pages/Jobs/Details.cshtml b/src/JobsMedical.Web/Pages/Jobs/Details.cshtml index 11d72ea..fe307d2 100644 --- a/src/JobsMedical.Web/Pages/Jobs/Details.cshtml +++ b/src/JobsMedical.Web/Pages/Jobs/Details.cshtml @@ -53,7 +53,7 @@ @* Numbers from THIS ad (aggregated) — the correct, per-listing contacts. *@ } - else if (!string.IsNullOrEmpty(f.Phone) || !string.IsNullOrEmpty(f.BaleId)) + else if (JobsMedical.Web.Services.SeoJsonLd.HasRealEmployer(f) && (!string.IsNullOrEmpty(f.Phone) || !string.IsNullOrEmpty(f.BaleId))) { @if (!string.IsNullOrEmpty(f.Phone)) { diff --git a/src/JobsMedical.Web/Pages/Shifts/Details.cshtml b/src/JobsMedical.Web/Pages/Shifts/Details.cshtml index 9c78f6a..12af487 100644 --- a/src/JobsMedical.Web/Pages/Shifts/Details.cshtml +++ b/src/JobsMedical.Web/Pages/Shifts/Details.cshtml @@ -53,7 +53,7 @@ @* Numbers from THIS ad (aggregated) — the correct, per-listing contacts. *@ } - else if (!string.IsNullOrEmpty(f.Phone) || !string.IsNullOrEmpty(f.BaleId)) + else if (JobsMedical.Web.Services.SeoJsonLd.HasRealEmployer(f) && (!string.IsNullOrEmpty(f.Phone) || !string.IsNullOrEmpty(f.BaleId))) { @if (!string.IsNullOrEmpty(f.Phone)) { diff --git a/src/JobsMedical.Web/Program.cs b/src/JobsMedical.Web/Program.cs index 0222a72..012a6c2 100644 --- a/src/JobsMedical.Web/Program.cs +++ b/src/JobsMedical.Web/Program.cs @@ -411,8 +411,16 @@ app.MapGet("/contact", async (string? type, int id, AppDbContext db, InterestSer if (s is null) return Results.NotFound(); title = s.Role?.Name ?? "تماس"; items.AddRange(s.Contacts.OrderBy(c => c.SortOrder).Select(c => Item(c.Type, c.Value))); - if (items.Count == 0 && !string.IsNullOrWhiteSpace(s.Facility?.Phone)) items.Add(Item(ContactType.Phone, s.Facility!.Phone!)); - if (!string.IsNullOrWhiteSpace(s.Facility?.BaleId)) items.Add(Item(ContactType.Bale, s.Facility!.BaleId!)); + // Only fall back to the facility's number for a REAL named employer — the shared + // «نامشخص» placeholder's phone is NOT this ad's number (it leaked one number onto many posts). + if (SeoJsonLd.HasRealEmployer(s.Facility)) + { + if (items.Count == 0 && !string.IsNullOrWhiteSpace(s.Facility!.Phone)) items.Add(Item(ContactType.Phone, s.Facility.Phone!)); + if (!string.IsNullOrWhiteSpace(s.Facility!.BaleId)) items.Add(Item(ContactType.Bale, s.Facility.BaleId!)); + } + if (items.Count == 0 && !string.IsNullOrWhiteSpace(s.SourceUrl) + && Uri.TryCreate(s.SourceUrl, UriKind.Absolute, out var ss) && ss.Host.Contains("divar")) + { fallbackUrl = s.SourceUrl; fallbackLabel = "مشاهده شماره در دیوار ↗"; } await interest.LogAsync(InterestEventType.Apply, id); break; } @@ -423,8 +431,14 @@ app.MapGet("/contact", async (string? type, int id, AppDbContext db, InterestSer if (j is null) return Results.NotFound(); title = j.Title; items.AddRange(j.Contacts.OrderBy(c => c.SortOrder).Select(c => Item(c.Type, c.Value))); - if (items.Count == 0 && !string.IsNullOrWhiteSpace(j.Facility?.Phone)) items.Add(Item(ContactType.Phone, j.Facility!.Phone!)); - if (!string.IsNullOrWhiteSpace(j.Facility?.BaleId)) items.Add(Item(ContactType.Bale, j.Facility!.BaleId!)); + if (SeoJsonLd.HasRealEmployer(j.Facility)) + { + if (items.Count == 0 && !string.IsNullOrWhiteSpace(j.Facility!.Phone)) items.Add(Item(ContactType.Phone, j.Facility.Phone!)); + if (!string.IsNullOrWhiteSpace(j.Facility!.BaleId)) items.Add(Item(ContactType.Bale, j.Facility.BaleId!)); + } + if (items.Count == 0 && !string.IsNullOrWhiteSpace(j.SourceUrl) + && Uri.TryCreate(j.SourceUrl, UriKind.Absolute, out var js) && js.Host.Contains("divar")) + { fallbackUrl = j.SourceUrl; fallbackLabel = "مشاهده شماره در دیوار ↗"; } await interest.LogJobAsync(InterestEventType.Apply, id); break; }