Aravinth Manivannan
db358e4632
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Co-authored-by: Ryuno-Ki
21 lines
585 B
TypeScript
21 lines
585 B
TypeScript
import * as config from "./config";
|
|
|
|
export const getEmails = async (toAddr: string) => {
|
|
const url = new URL(config.MAILDEV_URL);
|
|
url.pathname = "/email";
|
|
let res = await fetch(url);
|
|
let data = await res.json();
|
|
const mails = Array.from(data).filter(
|
|
(mail: any) => mail.to[0].address === toAddr
|
|
);
|
|
return mails;
|
|
};
|
|
|
|
export const getActivationLink = async (
|
|
toAddr: string
|
|
): Promise<string | void> => {
|
|
let emails = await getEmails(toAddr);
|
|
return emails
|
|
.find((mail) => mail.subject.includes("Please activate your account"))
|
|
.text.split("\n")[4];
|
|
};
|