From 36efece4e39731d679932b8b4668f81d9133d4c1 Mon Sep 17 00:00:00 2001 From: Satelink Network Date: Mon, 23 Nov 2026 17:33:23 +0530 Subject: [PATCH 1/3] fix(workflows): resolve cross-role defects, venue linkage, claims and e2e reliability - Admin API: implement list and resolve endpoints for venue ownership claims and venues list with proper status casting and claimant fields - Organiser & Events: support venue_id linkage during draft creation, update, and publish to events/event_sessions tables - Venue: add venue photo upload endpoint with 2MB limit and magic byte sniffing; link venue command centre to organiser draft wizard - Attendee Bookings: enforce CSRF protection on booking cancellations; enforce ticket tier min_per_booking, sales_start_at, and sales_end_at constraints - HTTP & Network: handle oversized payload with 413 without socket abort (ECONNRESET) - Test Matrix: add 107-scenario God-Mode E2E workflow matrix covering all roles, error conditions, and concurrency --- lib/handlers/admin.js | 159 ++- lib/handlers/bookings.js | 3 +- lib/handlers/business.js | 4 +- lib/handlers/organiser.js | 13 +- lib/handlers/venue.js | 16 +- lib/http.js | 4 +- lib/router.js | 6 +- lib/services/events.js | 1 + lib/services/organiser.js | 38 +- lib/services/ticketing.js | 10 + lib/services/venue.js | 4 +- lib/views/layout.js | 2 +- public/js/organiser.js | 10 + public/js/venue.js | 8 +- test/god-mode-e2e-workflow-matrix.test.js | 1389 +++++++++++++++++++++ test/helpers.js | 1 + 16 files changed, 1648 insertions(+), 20 deletions(-) create mode 100644 test/god-mode-e2e-workflow-matrix.test.js diff --git a/lib/handlers/admin.js b/lib/handlers/admin.js index 8133465..f35fb99 100644 --- a/lib/handlers/admin.js +++ b/lib/handlers/admin.js @@ -160,7 +160,7 @@ export async function overview(ctx) { (SELECT count(*)::int FROM leads WHERE status = 'new') AS new_leads, (SELECT count(*)::int FROM reports WHERE status = 'new') AS new_reports, (SELECT count(*)::int FROM reports WHERE status = 'reviewing') AS reviewing_reports, - (SELECT count(*)::int FROM venues WHERE status = 'active') AS venues_active, + (SELECT count(*)::int FROM venues WHERE status = 'active' AND onboarding_completed = true) AS venues_active, (SELECT count(*)::int FROM organisations WHERE status = 'active') AS organisations_active, (SELECT count(*)::int FROM user_blocks) AS user_blocks_total, (SELECT count(*)::int FROM audit_log) AS audit_events_total, @@ -1444,4 +1444,161 @@ export async function adminFinanceExport(ctx) { ctx.res.end(csv); } +// ---------- Venue Management & Ownership Claims ---------- + +export async function listAdminVenueClaims(ctx) { + await guard(ctx, R.ANY); + const statusFilter = ctx.query.get('status') || null; + const p = page(ctx.query, { defaultLimit: 50, maxLimit: 100 }); + const { rows } = await db.query( + `SELECT vc.id, vc.venue_id, vc.claimant_user_id, vc.claimant_org_id, vc.claimant_role, + vc.business_proof_type, vc.business_proof_ref, vc.contact_name, vc.contact_email, + vc.contact_phone, vc.notes, vc.status, vc.resolution_notes, vc.resolved_at, + vc.created_at, vc.updated_at, + v.name AS venue_name, v.org_id AS current_org_id, + u.alias AS claimant_alias, u.telegram_user_id AS claimant_telegram_user_id + FROM venue_claims vc + JOIN venues v ON v.id = vc.venue_id + JOIN users u ON u.id = vc.claimant_user_id + WHERE ($1::text IS NULL OR vc.status = $1) + ORDER BY vc.created_at DESC + LIMIT $2 OFFSET $3`, + [statusFilter, p.limit + 1, p.offset] + ); + sendJson(ctx.res, 200, { ok: true, claims: rows.slice(0, p.limit), page: pageInfo(rows, p) }); +} + +const ResolveVenueClaimBody = z.object({ + decision: z.enum(['approved', 'rejected', 'reviewing']), + resolutionNotes: z.string().trim().min(3).max(2000) +}).strict(); + +export async function resolveAdminVenueClaim(ctx) { + const a = await guard(ctx, R.SUPER, { write: true }); + const claimId = uuidParam(ctx.params.id); + const b = parse(ResolveVenueClaimBody, await readJson(ctx.req)); + + const result = await db.tx(async (c) => { + const claim = (await c.query( + `SELECT vc.*, v.org_id AS current_org_id, v.name AS venue_name + FROM venue_claims vc + JOIN venues v ON v.id = vc.venue_id + WHERE vc.id = $1 + FOR UPDATE OF vc`, + [claimId] + )).rows[0]; + + if (!claim) throw new HttpError(404, 'not_found', 'Venue claim not found'); + if (['approved', 'rejected'].includes(claim.status)) { + throw new HttpError(409, 'already_resolved', `Claim has already been ${claim.status}`); + } + + if (b.decision === 'approved') { + if (!claim.claimant_org_id) { + throw new HttpError(400, 'missing_claimant_org', 'Claimant organisation is missing'); + } + const updatedClaim = (await c.query( + `UPDATE venue_claims + SET status = 'approved', + resolution_notes = $2, + resolved_at = now(), + updated_at = now() + WHERE id = $1 + RETURNING *`, + [claimId, b.resolutionNotes] + )).rows[0]; + + // Transfer venue to claimant organisation + await c.query( + `UPDATE venues + SET org_id = $2, + updated_at = now() + WHERE id = $1`, + [claim.venue_id, claim.claimant_org_id] + ); + + // Ensure claimant user has manage_venue capability + await c.query( + `INSERT INTO user_capabilities (user_id, capability_code, status) + VALUES ($1, 'manage_venue', 'claimed') + ON CONFLICT (user_id, capability_code) DO NOTHING`, + [claim.claimant_user_id] + ); + + await audit(a.actor, 'venue.claim.approve', claimId, { + venueId: claim.venue_id, + venueName: claim.venue_name, + fromOrgId: claim.current_org_id, + toOrgId: claim.claimant_org_id, + notes: b.resolutionNotes + }, c); + + return { claim: updatedClaim, message: 'Ownership claim approved and venue transferred successfully.' }; + } + + if (b.decision === 'rejected') { + const updatedClaim = (await c.query( + `UPDATE venue_claims + SET status = 'rejected', + resolution_notes = $2, + resolved_at = now(), + updated_at = now() + WHERE id = $1 + RETURNING *`, + [claimId, b.resolutionNotes] + )).rows[0]; + + await audit(a.actor, 'venue.claim.reject', claimId, { + venueId: claim.venue_id, + venueName: claim.venue_name, + notes: b.resolutionNotes + }, c); + + return { claim: updatedClaim, message: 'Ownership claim rejected.' }; + } + + // reviewing status + const updatedClaim = (await c.query( + `UPDATE venue_claims + SET status = 'reviewing', + resolution_notes = $2, + updated_at = now() + WHERE id = $1 + RETURNING *`, + [claimId, b.resolutionNotes] + )).rows[0]; + + await audit(a.actor, 'venue.claim.reviewing', claimId, { + venueId: claim.venue_id, + notes: b.resolutionNotes + }, c); + + return { claim: updatedClaim, message: 'Claim status set to reviewing.' }; + }); + + sendJson(ctx.res, 200, { ok: true, ...result }); +} + +export async function listAdminVenues(ctx) { + await guard(ctx, R.ANY); + const statusFilter = ctx.query.get('status') || null; + const p = page(ctx.query, { defaultLimit: 50, maxLimit: 100 }); + const { rows } = await db.query( + `SELECT v.id, v.org_id, v.name, v.category, v.neighbourhood, v.capacity, v.status, + v.onboarding_completed, v.address_public, v.contact_email, v.contact_phone, + v.created_at, v.updated_at, + o.name AS org_name, o.verified_at IS NOT NULL AS org_verified, + c.name AS city_name, + (SELECT count(*)::int FROM events e WHERE e.venue_id = v.id AND NOT e.is_deleted) AS events_count + FROM venues v + JOIN organisations o ON o.id = v.org_id + LEFT JOIN location_cities c ON c.id = v.city_id + WHERE ($1::text IS NULL OR v.status::text = $1) + ORDER BY v.created_at DESC + LIMIT $2 OFFSET $3`, + [statusFilter, p.limit + 1, p.offset] + ); + sendJson(ctx.res, 200, { ok: true, venues: rows.slice(0, p.limit), page: pageInfo(rows, p) }); +} + diff --git a/lib/handlers/bookings.js b/lib/handlers/bookings.js index fe8e41e..da6c286 100644 --- a/lib/handlers/bookings.js +++ b/lib/handlers/bookings.js @@ -1,6 +1,6 @@ // lib/handlers/bookings.js - Member booking reads (session). import { sendJson, HttpError, readRawBody } from '../http.js'; -import { requireUser } from '../session.js'; +import { requireUser, requireCsrf } from '../session.js'; import { listUserBookings, getUserBooking, listUserAnnouncements, cancelUserBooking } from '../services/bookings.js'; export async function myBookings({ req, res }) { @@ -23,6 +23,7 @@ export async function getBooking({ req, res, params }) { export async function cancelMyBooking({ req, res, params }) { const user = await requireUser(req); + requireCsrf(req, user); if (!/^[0-9a-f-]{36}$/i.test(params.id)) throw new HttpError(404, 'not_found', 'Booking not found'); let reason = 'Cancelled by attendee'; try { diff --git a/lib/handlers/business.js b/lib/handlers/business.js index 4dc8411..8b97cd2 100644 --- a/lib/handlers/business.js +++ b/lib/handlers/business.js @@ -97,7 +97,7 @@ export async function getOverviewApi({ req, res }) { // Venues linked to workspace const { rows: venues } = await db.query( - `SELECT id, name, status, capacity, city_id, address_public FROM venues WHERE org_id = $1 AND status = 'active'`, + `SELECT id, name, status, capacity, city_id, address_public FROM venues WHERE org_id = $1 AND status = 'active' AND onboarding_completed = true`, [ws.org_id] ); @@ -106,7 +106,7 @@ export async function getOverviewApi({ req, res }) { `SELECT en.*, v.name AS venue_name FROM venue_enquiries en JOIN venues v ON v.id = en.venue_id - WHERE v.org_id = $1 AND en.status = 'pending' + WHERE v.org_id = $1 AND en.status = 'pending' AND v.status = 'active' AND v.onboarding_completed = true ORDER BY en.created_at DESC LIMIT 5`, [ws.org_id] diff --git a/lib/handlers/organiser.js b/lib/handlers/organiser.js index 722645f..9ee3e75 100644 --- a/lib/handlers/organiser.js +++ b/lib/handlers/organiser.js @@ -61,9 +61,10 @@ async function pageState(req, eventId = null) { return { state: 'not_organiser', user }; } -function wizardConfig(user, draftId) { +function wizardConfig(user, draftId, venueId = null) { return { draftId: draftId || null, + venueId: venueId || null, alias: user.alias || '', templates: Object.entries(O.TEMPLATES).map(([key, t]) => ({ key, label: t.label, hint: t.hint, defaults: O.initialDraftData(key) })), cities: CITIES.map((c) => c.name), @@ -87,7 +88,9 @@ export async function dashboardPage({ req, res }) { export async function wizardPage({ req, res, query }) { const s = await pageState(req); const draft = query.get('draft'); - const config = s.state === 'ok' ? wizardConfig(s.user, uuid.safeParse(draft).success ? draft : null) : null; + const venueIdParam = query.get('venue_id'); + const venueId = uuid.safeParse(venueIdParam).success ? venueIdParam : null; + const config = s.state === 'ok' ? wizardConfig(s.user, uuid.safeParse(draft).success ? draft : null, venueId) : null; sendHtml(res, 200, renderOrganiserPage({ page: 'wizard', ...s, config }), NOINDEX); } @@ -147,7 +150,10 @@ export async function listDrafts(ctx) { sendJson(ctx.res, 200, { ok: true, drafts: await O.listDrafts(user.id) }); } -const CreateBody = z.object({ template: z.enum(Object.keys(O.TEMPLATES)).optional() }).strict(); +const CreateBody = z.object({ + template: z.enum(Object.keys(O.TEMPLATES)).optional(), + venueId: z.string().uuid().optional() +}).strict(); export async function createDraft(ctx) { const user = await organiser(ctx, { write: true }); @@ -277,6 +283,7 @@ const UpdateEventBody = z.object({ area_public: z.string().max(120).nullable().optional(), venue_private: z.string().max(300).nullable().optional(), venue_privacy: z.enum(['public', 'disclosed_after_booking']).optional(), + venue_id: z.string().uuid().nullable().optional(), maps_url: z.string().max(500).nullable().optional(), refund_policy: z.string().max(1000).nullable().optional() }).strict(); diff --git a/lib/handlers/venue.js b/lib/handlers/venue.js index e28ff67..74bb518 100644 --- a/lib/handlers/venue.js +++ b/lib/handlers/venue.js @@ -1,11 +1,13 @@ // lib/handlers/venue.js - Venue Owner Dashboard page and API endpoints. // Strict access control: every API verifies session and venue ownership via lib/services/venue.js. // State-changing requests enforce CSRF tokens and rate limiting. -import { HttpError, readJson, sendJson, sendHtml } from '../http.js'; +import { HttpError, readJson, readBinaryBody, sendJson, sendHtml } from '../http.js'; import { getSessionUser, requireUser, requireCsrf, csrfTokenFor } from '../session.js'; import { parse, z, uuid } from '../validate.js'; import { rateLimit } from '../ratelimit.js'; import { renderVenuePage } from '../views/venue.js'; +import { db } from '../db.js'; +import { sniffImage, MAX_IMAGE_BYTES, imageUrl } from '../services/organiser.js'; import * as V from '../services/venue.js'; const uuidParam = (v) => { @@ -316,3 +318,15 @@ export async function listVenueClaimsApi(ctx) { const claims = await V.getVenueClaims(user); sendJson(ctx.res, 200, { ok: true, claims }); } + +export async function uploadVenuePhotoApi(ctx) { + const user = await writer(ctx); + const buf = await readBinaryBody(ctx.req, MAX_IMAGE_BYTES); + const type = sniffImage(buf, ctx.req.headers['content-type']); + const r = await db.one( + `INSERT INTO event_images (owner_user_id, content_type, bytes, byte_size, is_public) + VALUES ($1, $2, $3, $4, true) RETURNING id`, + [user.id, type, buf, buf.length] + ); + sendJson(ctx.res, 201, { ok: true, imageId: r.id, url: imageUrl(r.id) }); +} diff --git a/lib/http.js b/lib/http.js index d3c34b4..cff9b65 100644 --- a/lib/http.js +++ b/lib/http.js @@ -22,7 +22,7 @@ export function readRawBody(req, limit = MAX_BODY_BYTES) { size += chunk.length; if (size > limit) { reject(new HttpError(413, 'payload_too_large', 'Request body too large')); - req.destroy(); + req.resume(); return; } chunks.push(chunk); @@ -44,7 +44,7 @@ export function readBinaryBody(req, limit) { size += chunk.length; if (size > limit) { reject(new HttpError(413, 'payload_too_large', 'File too large')); - req.destroy(); + req.resume(); return; } chunks.push(chunk); diff --git a/lib/router.js b/lib/router.js index b910f00..5f805ff 100644 --- a/lib/router.js +++ b/lib/router.js @@ -182,6 +182,7 @@ const ROUTES = [ ['POST', '/api/venue/apply', h('venue', 'applyVenueApi')], ['POST', '/api/venue/claim', h('venue', 'submitVenueClaimApi')], ['GET', '/api/venue/claims', h('venue', 'listVenueClaimsApi')], + ['POST', '/api/venue/photos', h('venue', 'uploadVenuePhotoApi')], // Organiser (session + organiser access; drafts and events are owner-scoped) ['GET', '/api/organiser/context', h('organiser', 'context')], @@ -306,7 +307,10 @@ const ROUTES = [ ['POST', '/api/admin/organisers', h('admin', 'setOrganiser')], ['GET', '/api/admin/orgs', h('admin', 'listOrgs')], ['POST', '/api/admin/orgs', h('admin', 'createOrg')], - ['PATCH', '/api/admin/orgs/:id', h('admin', 'updateOrg')] + ['PATCH', '/api/admin/orgs/:id', h('admin', 'updateOrg')], + ['GET', '/api/admin/venues', h('admin', 'listAdminVenues')], + ['GET', '/api/admin/venue-claims', h('admin', 'listAdminVenueClaims')], + ['POST', '/api/admin/venue-claims/:id/resolve', h('admin', 'resolveAdminVenueClaim')] ]; const COMPILED = ROUTES.map(([method, pattern, load]) => { diff --git a/lib/services/events.js b/lib/services/events.js index 3bb9070..fd56b10 100644 --- a/lib/services/events.js +++ b/lib/services/events.js @@ -218,6 +218,7 @@ export function toPublicEvent(row, { checkout = checkoutForEvent(row) } = {}) { localityId: row.locality_id || null, area: row.area_public || '', venue: venuePublic ? (row.venue_private || '') : '', + venueId: row.venue_id || null, venuePrivacy: row.venue_privacy, coordsProvenance: row.coords_provenance || (row.lat != null ? 'city' : 'none'), lat: venuePublic && row.coords_provenance === 'venue' && row.lat != null ? Number(row.lat) : null, diff --git a/lib/services/organiser.js b/lib/services/organiser.js index f129272..9900fa3 100644 --- a/lib/services/organiser.js +++ b/lib/services/organiser.js @@ -125,6 +125,7 @@ export const DraftData = z.object({ endLocal: text(16), multiDay: flag, venue: text(300), + venueId: z.string().uuid().nullable().optional(), city: text(60), area: text(120), mapsUrl: text(500), @@ -428,8 +429,23 @@ export async function getDraft(userId, draftId, c = db) { return r; } -export async function createDraft(user, { template, data } = {}) { +export async function createDraft(user, { template, data, venueId } = {}) { const parsed = data ? parse(DraftData, data) : initialDraftData(template); + if (venueId && !parsed.venueId) { + const vRow = (await db.query( + `SELECT v.id, v.name, v.neighbourhood, v.address_public, v.address_private, c.name AS city_name + FROM venues v + LEFT JOIN location_cities c ON c.id = v.city_id + WHERE v.id = $1 AND v.status = 'active' AND v.onboarding_completed = true`, + [venueId] + )).rows[0]; + if (vRow) { + parsed.venueId = vRow.id; + if (!parsed.venue) parsed.venue = vRow.name; + if (!parsed.city && vRow.city_name) parsed.city = vRow.city_name; + if (!parsed.area && vRow.neighbourhood) parsed.area = vRow.neighbourhood; + } + } const open = await db.one(`SELECT count(*)::int AS n FROM event_drafts WHERE organiser_user_id = $1 AND status = 'active'`, [user.id]); if (open.n >= 20) throw new HttpError(409, 'too_many_drafts', 'You have 20 unfinished drafts. Publish or discard one first.'); const r = await db.one( @@ -669,14 +685,20 @@ export async function publishDraft(user, draftId, { version, confirm }) { const hasPaid = tickets.some((t) => t.kind === 'paid'); const checkoutMode = hasPaid ? (checkout.available && (checkout.provider === 'phonepe' || checkout.provider === 'phonepe_sandbox') ? 'upi_direct' : 'none') : 'free'; + let linkedVenueId = null; + if (d.venueId) { + const v = (await c.query("SELECT id FROM venues WHERE id = $1 AND status = 'active' AND onboarding_completed = true", [d.venueId])).rows[0]; + if (v) linkedVenueId = v.id; + } + const ev = (await c.query( `INSERT INTO events (slug, category, title, summary, description, city, city_id, locality_id, lat, lng, coords_provenance, area_public, venue_private, venue_privacy, start_at, end_at, timezone, capacity, price_status, refund_policy, organizer, status, published_at, organiser_user_id, draft_id, ticketing, is_multi_day, maps_url, requires_approval, booking_questions, pickup_points, contact_name, contact_phone, gallery, features, cover_media_id, - organiser_org_id, checkout_mode) + organiser_org_id, checkout_mode, venue_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, 'tbd', $19, $20, 'published', now(), $21, $22, 'tiers', - $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34) RETURNING id, slug, category`, + $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35) RETURNING id, slug, category, venue_id`, [slugify(d.title), d.category, clean(d.title), summaryOf(d.description) || null, clean(d.description), canonicalCity, cityId, localityId, lat, lng, coordsProvenance, clean(d.area) || null, clean(d.venue) || null, d.privateVenue ? 'disclosed_after_booking' : 'public', zonedToUtc(effectiveStart, tz), @@ -686,7 +708,7 @@ export async function publishDraft(user, draftId, { version, confirm }) { JSON.stringify(f.questions?.enabled ? sanitizeQuestions(f.questions.items) : []), JSON.stringify(f.pickup?.enabled ? sanitizePickups(f.pickup.points) : []), contactPhone ? clean(f.contact.name) : null, contactPhone, - JSON.stringify((d.imageIds || []).map(imageUrl)), JSON.stringify(finalFeatures), coverMediaId, orgId, checkoutMode])).rows[0]; + JSON.stringify((d.imageIds || []).map(imageUrl)), JSON.stringify(finalFeatures), coverMediaId, orgId, checkoutMode, linkedVenueId])).rows[0]; // Insert recurring / multi-date occurrences into event_sessions const sessionMap = new Map(); @@ -708,7 +730,7 @@ export async function publishDraft(user, draftId, { version, confirm }) { ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) RETURNING id, session_date`, [ev.id, idx + 1, item.date, sStart, sEnd, item.label || `Session ${idx + 1}`, - sched.venueArrangement === 'different' ? (item.venueId || null) : null, + sched.venueArrangement === 'different' ? (item.venueId || null) : (linkedVenueId || null), sVenueName || null, sVenueAddress || null, sCity, sMapsUrl, sLat, sLng, sTz] )).rows[0]; sessionMap.set(item.date, sRow.id); @@ -997,6 +1019,12 @@ export async function updateOrganiserEvent(user, eventId, updates) { values.push(clean(updates.venue_private) || null); } + if (updates.venue_id !== undefined || updates.venueId !== undefined) { + const vId = updates.venue_id !== undefined ? updates.venue_id : updates.venueId; + fields.push(`venue_id = $${idx++}`); + values.push(vId || null); + } + if (updates.area_public !== undefined) { fields.push(`area_public = $${idx++}`); values.push(clean(updates.area_public) || null); diff --git a/lib/services/ticketing.js b/lib/services/ticketing.js index 86da7bf..1f76117 100644 --- a/lib/services/ticketing.js +++ b/lib/services/ticketing.js @@ -91,7 +91,17 @@ export async function bookTier(user, eventId, body) { const tier = (await c.query('SELECT * FROM ticket_types WHERE id = $1 AND event_id = $2 AND active', [tierId, eventId])).rows[0]; if (!tier) throw new HttpError(404, 'ticket_not_found', 'That ticket type is not available'); const qty = body.quantity; + const minPerBooking = tier.min_per_booking || 1; + if (qty < minPerBooking) { + throw new HttpError(400, 'validation', `At least ${minPerBooking} ${tier.name} ticket${minPerBooking === 1 ? '' : 's'} required per booking`, { fields: [{ field: 'quantity', message: 'Too few tickets' }] }); + } if (qty > tier.max_per_booking) throw new HttpError(400, 'validation', `Up to ${tier.max_per_booking} ${tier.name} ticket${tier.max_per_booking === 1 ? '' : 's'} per booking`, { fields: [{ field: 'quantity', message: 'Too many tickets' }] }); + if (tier.sales_start_at && new Date(tier.sales_start_at) > new Date()) { + throw new HttpError(409, 'sales_not_started', 'Ticket sales have not started yet'); + } + if (tier.sales_end_at && new Date(tier.sales_end_at) < new Date()) { + throw new HttpError(409, 'sales_ended', 'Ticket sales have ended'); + } if (tier.eligibility && !body.eligibilityConfirmed) { throw new HttpError(400, 'validation', `Please confirm you meet this ticket’s eligibility: ${tier.eligibility}`, { fields: [{ field: 'eligibilityConfirmed', message: 'Required' }] }); } diff --git a/lib/services/venue.js b/lib/services/venue.js index 9eae18e..976f755 100644 --- a/lib/services/venue.js +++ b/lib/services/venue.js @@ -98,7 +98,7 @@ export async function getVenueContext(user, requestedVenueId = null, c = db) { `SELECT o.id, o.name, o.kind, o.status, o.verified_at, 'owner'::org_role AS role FROM organisations o WHERE o.status = 'active' - AND (o.kind = 'venue_operator' OR EXISTS (SELECT 1 FROM venues v WHERE v.org_id = o.id AND v.status = 'active')) + AND (o.kind = 'venue_operator' OR EXISTS (SELECT 1 FROM venues v WHERE v.org_id = o.id AND v.status = 'active' AND v.onboarding_completed = true)) ORDER BY o.name` )).rows; } else { @@ -107,7 +107,7 @@ export async function getVenueContext(user, requestedVenueId = null, c = db) { FROM org_memberships m JOIN organisations o ON o.id = m.org_id WHERE m.user_id = $1 AND m.status = 'active' AND o.status = 'active' - AND (o.kind = 'venue_operator' OR EXISTS (SELECT 1 FROM venues v WHERE v.org_id = o.id AND v.status = 'active')) + AND (o.kind = 'venue_operator' OR EXISTS (SELECT 1 FROM venues v WHERE v.org_id = o.id AND v.status = 'active' AND v.onboarding_completed = true)) ORDER BY o.name`, [user.id] )).rows; diff --git a/lib/views/layout.js b/lib/views/layout.js index e6812ad..bc83a6b 100644 --- a/lib/views/layout.js +++ b/lib/views/layout.js @@ -290,7 +290,7 @@ function footer() {

A vibrant social discovery and experiences marketplace across South India. Discover events, meet new people, and explore nightlife. Adults 21+ only.

${col('Discover', [['All events', '/events'], ['Nightlife', '/nightlife'], ['Weekend parties', '/weekend-parties'], ['Dinners', '/dinners'], ['Meetups', '/meetups'], ['Dating & Matchmaking', '/dating'], ['Weekend trips', '/trips']])} - ${col('Business', [['Business Overview', '/business'], ['Create Experience', '/business/new'], ['Venue Partners', '/business/new?type=venue'], ['Host With Us', '/business/new?type=host'], ['Suppliers & Partners', '/business/new?type=supplier']])} + ${col('Business', [['Business Overview', '/business'], ['List Your Venue', '/list-your-venue'], ['Create Experience', '/business/new'], ['Venue Partners', '/business/new?type=venue'], ['Host With Us', '/business/new?type=host'], ['Suppliers & Partners', '/business/new?type=supplier']])} ${col('Information', [['FAQ', '/faq'], ['Trust & Safety', '/trust-safety'], ['Community Guidelines', '/community-guidelines'], ['Privacy', '/privacy'], ['Terms', '/terms'], ['Contact', '/contact']])}