From 0476dc5fae2e95f4ee8c0b02fc1cd7df60bd1151 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Thu, 13 Nov 2025 08:54:37 +0000 Subject: [PATCH] completionId: cgen-2f8c4bf780ef468696b51822ba5f99cf cgen-2f8c4bf780ef468696b51822ba5f99cf --- api/community/posts.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/api/community/posts.ts b/api/community/posts.ts index 7c061445..c46ff815 100644 --- a/api/community/posts.ts +++ b/api/community/posts.ts @@ -112,6 +112,33 @@ export default async function handler(req: any, res: any) { const createdPost = data?.[0]; + // Sync post to Discord feed webhook + try { + const apiBase = process.env.API_BASE || "/api"; + await fetch(`${apiBase}/discord/feed-sync`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + id: createdPost?.id, + title: createdPost?.title, + content: createdPost?.content, + author_name: + createdPost?.user_profiles?.full_name || + createdPost?.user_profiles?.username || + "Community member", + author_avatar: createdPost?.user_profiles?.avatar_url, + arm_affiliation: createdPost?.arm_affiliation, + likes_count: createdPost?.likes_count, + comments_count: createdPost?.comments_count, + created_at: createdPost?.created_at, + }), + }).catch((err) => + console.error("[Posts API] Discord sync error:", err), + ); + } catch (error) { + console.error("[Posts API] Failed to sync to Discord:", error); + } + // Publish activity event for post creation try { const apiBase = process.env.API_BASE || "/api";