Skip to content

Commit

Permalink
Only provide unlisted bets with contract id
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Apr 20, 2023
1 parent 8c5f005 commit 5d298fd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions web/pages/api/v0/bets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { applyCorsHeaders, CORS_UNRESTRICTED } from 'web/lib/api/cors'
import { Bet } from 'common/bet'
import { getBet, getPublicBets } from 'web/lib/supabase/bets'
import { getBet, getBets, getPublicBets } from 'web/lib/supabase/bets'
import { getContractFromSlug } from 'web/lib/supabase/contracts'
import { getUserByUsername } from 'web/lib/firebase/users'
import { ApiError, ValidationError } from './_types'
Expand Down Expand Up @@ -93,7 +93,9 @@ export default async function handler(
getContractId(params),
getBeforeTime(params),
])
const bets = await getPublicBets({ userId, contractId, beforeTime, limit })
const bets = contractId
? await getBets({ userId, contractId, beforeTime, limit })
: await getPublicBets({ userId, contractId, beforeTime, limit })

res.setHeader('Cache-Control', 'max-age=15, public')
return res.status(200).json(bets)
Expand Down

0 comments on commit 5d298fd

Please sign in to comment.