[object Object]

← back to Nationalrealestate

usre /api/brokers: return broker_email + firm-level phone/email (firm_contacts fallback)

986b8c8e4a0357fb1f09d7f30b96e4c55c9e923b · 2026-08-12 14:37:38 -0700 · Steve Abrams

Individual DRE agents have no contact data; surface the firm's crawled phone/email so
~37,720 affiliated CA brokers get a reachable number/inbox on the RENTV desk.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 986b8c8e4a0357fb1f09d7f30b96e4c55c9e923b
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Aug 12 14:37:38 2026 -0700

    usre /api/brokers: return broker_email + firm-level phone/email (firm_contacts fallback)
    
    Individual DRE agents have no contact data; surface the firm's crawled phone/email so
    ~37,720 affiliated CA brokers get a reachable number/inbox on the RENTV desk.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 src/server/index.ts | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/server/index.ts b/src/server/index.ts
index c34cc7f..e9557e0 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -387,8 +387,12 @@ app.get('/api/brokers', async (req, res) => {
     const r = await query(
       `SELECT b.id, b.name, b.license_no, b.license_state, b.license_type, b.license_status,
               b.city, b.state_code, b.source, f.name AS firm_name, f.id AS firm_id,
-              b.phone AS broker_phone, b.website AS broker_website, b.website_status,
+              b.phone AS broker_phone, b.email AS broker_email, b.website AS broker_website, b.website_status,
               COALESCE(fs.url, f.website) AS firm_website,
+              -- firm-level contact fallback (the agent's own phone/email is usually blank on the DRE
+              -- registry; the firm's crawled contact is the next-best reachable number/inbox).
+              (SELECT value FROM firm_contacts WHERE firm_id = f.id AND kind = 'phone' ORDER BY id LIMIT 1) AS firm_phone,
+              (SELECT value FROM firm_contacts WHERE firm_id = f.id AND kind = 'email' ORDER BY id LIMIT 1) AS firm_email,
               COUNT(*) OVER()::int AS total
          FROM broker b
          LEFT JOIN firm f ON f.id = b.firm_id

← 5ddf920 usre /api/brokers: default to affiliated-only (agent must ha  ·  back to Nationalrealestate  ·  chore: usre deploy-script fixes + v0.18.1 (session close, TK 41dc5ca →