feat: cleanup maildev filter
ci/woodpecker/push/woodpecker Pipeline failed Details

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
1 changed files with 6 additions and 12 deletions

View File

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