Stop leaking the shared placeholder facility's phone onto unrelated shifts/jobs
CI/CD / CI · dotnet build (push) Successful in 1m32s
CI/CD / Deploy · hamkadr (push) Successful in 1m21s

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 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-20 19:50:12 +03:30
parent f1a00cb955
commit 7e17e7ccb3
3 changed files with 20 additions and 6 deletions
@@ -53,7 +53,7 @@
@* Numbers from THIS ad (aggregated) — the correct, per-listing contacts. *@
<partial name="_ContactList" model="jobContacts" />
}
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))
{
@@ -53,7 +53,7 @@
@* Numbers from THIS ad (aggregated) — the correct, per-listing contacts. *@
<partial name="_ContactList" model="shiftContacts" />
}
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))
{
+18 -4
View File
@@ -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;
}