Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.1 KB
Raw Blame
import { FollowUpExtractInputSchema } from '@lobechat/types';

import { withScopedPermission } from '@/business/server/trpc-middlewares/rbacPermission';
import { wsCompatProcedure } from '@/business/server/trpc-middlewares/workspaceAuth';
import { router } from '@/libs/trpc/lambda';
import { serverDatabase } from '@/libs/trpc/lambda/middleware';
import { FollowUpActionService } from '@/server/services/followUpAction';

const followUpProcedure = wsCompatProcedure.use(serverDatabase).use(async (opts) => {
  const { ctx } = opts;
  return opts.next({
    ctx: {
      followUpService: new FollowUpActionService({
        db: ctx.serverDB,
        userAgent: ctx.userAgent,
        userId: ctx.userId,
        workspaceId: ctx.workspaceId ?? undefined,
      }),
    },
  });
});
const followUpWriteProcedure = followUpProcedure.use(withScopedPermission('message:create'));

export const followUpActionRouter = router({
  extract: followUpWriteProcedure
    .input(FollowUpExtractInputSchema)
    .mutation(async ({ input, ctx }) => ctx.followUpService.extract(input)),
});