( organizationId: Organisation.OrganisationId, )
| 341 | }; |
| 342 | |
| 343 | export async function getOrganizationStorageSettings( |
| 344 | organizationId: Organisation.OrganisationId, |
| 345 | ): Promise<OrganizationStorageSettings> { |
| 346 | const { organization } = |
| 347 | await requireOrganizationStorageManager(organizationId); |
| 348 | const [bucket, drive, activeDrive] = await Promise.all([ |
| 349 | getOrganizationBucket(organizationId), |
| 350 | getOrganizationDrive(organizationId), |
| 351 | getActiveOrganizationDrive(organizationId), |
| 352 | ]); |
| 353 | const driveConfig = drive ? await parseDriveConfig(drive) : null; |
| 354 | const activeProvider = activeDrive ? "googleDrive" : bucket ? "s3" : null; |
| 355 | |
| 356 | return { |
| 357 | organization: { |
| 358 | id: organization.id, |
| 359 | name: organization.name, |
| 360 | }, |
| 361 | activeProvider, |
| 362 | googleOAuthClientId: process.env.GOOGLE_CLIENT_ID ?? null, |
| 363 | googlePickerApiKey: process.env.NEXT_PUBLIC_GOOGLE_PICKER_API_KEY ?? null, |
| 364 | s3: bucket ? await decryptS3Config(bucket, false) : null, |
| 365 | googleDrive: |
| 366 | drive && driveConfig |
| 367 | ? { |
| 368 | id: drive.id, |
| 369 | connected: drive.status === "active", |
| 370 | active: drive.active, |
| 371 | status: drive.status, |
| 372 | displayName: drive.displayName, |
| 373 | email: driveConfig.email ?? null, |
| 374 | folderId: driveConfig.folderId || null, |
| 375 | folderName: driveConfig.folderName ?? null, |
| 376 | driveId: driveConfig.driveId ?? null, |
| 377 | driveName: driveConfig.driveName ?? null, |
| 378 | } |
| 379 | : null, |
| 380 | }; |
| 381 | } |
| 382 | |
| 383 | export async function saveOrganizationS3Config(input: S3ConfigInput) { |
| 384 | const { user } = await requireOrganizationStorageManagerPro( |
no test coverage detected