Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit 09d394f

Browse files
committed
feat(axiom): implement outgoing emails
1 parent 2d1ddb7 commit 09d394f

File tree

9 files changed

+206
-194
lines changed

9 files changed

+206
-194
lines changed

apps/axiom/src/payload.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ export default buildConfig({
116116
prefix: "./media",
117117
},
118118
},
119-
bucket: process.env.S3BUCKET || "",
119+
bucket: process.env.S3_BUCKET || "",
120120
config: {
121121
forcePathStyle: true, // Important for using Supabase
122122
credentials: {
123-
accessKeyId: process.env.S3ACCESSKEYID || "",
124-
secretAccessKey: process.env.S3SECRETACCESSKEY || "",
123+
accessKeyId: process.env.S3_ACCESSKEYID || "",
124+
secretAccessKey: process.env.S3_SECRET_ACCESSKEY || "",
125125
},
126-
region: process.env.S3REGION || "",
127-
endpoint: process.env.S3ENDPOINT || "",
126+
region: process.env.S3_REGION || "",
127+
endpoint: process.env.S3_ENDPOINT || "",
128128
},
129129
}),
130130
].filter(Boolean)

apps/email/templates/cuhacking/registered-for-hackathon.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
import { execSync } from 'node:child_process'
1+
/* import { execSync } from 'node:child_process' */
22
import { Banner, Content, Footer, Keyboard } from '@/email/components'
33
import { Container, Html, Section, Tailwind } from '@react-email/components'
44

55
function getGenericEmailConstants() {
6-
try {
7-
const response = execSync(
8-
`curl -s ${process.env.CUHACKING_2025_AXIOM_LOCAL_URL}/api/emails/1?depth=1`,
9-
).toString()
6+
/* try {
7+
* const response = execSync(
8+
* `curl -s ${process.env.CUHACKING_2025_AXIOM_LOCAL_URL}/api/emails/1?depth=1`,
9+
* ).toString()
1010
11-
const { title = 'No Title', body = {} } = JSON.parse(response)
11+
* const { title = 'No Title', body = {} } = JSON.parse(response)
1212
13-
return {
14-
title,
15-
body: {
16-
text: body.text || 'No body text provided.',
17-
buttonText: body.buttonText || '',
18-
buttonLink: body.buttonLink || '',
19-
footer: body.footer || '',
20-
},
21-
}
22-
}
23-
catch (error) {
24-
console.error('Error fetching email content:', error)
13+
* return {
14+
* title,
15+
* body: {
16+
* text: body.text || 'No body text provided.',
17+
* buttonText: body.buttonText || '',
18+
* buttonLink: body.buttonLink || '',
19+
* footer: body.footer || '',
20+
* },
21+
* }
22+
* } */
23+
/* catch (error) {
24+
* console.error('Error fetching email content:', error) */
2525
return {
2626
title: 'Default Title',
2727
body: {
2828
text: 'This is a fallback email body.',
2929
buttonText: 'Click Here',
30-
buttonLink: 'https://example.com',
30+
buttonLink: 'https://portal.cuhacking.ca',
3131
footer: 'See you soon!',
3232
},
3333
}
34-
}
34+
/* } */
3535
}
3636

3737
const genericEmailConstants = getGenericEmailConstants()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Preview from "../../../../apps/email/templates/cuhacking/registered-for-hackathon"
2+
import { render } from '@react-email/render';
3+
4+
export const html = await render(<Preview />, {
5+
pretty: true,
6+
});

libs/cms/endpoints/auth/google.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { PayloadRequest } from "payload";
22
import { OAuth2Plugin, defaultGetToken } from "payload-oauth2";
33
import { baseConfig, googleStrategyConfig } from "@/cms/endpoints/auth/config"
4+
import {html} from '@/cms/endpoints/auth/generateEmail'
45

56
export const googleOAuth = OAuth2Plugin({
67
...baseConfig,
@@ -52,6 +53,12 @@ getUserInfo: async (accessToken: string, req: PayloadRequest) => {
5253
// console.log('Found existing user:', existingUser.docs[0])
5354
// const userFromDB = existingUser.docs[0]
5455

56+
await req.payload.sendEmail({
57+
to: user.email,
58+
subject: 'Test Email for cuHacking Portal',
59+
html
60+
})
61+
5562
return {
5663
email: user.email,
5764
displayName: user.name,

libs/db/collections/models/Users.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ export const authenticated: IsAuthenticated = ({ req }) => Boolean(req.user)
1212
export const Users: CollectionConfig = {
1313
slug: 'users',
1414
auth: true,
15+
group: adminGroups.featured,
16+
useAsTitle: 'displayName',
17+
defaultColumns: [
18+
'displayName',
19+
'pronouns',
20+
'email',
21+
'updatedAt',
22+
'createdAt',
23+
'id',
24+
],
25+
pagination: {
26+
defaultLimit: 50,
27+
limits: [10, 20, 50],
28+
},
1529
access: {
1630
admin: authenticated,
1731
create: authenticated,
@@ -31,20 +45,6 @@ export const Users: CollectionConfig = {
3145
},
3246
],
3347
},
34-
group: adminGroups.featured,
35-
useAsTitle: 'displayName',
36-
defaultColumns: [
37-
'displayName',
38-
'pronouns',
39-
'email',
40-
'updatedAt',
41-
'createdAt',
42-
'id',
43-
],
44-
pagination: {
45-
defaultLimit: 50,
46-
limits: [10, 20, 50],
47-
},
4848
},
4949
fields: [
5050
{

0 commit comments

Comments
 (0)