From 89537c13deda7fc97f1b3d615c5cf4580a372f8f Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Sat, 20 Jan 2024 13:32:11 +0800 Subject: [PATCH] Simplify function input --- packages/api/src/jobs/rss/refreshFeed.ts | 1 - .../api/src/services/update_subscription.ts | 20 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/api/src/jobs/rss/refreshFeed.ts b/packages/api/src/jobs/rss/refreshFeed.ts index dba8ed535..ccefcd0d5 100644 --- a/packages/api/src/jobs/rss/refreshFeed.ts +++ b/packages/api/src/jobs/rss/refreshFeed.ts @@ -617,7 +617,6 @@ const processSubscription = async ( // update subscription lastFetchedAt const updatedSubscription = await updateSubscription(userId, subscriptionId, { - id: subscriptionId, lastFetchedAt: lastItemFetchedAt, lastFetchedChecksum: updatedLastFetchedChecksum, scheduledAt: new Date(nextScheduledAt), diff --git a/packages/api/src/services/update_subscription.ts b/packages/api/src/services/update_subscription.ts index 33f9cdfb0..70da2cfe0 100644 --- a/packages/api/src/services/update_subscription.ts +++ b/packages/api/src/services/update_subscription.ts @@ -1,5 +1,8 @@ import { Subscription } from '../entity/subscription' -import { UpdateSubscriptionInput } from '../generated/graphql' +import { + SubscriptionStatus, + UpdateSubscriptionInput, +} from '../generated/graphql' import { getRepository } from '../repository' const ensureOwns = async (userId: string, subscriptionId: string) => { @@ -14,10 +17,23 @@ const ensureOwns = async (userId: string, subscriptionId: string) => { } } +type UpdateSubscriptionData = { + autoAddToLibrary?: boolean | null + description?: string | null + fetchContent?: boolean | null + folder?: string | null + isPrivate?: boolean | null + lastFetchedAt?: Date | null + lastFetchedChecksum?: string | null + name?: string | null + scheduledAt?: Date | null + status?: SubscriptionStatus | null +} + export const updateSubscription = async ( userId: string, subscriptionId: string, - newData: UpdateSubscriptionInput + newData: UpdateSubscriptionData ): Promise => { ensureOwns(userId, subscriptionId)