diff --git a/.changeset/block-gmail-corp-domain.md b/.changeset/block-gmail-corp-domain.md new file mode 100644 index 0000000000..aefb92e1e1 --- /dev/null +++ b/.changeset/block-gmail-corp-domain.md @@ -0,0 +1,4 @@ +--- +--- + +Fix domain health page to exclude free email providers (gmail.com, etc.) from "Related Organizations" section diff --git a/server/src/routes/admin/domains.ts b/server/src/routes/admin/domains.ts index 7aeaa01f3e..3613f6d8eb 100644 --- a/server/src/routes/admin/domains.ts +++ b/server/src/routes/admin/domains.ts @@ -1439,6 +1439,8 @@ export function setupDomainRoutes( SUBSTRING(domain FROM '([^.]+\\.[^.]+)$') as root_domain FROM org_domains WHERE domain IS NOT NULL + -- Exclude personal email domains (gmail.com, yahoo.com, admin-managed domains, etc.) + AND LOWER(SUBSTRING(domain FROM '([^.]+\\.[^.]+)$')) NOT IN (${freeEmailPlaceholders}) ), root_groups AS ( -- Group by root domain, only keep groups with multiple orgs @@ -1461,8 +1463,8 @@ export function setupDomainRoutes( ) SELECT * FROM root_groups ORDER BY org_count DESC - LIMIT $1 - `, [limit]); + LIMIT $${allExcludedDomains.length + 1} + `, [...allExcludedDomains, limit]); // 7. Similar organization names - find orgs with similar names that might be duplicates // Uses trigram similarity (requires pg_trgm extension) or simple word matching