2024-01-10 20:43:37 +05:30
|
|
|
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();
|
2024-01-10 22:52:04 +05:30
|
|
|
const mails = Array.from(data).filter(
|
|
|
|
(mail: any) => mail.to[0].address === toAddr
|
|
|
|
);
|
2024-01-10 20:43:37 +05:30
|
|
|
return mails;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getActivationLink = async (
|
|
|
|
toAddr: string
|
|
|
|
): Promise<string | void> => {
|
|
|
|
let emails = await getEmails(toAddr);
|
2024-01-10 22:52:04 +05:30
|
|
|
return emails
|
|
|
|
.find((mail) => mail.subject.includes("Please activate your account"))
|
|
|
|
.text.split("\n")[4];
|
2024-01-10 20:43:37 +05:30
|
|
|
};
|