aboutsummaryrefslogtreecommitdiff
path: root/services/docker/mail-server/relay/aws/context.ts
diff options
context:
space:
mode:
Diffstat (limited to 'services/docker/mail-server/relay/aws/context.ts')
-rw-r--r--services/docker/mail-server/relay/aws/context.ts30
1 files changed, 12 insertions, 18 deletions
diff --git a/services/docker/mail-server/relay/aws/context.ts b/services/docker/mail-server/relay/aws/context.ts
index 34d2d9f..c4f67bc 100644
--- a/services/docker/mail-server/relay/aws/context.ts
+++ b/services/docker/mail-server/relay/aws/context.ts
@@ -3,27 +3,21 @@ import {
DeleteObjectCommand,
S3Client,
} from "@aws-sdk/client-s3";
+import { FetchHttpHandler } from "@smithy/fetch-http-handler";
-import { getConfig } from "../config.ts";
-
-declare module "../mail.ts" {
- interface Mail {
- awsMessageId?: string;
- }
-}
+import { getConfigValue } from "../config.ts";
export class AwsContext {
- readonly region = "ap-southeast-1";
-
- accessKeyId = getConfig().getValue("awsAccessKeyId");
- secretAccessKey = getConfig().getValue("awsSecretAccessKey");
-
- getCredentials() {
- const { accessKeyId, secretAccessKey } = this;
- return Promise.resolve({ accessKeyId, secretAccessKey });
+ readonly credentials = () =>
+ Promise.resolve({
+ accessKeyId: getConfigValue("awsAccessKeyId"),
+ secretAccessKey: getConfigValue("awsSecretAccessKey"),
+ });
+ readonly requestHandler = new FetchHttpHandler();
+
+ get region() {
+ return getConfigValue("awsRegion");
}
-
- readonly credentials = this.getCredentials.bind(this);
}
export async function s3MoveObject(
@@ -35,7 +29,7 @@ export async function s3MoveObject(
const copyCommand = new CopyObjectCommand({
Bucket: bucket,
Key: newPath,
- CopySource: path,
+ CopySource: `${bucket}/${path}`,
});
await client.send(copyCommand);