Allow free daily market with M-zsh
This commit is contained in:
parent
2ddd95e904
commit
ca8420d61b
|
@ -72,11 +72,19 @@ export const createContract = functions
|
|||
return { status: 'error', message: 'Invalid initial probability' }
|
||||
|
||||
const ante = FIXED_ANTE // data.ante
|
||||
// uses utc time on server:
|
||||
const today = new Date().setHours(0, 0, 0, 0)
|
||||
const userContractsCreatedTodaySnapshot = await firestore
|
||||
.collection(`contracts`)
|
||||
.where('creatorId', '==', userId)
|
||||
.where('createdTime', '>=', today)
|
||||
.get()
|
||||
const isFree = userContractsCreatedTodaySnapshot.size === 0
|
||||
|
||||
if (
|
||||
ante === undefined ||
|
||||
ante < MINIMUM_ANTE ||
|
||||
ante > creator.balance ||
|
||||
(ante > creator.balance && !isFree) ||
|
||||
isNaN(ante) ||
|
||||
!isFinite(ante)
|
||||
)
|
||||
|
@ -108,15 +116,6 @@ export const createContract = functions
|
|||
tags ?? []
|
||||
)
|
||||
|
||||
// uses utc time on server:
|
||||
const today = new Date().setHours(0, 0, 0, 0)
|
||||
const userContractsCreatedTodaySnapshot = await firestore
|
||||
.collection(`contracts`)
|
||||
.where('creatorId', '==', userId)
|
||||
.where('createdTime', '>=', today)
|
||||
.get()
|
||||
const isFree = userContractsCreatedTodaySnapshot.size === 0
|
||||
|
||||
if (!isFree && ante) await chargeUser(creator.id, ante)
|
||||
|
||||
await contractRef.create(contract)
|
||||
|
|
|
@ -99,7 +99,7 @@ export function NewContract(props: { question: string; tag?: string }) {
|
|||
ante !== undefined &&
|
||||
ante !== null &&
|
||||
ante >= MINIMUM_ANTE &&
|
||||
ante <= balance &&
|
||||
(ante <= balance || deservesDailyFreeMarket) &&
|
||||
// closeTime must be in the future
|
||||
closeTime &&
|
||||
closeTime > Date.now()
|
||||
|
|
Loading…
Reference in New Issue
Block a user