From 83765136ccacd82ba6a8f9fb43eed78191ee0aa5 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Sat, 6 Mar 2021 13:36:12 +0100 Subject: [PATCH] Added mailer functions ref #154 --- src/mailer.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/mailer.ts b/src/mailer.ts index 33d7f24..4d1753a 100644 --- a/src/mailer.ts +++ b/src/mailer.ts @@ -25,4 +25,36 @@ export class Mailer { throw new MailSendingError(); } } + + /** + * Function for sending a runner selfservice welcome mail. + * @param to_address The address the mail will be sent to. Should always get pulled from a runner object. + * @param token The requested selfservice token - will be combined with the app_url to generate a selfservice profile link. + */ + public static async sendSelfserviceWelcomeMail(to_address: string, token: string, locale: string = "en") { + try { + await axios.post(`${Mailer.base}/registration?locale=${locale}&key=${Mailer.key}`, { + address: to_address, + selfserviceToken: token + }); + } catch (error) { + throw new MailSendingError(); + } + } + + /** + * Function for sending a runner selfservice link forgotten mail. + * @param to_address The address the mail will be sent to. Should always get pulled from a runner object. + * @param token The requested selfservice token - will be combined with the app_url to generate a selfservice profile link. + */ + public static async sendSelfserviceForgottenMail(to_address: string, token: string, locale: string = "en") { + try { + await axios.post(`${Mailer.base}/registration_forgot?locale=${locale}&key=${Mailer.key}`, { + address: to_address, + selfserviceToken: token + }); + } catch (error) { + throw new MailSendingError(); + } + } }