]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/utils/email.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / client / e2e / src / utils / email.ts
CommitLineData
5bdfa604
C
1function getVerificationLink (email: { text: string }) {
2 const { text } = email
3
4 const regexp = /\[(?<link>http:\/\/[^\]]+)\]/g
5 const matched = text.matchAll(regexp)
6
7 if (!matched) throw new Error('Could not find verification link in email')
8
9 for (const match of matched) {
10 const link = match.groups.link
11
12 if (link.includes('/verify-account/')) return link
13 }
14
15 throw new Error('Could not find /verify-account/ link')
16}
17
18function findEmailTo (emails: { text: string, to: { address: string }[] }[], to: string) {
19 for (const email of emails) {
20 for (const { address } of email.to) {
21 if (address === to) return email
22 }
23 }
24
25 return undefined
26}
27
28export {
29 getVerificationLink,
30 findEmailTo
31}