From 2edabf44c74f78ee03beafd555453783e44942a5 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Fri, 23 Aug 2019 18:01:43 +0000 Subject: [PATCH] feat: added closedAt to createStory mutation (#2496) --- src/core/server/graph/tenant/schema/schema.graphql | 7 +++++++ src/core/server/models/story/index.ts | 4 +++- src/core/server/services/stories/index.ts | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/core/server/graph/tenant/schema/schema.graphql b/src/core/server/graph/tenant/schema/schema.graphql index 14e7b1fd2..86255fdf5 100644 --- a/src/core/server/graph/tenant/schema/schema.graphql +++ b/src/core/server/graph/tenant/schema/schema.graphql @@ -3479,6 +3479,13 @@ input CreateStory { be scraped, but can be provided here. """ metadata: StoryMetadataInput + + """ + closedAt when provided specifies the date that the given story will be closed + at. If not provided, the story close will use the settings to determine the + automatic close date. + """ + closedAt: Time } input CreateStoryInput { diff --git a/src/core/server/models/story/index.ts b/src/core/server/models/story/index.ts index 288399f3b..436344759 100644 --- a/src/core/server/models/story/index.ts +++ b/src/core/server/models/story/index.ts @@ -222,7 +222,9 @@ export async function findOrCreateStory( return upsertStory(mongo, tenantID, { url }, now); } -export type CreateStoryInput = Partial>; +export type CreateStoryInput = Partial< + Pick +>; export async function createStory( mongo: Db, diff --git a/src/core/server/services/stories/index.ts b/src/core/server/services/stories/index.ts index 78623ae19..b8ce0f051 100644 --- a/src/core/server/services/stories/index.ts +++ b/src/core/server/services/stories/index.ts @@ -163,7 +163,7 @@ export async function create( tenant: Tenant, storyID: string, storyURL: string, - { metadata }: CreateStory, + { metadata, closedAt }: CreateStory, now = new Date() ) { // Ensure that the given URL is allowed. @@ -175,7 +175,7 @@ export async function create( } // Construct the input payload. - const input: CreateStoryInput = { metadata }; + const input: CreateStoryInput = { metadata, closedAt }; if (metadata) { input.scrapedAt = now; }