* feat: add integration access check to middlewares * fix: format issues * fix: remove group and user permissions and items from context * refactor: move action check to seperate function
19 lines
779 B
TypeScript
19 lines
779 B
TypeScript
import type { CalendarEvent } from "@homarr/integrations/types";
|
|
import { createItemAndIntegrationChannel } from "@homarr/redis";
|
|
|
|
import { createManyIntegrationOfOneItemMiddleware } from "../../middlewares/integration";
|
|
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|
|
|
export const calendarRouter = createTRPCRouter({
|
|
findAllEvents: publicProcedure
|
|
.unstable_concat(createManyIntegrationOfOneItemMiddleware("query", "sonarr", "radarr", "readarr", "lidarr"))
|
|
.query(async ({ ctx }) => {
|
|
return await Promise.all(
|
|
ctx.integrations.flatMap(async (integration) => {
|
|
const cache = createItemAndIntegrationChannel<CalendarEvent[]>("calendar", integration.id);
|
|
return await cache.getAsync();
|
|
}),
|
|
);
|
|
}),
|
|
});
|