import define from "../../../define.js";
import { listRelay } from "@/services/relay.js";

export const meta = {
	tags: ["admin"],

	requireCredential: true,
	requireModerator: true,

	res: {
		type: "array",
		optional: false,
		nullable: false,
		items: {
			type: "object",
			optional: false,
			nullable: false,
			properties: {
				id: {
					type: "string",
					optional: false,
					nullable: false,
					format: "id",
				},
				inbox: {
					type: "string",
					optional: false,
					nullable: false,
					format: "url",
				},
				status: {
					type: "string",
					optional: false,
					nullable: false,
					default: "requesting",
					enum: ["requesting", "accepted", "rejected"],
				},
			},
		},
	},
} as const;

export const paramDef = {
	type: "object",
	properties: {},
	required: [],
} as const;

export default define(meta, paramDef, async (ps, user) => {
	return await listRelay();
});
