feat(privacy): keep venue phone numbers out of every public response
A doctor's office number sat next to the address on the public profile and in the anonymous API payload, so harvesting the phone number of every practice in the country was one unauthenticated request away. Street address and map coordinates stay public — a patient needs those to find the place — but the phone is now opt-in per caller: DoctorAddress::toArray() and the clinic serializers only emit it when told to, and the public doctor/clinic endpoints tell them to only when the caller may edit that profile (the same can_edit they already compute). Owner-facing address CRUD keeps returning it unchanged. The patient still gets the number where it is actually useful — their own appointment. That payload also stops guessing: it used to serialise the doctor's *first* address, so a booking made at the clinic or at a second office showed the wrong street entirely. It now resolves the address recorded on the appointment itself, which works the same for a personal office and a clinic branch, and falls back to the clinic's own number when the address has none. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -209,9 +209,11 @@ class Clinic
|
||||
array $cityData = [],
|
||||
?array $map = null,
|
||||
?string $street = null,
|
||||
?string $telephone = null
|
||||
?string $telephone = null,
|
||||
bool $withContact = false
|
||||
): array {
|
||||
$phone = $this->firstFilled($telephone, $this->telephone);
|
||||
// شمارهٔ کلینیک هم مثل شمارهٔ مطب عمومی نیست. {@see DoctorAddress::toArray()}
|
||||
$phone = $withContact ? $this->firstFilled($telephone, $this->telephone) : null;
|
||||
$address = $this->firstFilled($street, $this->address);
|
||||
|
||||
return [
|
||||
@@ -267,9 +269,9 @@ class Clinic
|
||||
return null;
|
||||
}
|
||||
|
||||
public function toListArray(?string $city = null, ?string $state = null, ?string $telephone = null): array
|
||||
public function toListArray(?string $city = null, ?string $state = null, ?string $telephone = null, bool $withContact = false): array
|
||||
{
|
||||
$phone = $this->firstFilled($telephone, $this->telephone);
|
||||
$phone = $withContact ? $this->firstFilled($telephone, $this->telephone) : null;
|
||||
|
||||
return [
|
||||
'id' => (string) $this->id,
|
||||
|
||||
Reference in New Issue
Block a user