Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/queue-manager/src/consumers/send-bubble-data.consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ export class SendBubbleDataConsumer extends BaseConsumer {
Object.keys(extra).forEach((extraObjKey) => {
defaultValueObj[`extra.${extraObjKey}`] = extra[extraObjKey];
});
if (uploadata.customRecordFormat && uploadata.customRecordFormat.includes('{{extra.uploadId}}')) {
defaultValueObj['extra.uploadId'] = _uploadId;
}

if (uploadata.customRecordFormat && uploadata.customRecordFormat.includes('{{extra.userId}}')) {
defaultValueObj['extra.userId'] = await this.uploadRepository.getUserIdFromUploadId(_uploadId);
}
} catch (error) {}
}

Expand Down
17 changes: 17 additions & 0 deletions libs/dal/src/repositories/upload/upload.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,21 @@ export class UploadRepository extends BaseRepository<UploadEntity> {

return (environment[0].apiKeys[0]._userId as unknown as UserEntity).email;
}

async getUserIdFromUploadId(uploadId: string): Promise<string> {
const uploadInfoWithTemplate = await Upload.findById(uploadId).populate([
{
path: '_templateId',
},
]);
const environment = await Environment.find({
_projectId: (uploadInfoWithTemplate._templateId as unknown as TemplateEntity)._projectId,
}).populate([
{
path: 'apiKeys._userId',
},
]);

return (environment[0].apiKeys[0]._userId as unknown as UserEntity)._id;
}
}
Loading