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

Function updateChatName

packages/web/src/features/chat/actions.ts:96–130  ·  view source on GitHub ↗
({ chatId, name }: { chatId: string, name: string })

Source from the content-addressed store, hash-verified

94);
95
96export const updateChatName = async ({ chatId, name }: { chatId: string, name: string }) => sew(() =>
97 withOptionalAuth(async ({ org, user, prisma }) => {
98 const chat = await prisma.chat.findUnique({
99 where: {
100 id: chatId,
101 orgId: org.id,
102 },
103 });
104
105 if (!chat) {
106 return notFound();
107 }
108
109 const isOwner = await isOwnerOfChat(chat, user);
110
111 // Only the owner can rename chats
112 if (!isOwner) {
113 return notFound();
114 }
115
116 await prisma.chat.update({
117 where: {
118 id: chatId,
119 orgId: org.id,
120 },
121 data: {
122 name,
123 },
124 });
125
126 return {
127 success: true,
128 }
129 })
130);
131
132export const updateChatVisibility = async ({ chatId, visibility }: { chatId: string, visibility: ChatVisibility }) => sew(() =>
133 withAuth(async ({ org, user, prisma }) => {

Callers 3

ChatHistoryFunction · 0.90
ChatNameFunction · 0.90
ChatRowActionsFunction · 0.90

Calls 4

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

Tested by

no test coverage detected