Skip to content

Commit 361ba78

Browse files
committed
chore: wip
1 parent 6aaa750 commit 361ba78

File tree

4 files changed

+2324
-149
lines changed

4 files changed

+2324
-149
lines changed

storage/framework/core/cloud/src/cloud/email.ts

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,20 @@ export class EmailStack {
3232
encryption: s3.BucketEncryption.S3_MANAGED,
3333
lifecycleRules: [
3434
{
35-
id: '24h',
35+
id: 'Intelligent transition for Incoming',
3636
enabled: true,
37-
expiration: Duration.days(1),
38-
noncurrentVersionExpiration: Duration.days(1),
39-
prefix: 'today/',
37+
prefix: 'incoming/',
38+
transitions: [
39+
{
40+
storageClass: s3.StorageClass.INTELLIGENT_TIERING,
41+
transitionAfter: Duration.days(0),
42+
},
43+
],
4044
},
4145
{
42-
id: 'Intelligent transition for Inbox',
46+
id: 'Intelligent transition for Sent',
4347
enabled: true,
44-
prefix: 'inbox/',
48+
prefix: 'sent/',
4549
transitions: [
4650
{
4751
storageClass: s3.StorageClass.INTELLIGENT_TIERING,
@@ -50,16 +54,39 @@ export class EmailStack {
5054
],
5155
},
5256
{
53-
id: 'Intelligent transition for Sent',
57+
id: 'Intelligent transition for Archive',
5458
enabled: true,
55-
prefix: 'sent/',
59+
prefix: 'archive/',
5660
transitions: [
5761
{
5862
storageClass: s3.StorageClass.INTELLIGENT_TIERING,
5963
transitionAfter: Duration.days(0),
6064
},
6165
],
6266
},
67+
{
68+
id: 'Intelligent transition for Drafts',
69+
enabled: true,
70+
prefix: 'drafts/',
71+
transitions: [
72+
{
73+
storageClass: s3.StorageClass.INTELLIGENT_TIERING,
74+
transitionAfter: Duration.days(0),
75+
},
76+
],
77+
},
78+
{
79+
id: 'Auto-delete Trash after 30 days',
80+
enabled: true,
81+
prefix: 'trash/',
82+
expiration: Duration.days(30),
83+
},
84+
{
85+
id: 'Auto-delete Junk after 7 days',
86+
enabled: true,
87+
prefix: 'junk/',
88+
expiration: Duration.days(7),
89+
},
6390
],
6491
})
6592

@@ -102,7 +129,7 @@ export class EmailStack {
102129
{
103130
s3Action: {
104131
bucketName: this.emailBucket.bucketName,
105-
objectKeyPrefix: 'tmp/email_in/',
132+
objectKeyPrefix: 'incoming/', // IMAP server reads from this prefix
106133
},
107134
},
108135
],
@@ -330,7 +357,7 @@ export class EmailStack {
330357
this.emailBucket.addEventNotification(
331358
s3.EventType.OBJECT_CREATED_PUT,
332359
new s3n.LambdaDestination(lambdaEmailInbound),
333-
{ prefix: 'tmp/email_in/' },
360+
{ prefix: 'incoming/' },
334361
)
335362
this.emailBucket.addEventNotification(
336363
s3.EventType.OBJECT_CREATED_PUT,
@@ -345,12 +372,12 @@ export class EmailStack {
345372
this.emailBucket.addEventNotification(
346373
s3.EventType.OBJECT_CREATED_COPY,
347374
new s3n.LambdaDestination(lambdaEmailConverter),
348-
{ prefix: 'inbox/' },
375+
{ prefix: 'incoming/' },
349376
)
350377
this.emailBucket.addEventNotification(
351378
s3.EventType.OBJECT_CREATED_COPY,
352379
new s3n.LambdaDestination(lambdaEmailConverter),
353-
{ prefix: 'today/' },
380+
{ prefix: 'archive/' },
354381
)
355382
}
356383
}

storage/framework/core/cloud/src/cloud/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ export class Cloud extends Stack {
8181
zone: this.dns.zone,
8282
})
8383

84-
// Deploy mail server if mode is 'server'
85-
if (config.email.server?.mode === 'server') {
84+
// Deploy mail server if enabled (works for both 'serverless' and 'server' modes)
85+
if (config.email.server?.enabled) {
8686
this.mailServer = new MailServerStack(this, {
8787
...props,
8888
vpc: this.network.vpc,
8989
zone: this.dns.zone,
9090
certificate: this.security.certificate,
91+
emailBucket: this.email.emailBucket, // Share the email bucket for S3 storage
9192
})
9293
}
9394

0 commit comments

Comments
 (0)