diff --git a/thoughts-frontend/lib/api.ts b/thoughts-frontend/lib/api.ts index c211dfd..d9cfece 100644 --- a/thoughts-frontend/lib/api.ts +++ b/thoughts-frontend/lib/api.ts @@ -402,3 +402,53 @@ export const deleteApiKey = (keyId: string, token: string) => export const getFriends = (token: string) => getMeFollowingList(token).then((r) => ({ users: r.items })); + +// ── Federation management ───────────────────────────────────────────────── + +export const getPendingFollowRequests = (token: string) => + apiFetch( + "/federation/me/followers/pending", + {}, + z.array(RemoteActorSchema), + token + ); + +export const acceptFollowRequest = (actorUrl: string, token: string) => + apiFetch( + "/federation/me/followers/accept", + { method: "POST", body: JSON.stringify({ actor_url: actorUrl }) }, + z.null(), + token + ); + +export const rejectFollowRequest = (actorUrl: string, token: string) => + apiFetch( + "/federation/me/followers", + { method: "DELETE", body: JSON.stringify({ actor_url: actorUrl }) }, + z.null(), + token + ); + +export const getRemoteFollowers = (token: string) => + apiFetch( + "/federation/me/followers", + {}, + z.array(RemoteActorSchema), + token + ); + +export const getRemoteFollowing = (token: string) => + apiFetch( + "/federation/me/following", + {}, + z.array(RemoteActorSchema), + token + ); + +export const unfollowRemoteActor = (handle: string, token: string) => + apiFetch( + "/federation/me/following", + { method: "DELETE", body: JSON.stringify({ handle }) }, + z.null(), + token + );