| 159 | * verification before a mutation (rename, delete, update-messages). |
| 160 | */ |
| 161 | export async function getAccessibleCopilotChatAuth( |
| 162 | chatId: string, |
| 163 | userId: string |
| 164 | ): Promise<CopilotChatAuthRow | null> { |
| 165 | const [chat] = await db |
| 166 | .select(copilotChatAuthColumns) |
| 167 | .from(copilotChats) |
| 168 | .where(and(eq(copilotChats.id, chatId), eq(copilotChats.userId, userId))) |
| 169 | .limit(1) |
| 170 | |
| 171 | return authorizeCopilotChatRow(chat, chatId, userId) |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Load a copilot chat row for the legacy chat detail endpoint, including the |