File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
apps/queue-manager/src/consumers
libs/dal/src/repositories/upload Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,13 @@ export class SendBubbleDataConsumer extends BaseConsumer {
164164 Object . keys ( extra ) . forEach ( ( extraObjKey ) => {
165165 defaultValueObj [ `extra.${ extraObjKey } ` ] = extra [ extraObjKey ] ;
166166 } ) ;
167+ if ( uploadata . customRecordFormat && uploadata . customRecordFormat . includes ( '{{extra.uploadId}}' ) ) {
168+ defaultValueObj [ 'extra.uploadId' ] = _uploadId ;
169+ }
170+
171+ if ( uploadata . customRecordFormat && uploadata . customRecordFormat . includes ( '{{extra.userId}}' ) ) {
172+ defaultValueObj [ 'extra.userId' ] = await this . uploadRepository . getUserIdFromUploadId ( _uploadId ) ;
173+ }
167174 } catch ( error ) { }
168175 }
169176
Original file line number Diff line number Diff line change @@ -307,4 +307,21 @@ export class UploadRepository extends BaseRepository<UploadEntity> {
307307
308308 return ( environment [ 0 ] . apiKeys [ 0 ] . _userId as unknown as UserEntity ) . email ;
309309 }
310+
311+ async getUserIdFromUploadId ( uploadId : string ) : Promise < string > {
312+ const uploadInfoWithTemplate = await Upload . findById ( uploadId ) . populate ( [
313+ {
314+ path : '_templateId' ,
315+ } ,
316+ ] ) ;
317+ const environment = await Environment . find ( {
318+ _projectId : ( uploadInfoWithTemplate . _templateId as unknown as TemplateEntity ) . _projectId ,
319+ } ) . populate ( [
320+ {
321+ path : 'apiKeys._userId' ,
322+ } ,
323+ ] ) ;
324+
325+ return ( environment [ 0 ] . apiKeys [ 0 ] . _userId as unknown as UserEntity ) . _id ;
326+ }
310327}
You can’t perform that action at this time.
0 commit comments