feat: cleanup maildev filter
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

Co-authored-by: Ryuno-Ki
This commit is contained in:
Aravinth Manivannan 2024-01-10 22:52:04 +05:30
parent 7cd87d4c31
commit db358e4632
Signed by: realaravinth
GPG key ID: F8F50389936984FF

View file

@ -5,12 +5,9 @@ export const getEmails = async (toAddr: string) => {
url.pathname = "/email"; url.pathname = "/email";
let res = await fetch(url); let res = await fetch(url);
let data = await res.json(); let data = await res.json();
let mails = []; const mails = Array.from(data).filter(
Array.from(data).forEach((mail: any) => { (mail: any) => mail.to[0].address === toAddr
if (mail.to[0].address == toAddr) { );
mails.push(mail);
}
});
return mails; return mails;
}; };
@ -18,10 +15,7 @@ export const getActivationLink = async (
toAddr: string toAddr: string
): Promise<string | void> => { ): Promise<string | void> => {
let emails = await getEmails(toAddr); let emails = await getEmails(toAddr);
for (let i = 0; i < emails.length; i++) { return emails
let mail = emails[i]; .find((mail) => mail.subject.includes("Please activate your account"))
if (mail.subject.includes("Please activate your account")) { .text.split("\n")[4];
return mail.text.split('\n')[4]
}
}
}; };