Skip to content

Commit 848c2ae

Browse files
author
waleed
committed
remove dedicated chat bucket, use execution bucket
1 parent 6b9eacf commit 848c2ae

File tree

7 files changed

+13
-62
lines changed

7 files changed

+13
-62
lines changed

apps/sim/app/api/files/authorization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface AuthorizationResult {
1919
* Single source of truth for all file access control.
2020
*
2121
* Authorization rules:
22-
* - execution/workspace/knowledge-base/chat/copilot: Workspace membership required
22+
* - execution/workspace/knowledge-base/copilot: Workspace membership required
2323
* - profile-pictures: User ownership required
2424
* - Legacy files: Check both new and old database tables
2525
*/

apps/sim/app/api/files/presigned/batch/route.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@ export async function POST(request: NextRequest) {
5656
const uploadType: StorageContext =
5757
uploadTypeParam === 'knowledge-base'
5858
? 'knowledge-base'
59-
: uploadTypeParam === 'chat'
60-
? 'chat'
61-
: uploadTypeParam === 'copilot'
62-
? 'copilot'
63-
: uploadTypeParam === 'profile-pictures'
64-
? 'profile-pictures'
65-
: 'general'
59+
: uploadTypeParam === 'copilot'
60+
? 'copilot'
61+
: uploadTypeParam === 'profile-pictures'
62+
? 'profile-pictures'
63+
: 'general'
6664

6765
const MAX_FILE_SIZE = 100 * 1024 * 1024
6866
for (const file of files) {

apps/sim/app/api/files/presigned/route.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ export async function POST(request: NextRequest) {
7272
const uploadType: StorageContext =
7373
uploadTypeParam === 'knowledge-base'
7474
? 'knowledge-base'
75-
: uploadTypeParam === 'chat'
76-
? 'chat'
77-
: uploadTypeParam === 'copilot'
78-
? 'copilot'
79-
: uploadTypeParam === 'profile-pictures'
80-
? 'profile-pictures'
81-
: 'general'
75+
: uploadTypeParam === 'copilot'
76+
? 'copilot'
77+
: uploadTypeParam === 'profile-pictures'
78+
? 'profile-pictures'
79+
: 'general'
8280

8381
if (uploadType === 'knowledge-base') {
8482
const fileValidationError = validateFileType(fileName, contentType)

apps/sim/app/api/files/upload/route.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -218,28 +218,14 @@ export async function POST(request: NextRequest) {
218218
}
219219
}
220220

221-
// Priority 4: Context-specific uploads (copilot, chat, profile-pictures)
222-
if (context === 'copilot' || context === 'chat' || context === 'profile-pictures') {
221+
// Priority 4: Context-specific uploads (copilot, profile-pictures)
222+
if (context === 'copilot' || context === 'profile-pictures') {
223223
if (!isImageFileType(file.type)) {
224224
throw new InvalidRequestError(
225225
`Only image files (JPEG, PNG, GIF, WebP, SVG) are allowed for ${context} uploads`
226226
)
227227
}
228228

229-
if (context === 'chat' && workspaceId) {
230-
const permission = await getUserEntityPermissions(
231-
session.user.id,
232-
'workspace',
233-
workspaceId
234-
)
235-
if (permission === null) {
236-
return NextResponse.json(
237-
{ error: 'Insufficient permissions for workspace' },
238-
{ status: 403 }
239-
)
240-
}
241-
}
242-
243229
logger.info(`Uploading ${context} file: ${originalName}`)
244230

245231
const metadata: Record<string, string> = {
@@ -249,10 +235,6 @@ export async function POST(request: NextRequest) {
249235
userId: session.user.id,
250236
}
251237

252-
if (workspaceId && context === 'chat') {
253-
metadata.workspaceId = workspaceId
254-
}
255-
256238
const fileInfo = await storageService.uploadFile({
257239
file: buffer,
258240
fileName: originalName,

apps/sim/lib/env.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export const env = createEnv({
121121
S3_LOGS_BUCKET_NAME: z.string().optional(), // S3 bucket for storing logs
122122
S3_KB_BUCKET_NAME: z.string().optional(), // S3 bucket for knowledge base files
123123
S3_EXECUTION_FILES_BUCKET_NAME: z.string().optional(), // S3 bucket for workflow execution files
124-
S3_CHAT_BUCKET_NAME: z.string().optional(), // S3 bucket for chat logos
125124
S3_COPILOT_BUCKET_NAME: z.string().optional(), // S3 bucket for copilot files
126125
S3_PROFILE_PICTURES_BUCKET_NAME: z.string().optional(), // S3 bucket for profile pictures
127126

@@ -132,7 +131,6 @@ export const env = createEnv({
132131
AZURE_STORAGE_CONTAINER_NAME: z.string().optional(), // Azure container for general files
133132
AZURE_STORAGE_KB_CONTAINER_NAME: z.string().optional(), // Azure container for knowledge base files
134133
AZURE_STORAGE_EXECUTION_FILES_CONTAINER_NAME: z.string().optional(), // Azure container for workflow execution files
135-
AZURE_STORAGE_CHAT_CONTAINER_NAME: z.string().optional(), // Azure container for chat logos
136134
AZURE_STORAGE_COPILOT_CONTAINER_NAME: z.string().optional(), // Azure container for copilot files
137135
AZURE_STORAGE_PROFILE_PICTURES_CONTAINER_NAME: z.string().optional(), // Azure container for profile pictures
138136

apps/sim/lib/uploads/config.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,6 @@ export const BLOB_EXECUTION_FILES_CONFIG = {
4949
containerName: env.AZURE_STORAGE_EXECUTION_FILES_CONTAINER_NAME || 'sim-execution-files',
5050
}
5151

52-
export const S3_CHAT_CONFIG = {
53-
bucket: env.S3_CHAT_BUCKET_NAME || '',
54-
region: env.AWS_REGION || '',
55-
}
56-
57-
export const BLOB_CHAT_CONFIG = {
58-
accountName: env.AZURE_ACCOUNT_NAME || '',
59-
accountKey: env.AZURE_ACCOUNT_KEY || '',
60-
connectionString: env.AZURE_CONNECTION_STRING || '',
61-
containerName: env.AZURE_STORAGE_CHAT_CONTAINER_NAME || '',
62-
}
63-
6452
export const S3_COPILOT_CONFIG = {
6553
bucket: env.S3_COPILOT_BUCKET_NAME || '',
6654
region: env.AWS_REGION || '',
@@ -126,11 +114,6 @@ function getS3Config(context: StorageContext): StorageConfig {
126114
bucket: S3_KB_CONFIG.bucket,
127115
region: S3_KB_CONFIG.region,
128116
}
129-
case 'chat':
130-
return {
131-
bucket: S3_CHAT_CONFIG.bucket,
132-
region: S3_CHAT_CONFIG.region,
133-
}
134117
case 'copilot':
135118
return {
136119
bucket: S3_COPILOT_CONFIG.bucket,
@@ -171,13 +154,6 @@ function getBlobConfig(context: StorageContext): StorageConfig {
171154
connectionString: BLOB_KB_CONFIG.connectionString,
172155
containerName: BLOB_KB_CONFIG.containerName,
173156
}
174-
case 'chat':
175-
return {
176-
accountName: BLOB_CHAT_CONFIG.accountName,
177-
accountKey: BLOB_CHAT_CONFIG.accountKey,
178-
connectionString: BLOB_CHAT_CONFIG.connectionString,
179-
containerName: BLOB_CHAT_CONFIG.containerName,
180-
}
181157
case 'copilot':
182158
return {
183159
accountName: BLOB_COPILOT_CONFIG.accountName,

apps/sim/lib/uploads/shared/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export type StorageContext =
22
| 'general'
33
| 'knowledge-base'
4-
| 'chat'
54
| 'copilot'
65
| 'execution'
76
| 'workspace'

0 commit comments

Comments
 (0)