-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add fields for email reminder and template (#139)
Fixes #118 Fixes #135 Fixes #143 --------- Co-authored-by: Anton Lilleby <[email protected]>
- Loading branch information
Showing
30 changed files
with
1,180 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import ical, { ICalAttendeeRole, ICalAttendeeStatus, ICalCalendarMethod } from "ical-generator"; | ||
import { composeEmail, sendEmail } from "../nodemailer"; | ||
import { PUBLIC_APP_BASE_URL } from "$env/static/public"; | ||
import type { EventUpdatedProps } from "../../../routes/api/send-event-updated/+server"; | ||
|
||
interface EmailAcceptedProps extends EventUpdatedProps { | ||
to: string; | ||
} | ||
|
||
export const sendEmailAccepted = async (props: EmailAcceptedProps) => { | ||
const icsFile = createIcsFile(props); | ||
|
||
const emailTemplate = composeEmail({ | ||
...props, | ||
subject: `${props.subject} ${props.summary}`, | ||
icsFile, | ||
}); | ||
|
||
const result = await sendEmail(emailTemplate); | ||
return result; | ||
}; | ||
|
||
const createIcsFile = ({ | ||
id, | ||
to, | ||
summary, | ||
description, | ||
start, | ||
end, | ||
location, | ||
organiser, | ||
}: EmailAcceptedProps) => { | ||
const url = `${PUBLIC_APP_BASE_URL}/event/${id}`; | ||
const calendar = ical({ name: organiser, method: ICalCalendarMethod.REQUEST }); | ||
|
||
calendar.createEvent({ | ||
id, | ||
summary, | ||
description, | ||
location, | ||
start, | ||
end, | ||
url, | ||
attendees: [ | ||
{ | ||
email: to, | ||
status: ICalAttendeeStatus.ACCEPTED, | ||
role: ICalAttendeeRole.REQ, | ||
}, | ||
], | ||
organizer: { | ||
name: organiser === "Alle" ? "Capra Gruppen" : organiser, | ||
email: "[email protected]", | ||
}, | ||
}); | ||
|
||
return Buffer.from(calendar.toString()); | ||
}; |
Oops, something went wrong.
55097df
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
skjer – ./
skjer-git-main-capra.vercel.app
capra-web.vercel.app
skjer-capra.vercel.app
skjer.fryde.no
skjer.liflig.no
skjer.capraconsulting.no