import define from "../../define.js";
import { VerifiedBadgeRequests } from "../../../../models/index.js";
import { makePaginationQuery } from "../../common/make-pagination-query.js";
export const meta = {
    tags: [
        "admin"
    ],
    requireCredential: true,
    requireAdmin: true
};
export const paramDef = {
    type: "object",
    properties: {
        limit: {
            type: "integer",
            minimum: 1,
            maximum: 100,
            default: 10
        },
        sinceId: {
            type: "string",
            format: "misskey:id"
        },
        untilId: {
            type: "string",
            format: "misskey:id"
        },
        state: {
            type: "string",
            enum: [
                "all",
                "pending",
                "approved",
                "rejected"
            ],
            default: "pending"
        }
    },
    required: []
};
export default define(meta, paramDef, async (ps)=>{
    const query = makePaginationQuery(VerifiedBadgeRequests.createQueryBuilder("request"), ps.sinceId, ps.untilId);
    if (ps.state !== "all") {
        query.andWhere("request.status = :status", {
            status: ps.state
        });
    }
    const requests = await query.take(ps.limit).getMany();
    return await VerifiedBadgeRequests.packMany(requests);
});
