diff --git a/common/answer.ts b/common/answer.ts index 36dd0415..9dcc3828 100644 --- a/common/answer.ts +++ b/common/answer.ts @@ -29,3 +29,5 @@ export const getNoneAnswer = (contractId: string, creator: User) => { text: 'None', } } + +export const MAX_ANSWER_LENGTH = 240 diff --git a/functions/src/create-answer.ts b/functions/src/create-answer.ts index 4bbfb089..1da8f350 100644 --- a/functions/src/create-answer.ts +++ b/functions/src/create-answer.ts @@ -9,7 +9,7 @@ import { } from '../../common/contract' import { User } from '../../common/user' import { getLoanAmount, getNewMultiBetInfo } from '../../common/new-bet' -import { Answer } from '../../common/answer' +import { Answer, MAX_ANSWER_LENGTH } from '../../common/answer' import { getContract, getValues } from './utils' import { sendNewAnswerEmail } from './emails' import { Bet } from '../../common/bet' @@ -31,7 +31,7 @@ export const createAnswer = functions.runWith({ minInstances: 1 }).https.onCall( if (amount <= 0 || isNaN(amount) || !isFinite(amount)) return { status: 'error', message: 'Invalid amount' } - if (!text || typeof text !== 'string' || text.length > 10000) + if (!text || typeof text !== 'string' || text.length > MAX_ANSWER_LENGTH) return { status: 'error', message: 'Invalid text' } // Run as transaction to prevent race conditions. diff --git a/web/components/answers/create-answer-panel.tsx b/web/components/answers/create-answer-panel.tsx index f7595f20..6a3dd8c6 100644 --- a/web/components/answers/create-answer-panel.tsx +++ b/web/components/answers/create-answer-panel.tsx @@ -22,6 +22,7 @@ import { } from '../../../common/calculate-dpm' import { firebaseLogin } from '../../lib/firebase/users' import { Bet } from '../../../common/bet' +import { MAX_ANSWER_LENGTH } from '../../../common/answer' export function CreateAnswerPanel(props: { contract: FullContract @@ -84,7 +85,7 @@ export function CreateAnswerPanel(props: { className="textarea textarea-bordered w-full resize-none" placeholder="Type your answer..." rows={1} - maxLength={10000} + maxLength={MAX_ANSWER_LENGTH} />