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,20 +775,29 @@ const migrateAndPopulateAttachmentMessages = async ({
const addDefaultStorageHelper = async ({ logger }: MigrationServices) => {
const SettingModel = mongoose.model<Setting>(Setting.name, settingSchema);
try {
await SettingModel.create({
group: 'chatbot_settings',
label: 'default_storage_helper',
value: 'local-storage-helper',
type: SettingType.select,
config: {
multiple: false,
allowCreate: false,
entity: 'Helper',
idKey: 'name',
labelKey: 'name',
await SettingModel.updateOne(
{
group: 'chatbot_settings',
label: 'default_storage_helper',
},
weight: 2,
});
{
group: 'chatbot_settings',
label: 'default_storage_helper',
value: 'local-storage-helper',
type: SettingType.select,
config: {
multiple: false,
allowCreate: false,
entity: 'Helper',
idKey: 'name',
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');