diff --git a/src/scripts/fetchDiscord.ts b/src/scripts/fetchDiscord.ts index 000644b5..0f9cd2a0 100644 --- a/src/scripts/fetchDiscord.ts +++ b/src/scripts/fetchDiscord.ts @@ -140,6 +140,9 @@ function processMessages(messages: Message[]) { function createSanitizedThread(thread: Thread, messages: Message[]) { const [intro, ...combinedResponses] = processMessages(messages) + const createdAtDate = intro + ? new Date(intro.timestamp).toISOString() + : new Date(thread.thread_metadata.create_timestamp).toISOString() return { slug: sanitizeSlug(thread.name), @@ -147,7 +150,7 @@ function createSanitizedThread(thread: Thread, messages: Message[]) { id: thread.id, name: thread.name, archived: thread.thread_metadata.archived, - createdAt: thread.thread_metadata.create_timestamp, + createdAt: createdAtDate, guildId: thread.guild_id, }, intro: intro diff --git a/src/scripts/syncToAlgolia.ts b/src/scripts/syncToAlgolia.ts index e582fcec..7e8178db 100644 --- a/src/scripts/syncToAlgolia.ts +++ b/src/scripts/syncToAlgolia.ts @@ -55,15 +55,17 @@ export const syncToAlgolia = async (): Promise => { const githubDocs: GithubDoc[] = [] docs.forEach((doc) => { - const { communityHelpJSON, discordID, githubID, helpful } = doc + const { communityHelpJSON, discordID, githubID, helpful, threadCreatedAt } = doc if (discordID) { const { slug, info, intro, messageCount, messages } = communityHelpJSON + const formattedDate = threadCreatedAt || info.createdAt + discordDocs.push({ name: info.name, slug, author: intro.authorName, - createdAt: info.createdAt, + createdAt: formattedDate, helpful: helpful ?? false, messageCount, messages: messages.map((message) => {