fix: apply review feedback

This commit is contained in:
Mohamed Marrouchi 2025-01-20 11:58:29 +01:00
parent 81aed2e5db
commit 6a4746dccd
2 changed files with 24 additions and 15 deletions

View File

@ -61,7 +61,7 @@ export class AttachmentService extends BaseService<Attachment> {
const storageHelper = await this.helperService.getDefaultHelper(
HelperType.STORAGE,
);
return storageHelper.download(attachment);
return await storageHelper.download(attachment);
}
/**
@ -74,7 +74,7 @@ export class AttachmentService extends BaseService<Attachment> {
const storageHelper = await this.helperService.getDefaultHelper(
HelperType.STORAGE,
);
return storageHelper.readAsBuffer(attachment);
return await storageHelper.readAsBuffer(attachment);
}
/**

View File

@ -775,7 +775,12 @@ const migrateAndPopulateAttachmentMessages = async ({
const addDefaultStorageHelper = async ({ logger }: MigrationServices) => {
const SettingModel = mongoose.model<Setting>(Setting.name, settingSchema);
try {
await SettingModel.create({
await SettingModel.updateOne(
{
group: 'chatbot_settings',
label: 'default_storage_helper',
},
{
group: 'chatbot_settings',
label: 'default_storage_helper',
value: 'local-storage-helper',
@ -788,7 +793,11 @@ const addDefaultStorageHelper = async ({ logger }: MigrationServices) => {
labelKey: 'name',
},
weight: 2,
});
},
{
upsert: true,
},
);
logger.log('Successfuly added the default local storage helper setting');
} catch (err) {
logger.error('Unable to add the default local storage helper setting');