Browse Source

remove orgId config variable

Futa Arai 10 months ago
parent
commit
86862ea2be

+ 3 - 4
apps/app/src/features/page-bulk-export/server/service/page-bulk-export-job-cron/index.ts

@@ -105,17 +105,16 @@ class PageBulkExportJobCronService extends CronService implements IPageBulkExpor
   getTmpOutputDir(pageBulkExportJob: PageBulkExportJobDocument, isHtmlPath = false): string {
     const isGrowiCloud = configManager.getConfig('app:growiCloudUri') != null;
     const appId = configManager.getConfig('app:growiAppIdForCloud')?.toString();
-    const orgId = configManager.getConfig('app:growiOrgIdForCloud')?.toString();
     const jobId = pageBulkExportJob._id.toString();
 
     if (isGrowiCloud) {
-      if (appId == null || orgId == null) {
-        throw new Error('appId and orgId is required for bulk export on GROWI.cloud');
+      if (appId == null) {
+        throw new Error('appId is required for bulk export on GROWI.cloud');
       }
     }
 
     const basePath = isHtmlPath ? path.join(this.tmpOutputRootDir, 'html') : this.tmpOutputRootDir;
-    return path.join(basePath, orgId ?? '', appId ?? '', jobId);
+    return path.join(basePath, appId ?? '', jobId);
   }
 
   /**

+ 2 - 4
apps/app/src/features/page-bulk-export/server/service/page-bulk-export-job-cron/request-pdf-converter.ts

@@ -20,9 +20,8 @@ export async function requestPdfConverter(pageBulkExportJob: PageBulkExportJobDo
 
   const isGrowiCloud = configManager.getConfig('app:growiCloudUri') != null;
   const appId = configManager.getConfig('app:growiAppIdForCloud');
-  const orgId = configManager.getConfig('app:growiOrgIdForCloud');
-  if (isGrowiCloud && (appId == null || orgId == null)) {
-    throw new Error('appId and orgId is required for bulk export on GROWI.cloud');
+  if (isGrowiCloud && (appId == null)) {
+    throw new Error('appId is required for bulk export on GROWI.cloud');
   }
 
   const exportJobExpirationSeconds = configManager.getConfig('app:bulkExportJobExpirationSeconds');
@@ -48,7 +47,6 @@ export async function requestPdfConverter(pageBulkExportJob: PageBulkExportJobDo
     }
 
     const res = await pdfCtrlSyncJobStatus({
-      orgId: orgId?.toString(),
       appId: appId?.toString(),
       jobId: pageBulkExportJob._id.toString(),
       expirationDate: bulkExportJobExpirationDate.toISOString(),

+ 0 - 5
apps/app/src/server/service/config-manager/config-definition.ts

@@ -58,7 +58,6 @@ export const CONFIG_KEYS = [
   'app:elasticsearchReindexOnBoot',
   'app:growiCloudUri',
   'app:growiAppIdForCloud',
-  'app:growiOrgIdForCloud',
   'app:ogpUri',
   'app:minPasswordLength',
   'app:auditLogEnabled',
@@ -471,10 +470,6 @@ export const CONFIG_DEFINITIONS = {
     envVarName: 'GROWI_APP_ID_FOR_GROWI_CLOUD',
     defaultValue: undefined,
   }),
-  'app:growiOrgIdForCloud': defineConfig<number | undefined>({
-    envVarName: 'GROWI_ORG_ID_FOR_GROWI_CLOUD',
-    defaultValue: undefined,
-  }),
   'app:ogpUri': defineConfig<string | undefined>({
     envVarName: 'OGP_URI',
     defaultValue: undefined,

+ 1 - 2
apps/pdf-converter/src/controllers/pdf.ts

@@ -31,12 +31,11 @@ class PdfCtrl {
     @Required() @BodyParams('jobId') jobId: string,
     @Required() @BodyParams('expirationDate') expirationDateStr: string,
     @Required() @BodyParams('status') @Enum(Object.values(JobStatusSharedWithGrowi)) growiJobStatus: JobStatusSharedWithGrowi,
-    @BodyParams('orgId') orgId?: string,
     @BodyParams('appId') appId?: string,
   ): Promise<{ status: JobStatus } | undefined> {
     const expirationDate = new Date(expirationDateStr);
     try {
-      await this.pdfConvertService.registerOrUpdateJob(jobId, expirationDate, growiJobStatus, orgId, appId);
+      await this.pdfConvertService.registerOrUpdateJob(jobId, expirationDate, growiJobStatus, appId);
       const status = this.pdfConvertService.getJobStatus(jobId); // get status before cleanup
       this.pdfConvertService.cleanUpJobList();
       return { status };

+ 5 - 9
apps/pdf-converter/src/service/pdf-convert.ts

@@ -62,14 +62,12 @@ class PdfConvertService implements OnInit {
    * @param jobId PageBulkExportJob ID
    * @param expirationDate expiration date of job
    * @param status status of job
-   * @param orgId organization ID for GROWI.cloud
    * @param appId application ID for GROWI.cloud
    */
   async registerOrUpdateJob(
       jobId: string,
       expirationDate: Date,
       status: JobStatusSharedWithGrowi,
-      orgId?: string,
       appId?: string,
   ): Promise<void> {
     const isJobNew = !(jobId in this.jobList);
@@ -91,7 +89,7 @@ class PdfConvertService implements OnInit {
     }
 
     if (isJobNew && status !== JobStatus.FAILED) {
-      this.readHtmlAndConvertToPdfUntilFinish(jobId, orgId, appId);
+      this.readHtmlAndConvertToPdfUntilFinish(jobId, appId);
     }
   }
 
@@ -143,10 +141,9 @@ class PdfConvertService implements OnInit {
    * Read html files from shared fs path, convert them to pdf, and save them to shared fs path.
    * Repeat this until all html files are converted to pdf or job fails.
    * @param jobId PageBulkExportJob ID
-   * @param orgId organization ID for GROWI.cloud
    * @param appId application ID for GROWI.cloud
    */
-  private async readHtmlAndConvertToPdfUntilFinish(jobId: string, orgId?: string, appId?: string): Promise<void> {
+  private async readHtmlAndConvertToPdfUntilFinish(jobId: string, appId?: string): Promise<void> {
     while (!this.isJobCompleted(jobId)) {
       // eslint-disable-next-line no-await-in-loop
       await new Promise(resolve => setTimeout(resolve, 10 * 1000));
@@ -156,7 +153,7 @@ class PdfConvertService implements OnInit {
           throw new Error('Job expired');
         }
 
-        const htmlReadable = this.getHtmlReadable(jobId, orgId, appId);
+        const htmlReadable = this.getHtmlReadable(jobId, appId);
         const pdfWritable = this.getPdfWritable();
         this.jobList[jobId].currentStream = htmlReadable;
 
@@ -176,12 +173,11 @@ class PdfConvertService implements OnInit {
   /**
    * Get readable stream that reads html files from shared fs path
    * @param jobId PageBulkExportJob ID
-   * @param orgId organization ID for GROWI.cloud
    * @param appId application ID for GROWI.cloud
    * @returns readable stream
    */
-  private getHtmlReadable(jobId: string, orgId?: string, appId?: string): Readable {
-    const jobHtmlDir = path.join(this.tmpHtmlDir, orgId ?? '', appId ?? '', jobId);
+  private getHtmlReadable(jobId: string, appId?: string): Readable {
+    const jobHtmlDir = path.join(this.tmpHtmlDir, appId ?? '', jobId);
     const htmlFileEntries = fs.readdirSync(jobHtmlDir, { recursive: true, withFileTypes: true }).filter(entry => entry.isFile());
     let index = 0;
 

+ 0 - 1
packages/pdf-converter-client/src/index.ts

@@ -43,7 +43,6 @@ export type PdfCtrlSyncJobStatusBody = {
   expirationDate: string;
   /** @minLength 1 */
   jobId: string;
-  orgId?: string;
   /** @minLength 1 */
   status: PdfCtrlSyncJobStatusBodyStatus;
 };