From e730abb9aafa77f72f1feff8777ebe3026f6944a Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 12 Dec 2023 15:17:00 +0800 Subject: [PATCH] fix subscribe api returns error due to createdAt being null --- packages/api/src/resolvers/subscriptions/index.ts | 13 +++++++++---- packages/api/test/resolvers/subscriptions.test.ts | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/api/src/resolvers/subscriptions/index.ts b/packages/api/src/resolvers/subscriptions/index.ts index cf19a25d1..f29282c09 100644 --- a/packages/api/src/resolvers/subscriptions/index.ts +++ b/packages/api/src/resolvers/subscriptions/index.ts @@ -40,7 +40,11 @@ import { unsubscribe } from '../../services/subscriptions' import { Merge } from '../../util' import { analytics } from '../../utils/analytics' import { enqueueRssFeedFetch } from '../../utils/createTask' -import { authorized, getAbsoluteUrl } from '../../utils/helpers' +import { + authorized, + getAbsoluteUrl, + keysToCamelCase, +} from '../../utils/helpers' import { parseFeed, parseOpml, RSS_PARSER_CONFIG } from '../../utils/parser' type PartialSubscription = Omit @@ -249,7 +253,7 @@ export const subscribeResolver = authorized< input.isPrivate ?? null, MAX_RSS_SUBSCRIPTIONS, ] - )) as Subscription[] + )) as any[] if (results.length === 0) { return { @@ -257,7 +261,8 @@ export const subscribeResolver = authorized< } } - const newSubscription = results[0] + // convert to camel case + const newSubscription = keysToCamelCase(results[0]) as Subscription // create a cloud task to fetch rss feed item for the new subscription await enqueueRssFeedFetch({ @@ -439,7 +444,7 @@ export const scanFeedsResolver = authorized< const response = await axios.get(url, RSS_PARSER_CONFIG) const content = response.data as string // check if the content is html or xml - const contentType = response.headers['content-type'] + const contentType = response.headers['content-type'] as string const isHtml = contentType?.includes('text/html') if (isHtml) { // this is an html page, parse rss feed links diff --git a/packages/api/test/resolvers/subscriptions.test.ts b/packages/api/test/resolvers/subscriptions.test.ts index cfdf6b10e..0e9827a41 100644 --- a/packages/api/test/resolvers/subscriptions.test.ts +++ b/packages/api/test/resolvers/subscriptions.test.ts @@ -289,6 +289,7 @@ describe('Subscriptions API', () => { ... on UnsubscribeSuccess { subscription { id + createdAt } } ... on UnsubscribeError {