From 5d02ba3570a1fc78a020f6266452b1fc682069ef Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Mon, 1 Aug 2022 10:05:03 -0600 Subject: [PATCH] Add challenge params to parse request --- og-image/api/_lib/parser.ts | 6 ++++++ og-image/api/_lib/template.ts | 4 ++-- og-image/api/_lib/types.ts | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/og-image/api/_lib/parser.ts b/og-image/api/_lib/parser.ts index b8163719..dab8591d 100644 --- a/og-image/api/_lib/parser.ts +++ b/og-image/api/_lib/parser.ts @@ -20,6 +20,10 @@ export function parseRequest(req: IncomingMessage) { creatorName, creatorUsername, creatorAvatarUrl, + + // Challenge attributes: + challengeAmount, + challengeOutcome, } = query || {} if (Array.isArray(fontSize)) { @@ -67,6 +71,8 @@ export function parseRequest(req: IncomingMessage) { creatorName: getString(creatorName) || 'Manifold Markets', creatorUsername: getString(creatorUsername) || 'ManifoldMarkets', creatorAvatarUrl: getString(creatorAvatarUrl) || '', + challengeAmount: getString(challengeAmount), + challengeOutcome: getString(challengeOutcome), } parsedRequest.images = getDefaultImages(parsedRequest.images) return parsedRequest diff --git a/og-image/api/_lib/template.ts b/og-image/api/_lib/template.ts index 0be8b70c..7285bc15 100644 --- a/og-image/api/_lib/template.ts +++ b/og-image/api/_lib/template.ts @@ -128,7 +128,7 @@ export function getHtml(parsedReq: ParsedRequest) { - +
${ - challengeAmount ? challengeAmount : probability + challengeAmount ? 'M$' + challengeAmount : probability }
${ challengeOutcome ? 'on' + challengeOutcome : '' diff --git a/og-image/api/_lib/types.ts b/og-image/api/_lib/types.ts index 0aa0d30b..3b7f9a2d 100644 --- a/og-image/api/_lib/types.ts +++ b/og-image/api/_lib/types.ts @@ -18,6 +18,6 @@ export interface ParsedRequest { creatorName: string creatorUsername: string creatorAvatarUrl: string - challengeAmount?: string - challengeOutcome?: string + challengeAmount: string | undefined + challengeOutcome: string | undefined }