Files
thoughts/thoughts-frontend/app/actions/social.ts
Gabriel Kaszewski 9aee4ceb6d
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
feat: v2 rewrite — hexagonal arch, ActivityPub federation, NATS, deployment-ready (#1)
2026-05-16 09:42:40 +00:00

29 lines
764 B
TypeScript

"use server";
import { revalidateTag } from "next/cache";
import { cookies } from "next/headers";
import {
followUser as apiFollowUser,
unfollowUser as apiUnfollowUser,
} from "@/lib/api";
async function getToken(): Promise<string> {
const token = (await cookies()).get("auth_token")?.value;
if (!token) throw new Error("Not authenticated");
return token;
}
export async function followUser(username: string) {
const token = await getToken();
await apiFollowUser(username, token);
revalidateTag(`profile:${username}`);
revalidateTag("feed");
}
export async function unfollowUser(username: string) {
const token = await getToken();
await apiUnfollowUser(username, token);
revalidateTag(`profile:${username}`);
revalidateTag("feed");
}