Skip to content

Commit

Permalink
10455-story: remove duplicative sendEmail
Browse files Browse the repository at this point in the history
  • Loading branch information
Mwindo committed Sep 5, 2024
1 parent b7d6db1 commit 301bbd3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
4 changes: 0 additions & 4 deletions scripts/user/add-judge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
getUserPoolId,
requireEnvVars,
} from '../../shared/admin-tools/util';
import { sendWelcomeEmail } from 'scripts/user/email-helpers';

// eslint-disable-next-line spellcheck/spell-checker
/**
Expand Down Expand Up @@ -115,9 +114,6 @@ requireEnvVars(['ENV']);
user: rawUser,
});

console.log('Sending welcome email ... ');
await sendWelcomeEmail({ applicationContext, email });

console.log(
`\nSuccess! Created Judge ${judgeFullName} with userId = ${userId} and email = ${email}.`,
);
Expand Down
15 changes: 13 additions & 2 deletions scripts/user/add-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from '../../shared/admin-tools/util';
import { judgeUser } from '@shared/test/mockUsers';
import { mockJudgeUser } from '@shared/test/mockAuthUsers';
import { sendWelcomeEmail } from 'scripts/user/email-helpers';
import joi from 'joi';

requireEnvVars(['ENV', 'DEFAULT_ACCOUNT_PASS']);
Expand Down Expand Up @@ -104,6 +103,18 @@ const checkParams = ({
return value;
};

export const sendWelcomeEmail = async ({ email }) => {
try {
await applicationContext.getCognito().adminCreateUser({
MessageAction: 'RESEND',
UserPoolId: environment.userPoolId,
Username: email.toLowerCase(),
});
} catch (err) {
console.error('Error sending welcome email', err);
}
};

// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
const { tableName } = await getDestinationTableInfo();
Expand All @@ -130,5 +141,5 @@ const checkParams = ({
setPasswordAsPermanent: true,
user: { ...params },
});
await sendWelcomeEmail({ applicationContext, email: params.email });
await sendWelcomeEmail({ email: params.email });
})();
13 changes: 0 additions & 13 deletions scripts/user/email-helpers.ts

This file was deleted.

0 comments on commit 301bbd3

Please sign in to comment.