MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / getChatInfo

Function getChatInfo

packages/web/src/features/chat/actions.ts:65–94  ·  view source on GitHub ↗
({ chatId }: { chatId: string })

Source from the content-addressed store, hash-verified

63);
64
65export const getChatInfo = async ({ chatId }: { chatId: string }) => sew(() =>
66 withOptionalAuth(async ({ org, user, prisma }) => {
67 const chat = await prisma.chat.findUnique({
68 where: {
69 id: chatId,
70 orgId: org.id,
71 },
72 });
73
74 if (!chat) {
75 return notFound();
76 }
77
78 const isOwner = await isOwnerOfChat(chat, user);
79 const isSharedWithUser = await isChatSharedWithUser({ prisma, chatId, userId: user?.id });
80
81 // Private chats can only be viewed by the owner or users it's been shared with
82 if (chat.visibility === ChatVisibility.PRIVATE && !isOwner && !isSharedWithUser) {
83 return notFound();
84 }
85
86 return {
87 messages: chat.messages as unknown as SBChatMessage[],
88 visibility: chat.visibility,
89 name: chat.name,
90 isOwner,
91 isSharedWithUser,
92 };
93 })
94);
95
96export const updateChatName = async ({ chatId, name }: { chatId: string, name: string }) => sew(() =>
97 withOptionalAuth(async ({ org, user, prisma }) => {

Callers 1

PageFunction · 0.90

Calls 5

sewFunction · 0.90
withOptionalAuthFunction · 0.90
notFoundFunction · 0.90
isOwnerOfChatFunction · 0.90
isChatSharedWithUserFunction · 0.90

Tested by

no test coverage detected