Add missing integrations.info endpoint (#6474)
This commit is contained in:
@@ -7,7 +7,7 @@ import validate from "@server/middlewares/validate";
|
|||||||
import { Event, IntegrationAuthentication } from "@server/models";
|
import { Event, IntegrationAuthentication } from "@server/models";
|
||||||
import Integration from "@server/models/Integration";
|
import Integration from "@server/models/Integration";
|
||||||
import { authorize } from "@server/policies";
|
import { authorize } from "@server/policies";
|
||||||
import { presentIntegration } from "@server/presenters";
|
import { presentIntegration, presentPolicies } from "@server/presenters";
|
||||||
import { APIContext } from "@server/types";
|
import { APIContext } from "@server/types";
|
||||||
import pagination from "../middlewares/pagination";
|
import pagination from "../middlewares/pagination";
|
||||||
import * as T from "./schema";
|
import * as T from "./schema";
|
||||||
@@ -72,6 +72,26 @@ router.post(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"integrations.info",
|
||||||
|
auth(),
|
||||||
|
validate(T.IntegrationsInfoSchema),
|
||||||
|
async (ctx: APIContext<T.IntegrationsInfoReq>) => {
|
||||||
|
const { id } = ctx.input.body;
|
||||||
|
const { user } = ctx.state.auth;
|
||||||
|
|
||||||
|
const integration = await Integration.findByPk(id, {
|
||||||
|
rejectOnEmpty: true,
|
||||||
|
});
|
||||||
|
authorize(user, "read", integration);
|
||||||
|
|
||||||
|
ctx.body = {
|
||||||
|
data: presentIntegration(integration),
|
||||||
|
policies: presentPolicies(user, [integration]),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"integrations.update",
|
"integrations.update",
|
||||||
auth({ admin: true }),
|
auth({ admin: true }),
|
||||||
|
|||||||
@@ -81,6 +81,15 @@ export const IntegrationsUpdateSchema = BaseSchema.extend({
|
|||||||
|
|
||||||
export type IntegrationsUpdateReq = z.infer<typeof IntegrationsUpdateSchema>;
|
export type IntegrationsUpdateReq = z.infer<typeof IntegrationsUpdateSchema>;
|
||||||
|
|
||||||
|
export const IntegrationsInfoSchema = BaseSchema.extend({
|
||||||
|
body: z.object({
|
||||||
|
/** Id of integration to find */
|
||||||
|
id: z.string().uuid(),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type IntegrationsInfoReq = z.infer<typeof IntegrationsInfoSchema>;
|
||||||
|
|
||||||
export const IntegrationsDeleteSchema = BaseSchema.extend({
|
export const IntegrationsDeleteSchema = BaseSchema.extend({
|
||||||
body: z.object({
|
body: z.object({
|
||||||
/** Id of integration to be deleted */
|
/** Id of integration to be deleted */
|
||||||
|
|||||||
Reference in New Issue
Block a user