Browse Source

fix: include partial req reference to job payload

pull/6894/head
Pranav C 1 year ago
parent
commit
c49bb22535
  1. 5
      packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts
  2. 7
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts
  3. 10
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.controller.ts
  4. 7
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts
  5. 9
      packages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.ts
  6. 3
      packages/nocodb/src/modules/jobs/jobs/source-create/source-create.processor.ts
  7. 9
      packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.controller.ts
  8. 4
      packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.processor.ts

5
packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts

@ -53,6 +53,11 @@ export class AtImportController {
authToken: '',
baseURL,
user: user,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };

7
packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts

@ -87,6 +87,7 @@ export class DuplicateController {
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
@ -150,9 +151,10 @@ export class DuplicateController {
sourceId: source.id,
dupProjectId: dupProject.id,
options: body.options || {},
req: {
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
@ -205,9 +207,10 @@ export class DuplicateController {
modelId: model.id,
title: uniqueTitle,
options: body.options || {},
req: {
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});

10
packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.controller.ts

@ -38,6 +38,11 @@ export class MetaSyncController {
baseId,
sourceId: 'all',
user: req.user,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };
@ -70,6 +75,11 @@ export class MetaSyncController {
baseId,
sourceId,
user: req.user,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };

7
packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts

@ -17,19 +17,20 @@ export class MetaSyncProcessor {
const info: {
baseId: string;
sourceId: string;
user: any;
user: any
req:any;
} = job.data;
if (info.sourceId === 'all') {
await this.metaDiffsService.metaDiffSync({
baseId: info.baseId,
req: {},
req: info.req,
});
} else {
await this.metaDiffsService.baseMetaDiffSync({
baseId: info.baseId,
sourceId: info.sourceId,
req: {},
req: info.req,
});
}

9
packages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.ts

@ -4,7 +4,7 @@ import {
HttpCode,
Inject,
Param,
Post,
Post, Req,
UseGuards,
} from '@nestjs/common';
import { BaseReqType } from 'nocodb-sdk';
@ -25,7 +25,7 @@ export class SourceCreateController {
])
@HttpCode(200)
@Acl('baseCreate')
async baseCreate(@Param('baseId') baseId: string, @Body() body: BaseReqType) {
async baseCreate(@Param('baseId') baseId: string, @Body() body: BaseReqType, @Req() req) {
const jobs = await this.jobsService.jobList();
const fnd = jobs.find(
(j) => j.name === JobTypes.BaseCreate && j.data.baseId === baseId,
@ -40,6 +40,11 @@ export class SourceCreateController {
const job = await this.jobsService.add(JobTypes.BaseCreate, {
baseId,
source: body,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };

3
packages/nocodb/src/modules/jobs/jobs/source-create/source-create.processor.ts

@ -18,7 +18,7 @@ export class SourceCreateProcessor {
async job(job: Job) {
this.debugLog(`job started for ${job.id}`);
const { baseId, source } = job.data;
const { baseId, source, req } = job.data;
const logBasic = (log) => {
this.jobsLogService.sendLog(job, { message: log });
@ -29,6 +29,7 @@ export class SourceCreateProcessor {
baseId,
source,
logger: logBasic,
req,
});
if (createdBase.isMeta()) {

9
packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.controller.ts

@ -1,4 +1,4 @@
import { Controller, Delete, Inject, Param, UseGuards } from '@nestjs/common';
import {Controller, Delete, Inject, Param, Req, UseGuards} from '@nestjs/common';
import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { NcError } from '~/helpers/catchError';
@ -19,7 +19,7 @@ export class SourceDeleteController {
'/api/v2/meta/bases/:baseId/sources/:sourceId',
])
@Acl('baseDelete')
async baseDelete(@Param('sourceId') sourceId: string) {
async baseDelete(@Param('sourceId') sourceId: string,@Req() req){
const jobs = await this.jobsService.jobList();
const fnd = jobs.find(
(j) => j.name === JobTypes.BaseDelete && j.data.sourceId === sourceId,
@ -33,6 +33,11 @@ export class SourceDeleteController {
const job = await this.jobsService.add(JobTypes.BaseDelete, {
sourceId,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };

4
packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.processor.ts

@ -14,11 +14,11 @@ export class SourceDeleteProcessor {
async job(job: Job) {
this.debugLog(`job started for ${job.id}`);
const { sourceId } = job.data;
const { sourceId, req } = job.data;
await this.sourcesService.baseDelete({
sourceId,
req: {},
req,
});
this.debugLog(`job completed for ${job.id}`);

Loading…
Cancel
Save