From dd84a0689eedc5a79574bbe5e1e4c79da5c6bfa1 Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Thu, 7 Sep 2023 09:01:18 -0400 Subject: [PATCH 1/2] add optional count param to active story script --- server/src/core/server/app/handlers/api/story/active.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/core/server/app/handlers/api/story/active.ts b/server/src/core/server/app/handlers/api/story/active.ts index bf0ba6b44b..765101c6ed 100644 --- a/server/src/core/server/app/handlers/api/story/active.ts +++ b/server/src/core/server/app/handlers/api/story/active.ts @@ -14,11 +14,13 @@ export type Options = Pick; const ActiveStoriesQuerySchema = Joi.object().keys({ callback: Joi.string().allow("").optional(), siteID: Joi.string().required(), + count: Joi.number().optional(), }); interface ActiveStoriesQuery { callback: string; siteID: string; + count: number; } /** @@ -44,7 +46,7 @@ export const activeJSONPHandler = const { tenant, now } = req.coral; // Ensure we have a siteID on the query. - const { siteID }: ActiveStoriesQuery = validate( + const { siteID, count }: ActiveStoriesQuery = validate( ActiveStoriesQuerySchema, req.query ); @@ -61,7 +63,7 @@ export const activeJSONPHandler = mongo, tenant.id, siteID, - 5, + count ?? 5, start, now ); From f27e04bcda98f973c0a38b45415fdb6cb9cf120f Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Thu, 7 Sep 2023 15:45:19 -0400 Subject: [PATCH 2/2] add a max count --- server/src/core/server/app/handlers/api/story/active.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/core/server/app/handlers/api/story/active.ts b/server/src/core/server/app/handlers/api/story/active.ts index 765101c6ed..f6575d3b17 100644 --- a/server/src/core/server/app/handlers/api/story/active.ts +++ b/server/src/core/server/app/handlers/api/story/active.ts @@ -14,7 +14,7 @@ export type Options = Pick; const ActiveStoriesQuerySchema = Joi.object().keys({ callback: Joi.string().allow("").optional(), siteID: Joi.string().required(), - count: Joi.number().optional(), + count: Joi.number().optional().max(999), }); interface ActiveStoriesQuery {