From 3ce65bfd7b784f27f9147293ae5d1929ad2d311d Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 18 Oct 2025 03:00:09 +0000 Subject: [PATCH] Switch follow/unfollow/endorse to server APIs so notifications fire cgen-295023c025ae4bbd9f2937b51bd579cb --- client/lib/aethex-social-service.ts | 39 +++++++++++++---------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/client/lib/aethex-social-service.ts b/client/lib/aethex-social-service.ts index 5a7b60b6..9201e197 100644 --- a/client/lib/aethex-social-service.ts +++ b/client/lib/aethex-social-service.ts @@ -53,26 +53,21 @@ export const aethexSocialService = { }, async followUser(followerId: string, followingId: string): Promise { - const { error } = await supabase.from("user_follows").insert({ - follower_id: followerId, - following_id: followingId, + const resp = await fetch("/api/social/follow", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ follower_id: followerId, following_id: followingId }), }); - - if (error) { - throw new Error(error.message || "Unable to follow user"); - } + if (!resp.ok) throw new Error(await resp.text()); }, async unfollowUser(followerId: string, followingId: string): Promise { - const { error } = await supabase - .from("user_follows") - .delete() - .eq("follower_id", followerId) - .eq("following_id", followingId); - - if (error) { - throw new Error(error.message || "Unable to unfollow user"); - } + const resp = await fetch("/api/social/unfollow", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ follower_id: followerId, following_id: followingId }), + }); + if (!resp.ok) throw new Error(await resp.text()); }, async sendInvite(inviterId: string, email: string, message?: string | null) { @@ -150,11 +145,11 @@ export const aethexSocialService = { }, async endorseSkill(endorserId: string, endorsedId: string, skill: string) { - const payload = { endorser_id: endorserId, endorsed_id: endorsedId, skill }; - const { error } = await supabase - .from("endorsements") - .insert(payload as any); - if (error) throw new Error(error.message || "Unable to endorse"); - await this.applyReward(endorsedId, "endorsement_received", 2); + const resp = await fetch("/api/social/endorse", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ endorser_id: endorserId, endorsed_id: endorsedId, skill }), + }); + if (!resp.ok) throw new Error(await resp.text()); }, };