Skip to content

Commit

Permalink
fix: Fixed error on awsBucketName not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Jun 4, 2023
1 parent 6bf45b0 commit 4512abf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Expand Up @@ -12,7 +12,7 @@ export default {
url: null,
autoDownload: true,
uploadS3: false,
awsBucketName: '',
awsBucketName: null,
readMessage: true,
allUnreadOnStart: false,
listenAcks: true,
Expand Down
11 changes: 4 additions & 7 deletions src/util/functions.ts
Expand Up @@ -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 = {
Expand Down

0 comments on commit 4512abf

Please sign in to comment.