diff --git a/README.md b/README.md index 2d7fd2866e..76e8aeb123 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ This server use config.ts file to define some options, default values are: // enable upload to s3 uploadS3: false, // set default bucket name on aws s3 - awsBucketName: '', + awsBucketName: null, //marks messages as read when the webhook returns ok readMessage: true, //sends all unread messages to the webhook when the server starts diff --git a/src/config.ts b/src/config.ts index c015a42473..1ae3fbc0a8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -12,7 +12,7 @@ export default { url: null, autoDownload: true, uploadS3: false, - awsBucketName: '', + awsBucketName: null, readMessage: true, allUnreadOnStart: false, listenAcks: true, diff --git a/src/util/functions.ts b/src/util/functions.ts index acb7f09f50..6ae52c8f61 100644 --- a/src/util/functions.ts +++ b/src/util/functions.ts @@ -137,14 +137,11 @@ async function autoDownload(client: any, req: any, message: any) { const hashName = crypto.randomBytes(24).toString('hex'); const s3 = new aws.S3(); - const bucketName = - config.webhook.awsBucketName && config.webhook.awsBucketName !== '' - ? config.webhook.awsBucketName - : client.session; + const bucketName = config.webhook?.awsBucketName + ? config.webhook?.awsBucketName + : client.session; const fileName = `${ - config.webhook.awsBucketName && config.webhook.awsBucketName !== '' - ? client.session + '/' - : '' + config.webhook?.awsBucketName ? client.session + '/' : '' }${hashName}.${mime.extension(message.mimetype)}`; const params = {