Consolidate audit-fixes branch: webhooks, integrations, and deploy hardening

Batch commit of the pending working tree on security/audit-fixes-2026-07.
Major areas:
- Outbound webhooks / Zapier: schema + signed delivery with retries, public
  v1 API (REST-hook subscribe/unsubscribe), settings UI, cron drain.
- Deploy hardening: email via SMTP2GO (Resend fully removed), verified DB TLS
  (DATABASE_SSL=require + DATABASE_CA), storage fails loud in production when
  Spaces is unconfigured instead of silently using ephemeral disk.
- Integrations & features (concurrent work): accounting (QuickBooks/Xero),
  e-signature (DocuSign/Dropbox Sign), PayPal, geocoding/maps, onboarding,
  expanded legal pages.
- DB migrations 0006–0009.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Leon Serfaty
2026-07-02 13:42:34 -04:00
co-authored by Claude Opus 4.8
parent 969d5d4c8a
commit c9968531e4
282 changed files with 41530 additions and 4013 deletions
+12 -9
View File
@@ -12,6 +12,7 @@ import {
expenses,
} from "@/lib/db/schema"
import { getSessionUser } from "@/lib/session"
import { getEffectiveOwnerId } from "@/lib/account"
import { openai } from "@/lib/ai/client"
import { enforceAiQuota } from "@/lib/ai/usage"
import { dataBlock } from "@/lib/ai/prompts"
@@ -23,8 +24,10 @@ export async function POST(request: Request) {
const quota = await enforceAiQuota(user.id, "ai_ask")
if (!quota.ok) return NextResponse.json({ error: quota.error }, { status: quota.status })
const ownerId = await getEffectiveOwnerId(user.id)
const profile = await db.query.profiles.findFirst({
where: eq(profiles.id, user.id),
where: eq(profiles.id, ownerId),
columns: { full_name: true },
})
@@ -45,7 +48,7 @@ export async function POST(request: Request) {
total_units: properties.total_units,
})
.from(properties)
.where(eq(properties.user_id, user.id)),
.where(eq(properties.user_id, ownerId)),
db
.select({
id: units.id,
@@ -56,7 +59,7 @@ export async function POST(request: Request) {
status: units.status,
})
.from(units)
.where(eq(units.user_id, user.id)),
.where(eq(units.user_id, ownerId)),
db
.select({
id: tenants.id,
@@ -69,7 +72,7 @@ export async function POST(request: Request) {
move_in_date: tenants.move_in_date,
})
.from(tenants)
.where(and(eq(tenants.user_id, user.id), eq(tenants.status, "active"))),
.where(and(eq(tenants.user_id, ownerId), eq(tenants.status, "active"))),
db
.select({
amount: rent_payments.amount,
@@ -79,7 +82,7 @@ export async function POST(request: Request) {
property_id: rent_payments.property_id,
})
.from(rent_payments)
.where(and(eq(rent_payments.user_id, user.id), gte(rent_payments.due_date, threeMonthsAgo))),
.where(and(eq(rent_payments.user_id, ownerId), gte(rent_payments.due_date, threeMonthsAgo))),
db
.select({
id: maintenance_requests.id,
@@ -91,7 +94,7 @@ export async function POST(request: Request) {
created_at: maintenance_requests.created_at,
})
.from(maintenance_requests)
.where(and(eq(maintenance_requests.user_id, user.id), inArray(maintenance_requests.status, ["open", "in_progress"]))),
.where(and(eq(maintenance_requests.user_id, ownerId), inArray(maintenance_requests.status, ["open", "in_progress"]))),
db
.select({
id: leases.id,
@@ -102,7 +105,7 @@ export async function POST(request: Request) {
status: leases.status,
})
.from(leases)
.where(and(eq(leases.user_id, user.id), eq(leases.status, "active"))),
.where(and(eq(leases.user_id, ownerId), eq(leases.status, "active"))),
db
.select({
amount: expenses.amount,
@@ -112,7 +115,7 @@ export async function POST(request: Request) {
property_id: expenses.property_id,
})
.from(expenses)
.where(and(eq(expenses.user_id, user.id), gte(expenses.expense_date, threeMonthsAgo))),
.where(and(eq(expenses.user_id, ownerId), gte(expenses.expense_date, threeMonthsAgo))),
])
// Build summary stats
@@ -162,5 +165,5 @@ Answer the landlord's question in a helpful, concise, and professional manner. U
const answer = completion.choices[0].message.content ?? ""
return NextResponse.json({ answer })
return NextResponse.json({ answer, usage: { used: quota.used, limit: quota.limit } })
}