Simplify function input

This commit is contained in:
Jackson Harper 2024-01-20 13:32:11 +08:00
parent 1898e32607
commit 89537c13de
2 changed files with 18 additions and 3 deletions

View file

@ -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),

View file

@ -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<Subscription> => {
ensureOwns(userId, subscriptionId)