feat(frontend): remote actor lookup and follow from search page
This commit is contained in:
@@ -15,6 +15,14 @@ export const UserSchema = z.object({
|
||||
|
||||
export const MeSchema = UserSchema;
|
||||
|
||||
export const RemoteActorSchema = z.object({
|
||||
handle: z.string(),
|
||||
displayName: z.string().nullable(),
|
||||
avatarUrl: z.string().nullable(),
|
||||
url: z.string(),
|
||||
});
|
||||
export type RemoteActor = z.infer<typeof RemoteActorSchema>;
|
||||
|
||||
export const ThoughtSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
content: z.string(),
|
||||
@@ -208,6 +216,22 @@ export const followUser = (username: string, token: string) =>
|
||||
export const unfollowUser = (username: string, token: string) =>
|
||||
apiFetch(`/users/${username}/follow`, { method: "DELETE" }, z.null(), token);
|
||||
|
||||
export const lookupRemoteActor = (handle: string, token: string | null) =>
|
||||
apiFetch(
|
||||
`/federation/lookup?handle=${encodeURIComponent(handle)}`,
|
||||
{},
|
||||
RemoteActorSchema,
|
||||
token
|
||||
);
|
||||
|
||||
export const followRemoteUser = (handle: string, token: string) =>
|
||||
apiFetch(
|
||||
`/federation/follow`,
|
||||
{ method: "POST", body: JSON.stringify({ handle }) },
|
||||
z.null(),
|
||||
token
|
||||
);
|
||||
|
||||
export const getAllUsers = (page: number = 1, pageSize: number = 20) =>
|
||||
apiFetch(
|
||||
`/users?page=${page}&per_page=${pageSize}`,
|
||||
|
||||
Reference in New Issue
Block a user