Remove direct Discord post synchronization from server

Removes the HTTP-based Discord post synchronization logic from the server, as the Discord bot now handles this directly via polling Supabase.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: eb03098a-a2c8-4077-bc43-43ade85b9f51
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/duiWnI1
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
sirpiglr 2025-12-03 18:56:42 +00:00
commit 462c1294cb
3 changed files with 2 additions and 53 deletions

View file

@ -60,10 +60,6 @@ externalPort = 3000
localPort = 40437
externalPort = 3001
[[ports]]
localPort = 41051
externalPort = 3002
[deployment]
deploymentTarget = "autoscale"
run = ["node", "dist/server/production.mjs"]

View file

@ -400,29 +400,23 @@ export const communityService = {
"id" | "created_at" | "updated_at" | "likes_count" | "comments_count"
>,
): Promise<CommunityPost> {
console.log("[createPost] Starting - calling API at", `${API_BASE}/api/posts`);
try {
const resp = await fetch(`${API_BASE}/api/posts`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(post),
});
console.log("[createPost] API response status:", resp.status);
if (resp.ok) {
const result = await resp.json();
console.log("[createPost] API success - post created via API (Discord sync enabled)");
return result as CommunityPost;
return (await resp.json()) as CommunityPost;
}
if (resp.status >= 400) {
const payload = await resp.json().catch(() => ({}));
console.error("[createPost] API error:", payload);
throw new Error(payload?.error || `API responded with ${resp.status}`);
}
} catch (error) {
console.warn("[createPost] API failed, falling back to direct Supabase (NO Discord sync):", error);
console.warn("Falling back to Supabase insert for post:", error);
}
console.log("[createPost] Using direct Supabase insert (Discord sync SKIPPED)");
const { data, error } = await supabase
.from("community_posts")
.insert(post)

View file

@ -2523,47 +2523,6 @@ export function createServer() {
.json({ error: error.message || "Failed to create post" });
}
// Send post to Discord feed channel (fire and forget)
try {
const contentParsed = JSON.parse(String(payload.content).trim());
// Only sync to Discord if this is NOT a Discord-sourced post
if (contentParsed.source !== "discord") {
// Get author info for the Discord embed
const { data: authorProfile } = await adminSupabase
.from("user_profiles")
.select("username, full_name, avatar_url")
.eq("id", payload.author_id)
.single();
const discordBotPort = process.env.DISCORD_BOT_PORT || "8044";
const discordBridgeToken = process.env.DISCORD_BRIDGE_TOKEN || "aethex-bridge";
fetch(`http://localhost:${discordBotPort}/send-to-discord`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${discordBridgeToken}`,
},
body: JSON.stringify({
...data,
author: authorProfile,
}),
}).then(async (resp) => {
if (resp.ok) {
console.log("[Feed Bridge] ✅ Post sent to Discord");
} else {
const errText = await resp.text();
console.log("[Feed Bridge] Discord sync response:", resp.status, errText);
}
}).catch((err) => {
console.log("[Feed Bridge] Could not sync to Discord:", err.message);
});
}
} catch (syncErr: any) {
// Non-blocking - just log it
console.log("[Feed Bridge] Sync error:", syncErr?.message);
}
res.json(data);
} catch (e: any) {
console.error("[API] /api/posts exception:", e?.message || String(e));