diff --git a/dist/clubs/dc-otto/mailer/index.d.ts b/dist/src/clubs/dc-otto/mailer/index.d.ts similarity index 100% rename from dist/clubs/dc-otto/mailer/index.d.ts rename to dist/src/clubs/dc-otto/mailer/index.d.ts diff --git a/dist/clubs/dc-otto/mailer/index.js b/dist/src/clubs/dc-otto/mailer/index.js similarity index 100% rename from dist/clubs/dc-otto/mailer/index.js rename to dist/src/clubs/dc-otto/mailer/index.js diff --git a/dist/clubs/dc-otto/mailer/templates/index.d.ts b/dist/src/clubs/dc-otto/mailer/templates/index.d.ts similarity index 100% rename from dist/clubs/dc-otto/mailer/templates/index.d.ts rename to dist/src/clubs/dc-otto/mailer/templates/index.d.ts diff --git a/dist/clubs/dc-otto/mailer/templates/index.js b/dist/src/clubs/dc-otto/mailer/templates/index.js similarity index 100% rename from dist/clubs/dc-otto/mailer/templates/index.js rename to dist/src/clubs/dc-otto/mailer/templates/index.js diff --git a/dist/index.d.ts b/dist/src/index.d.ts similarity index 88% rename from dist/index.d.ts rename to dist/src/index.d.ts index 5a161fb..459aac4 100644 --- a/dist/index.d.ts +++ b/dist/src/index.d.ts @@ -12,4 +12,5 @@ export declare const CompileEventEmail: (event: core.Event.Model, club: core.Clu export declare const CompilePostEmail: (post: core.Post.Model, club: core.Club.Model, link: string) => Promise; export declare const CompileConfirmationEmail: (reservation: core.Event.Reservation, event: core.Event.Model, group: core.Calendar.Group, club: core.Club.Model, url: string) => Promise; export declare const CompileWelcomeEmail: (user: core.User.Model, club: core.Club.Model, inviteLink: string) => Promise; +export declare const CompileInvalidEmailAdminNotification: (adminName: string, invalidEmail: string, club: core.Club.Model) => Promise; export declare const CompileServiceEmail: (info: ConfirmationInfo, club: core.Club.Model) => Promise; diff --git a/dist/index.js b/dist/src/index.js similarity index 88% rename from dist/index.js rename to dist/src/index.js index 60b8122..b2632ed 100644 --- a/dist/index.js +++ b/dist/src/index.js @@ -33,6 +33,11 @@ exports.CompileWelcomeEmail = (user, club, inviteLink) => { const path = `${__dirname}/templates/welcome.html`; return CompileEmail(path, welcomeInfo, club); }; +exports.CompileInvalidEmailAdminNotification = (adminName, invalidEmail, club) => { + const invalidEmailInfo = transform.BuildInvalidEmailAdminNotificationContent(adminName, invalidEmail, club); + const path = `${__dirname}/templates/invalidEmail.html`; + return CompileEmail(path, invalidEmailInfo, club); +}; exports.CompileServiceEmail = (info, club) => { const path = `${__dirname}/templates/confirmation.html`; return CompileEmail(path, info, club); diff --git a/dist/models/club.d.ts b/dist/src/models/club.d.ts similarity index 100% rename from dist/models/club.d.ts rename to dist/src/models/club.d.ts diff --git a/dist/models/club.js b/dist/src/models/club.js similarity index 100% rename from dist/models/club.js rename to dist/src/models/club.js diff --git a/dist/models/confirmation.d.ts b/dist/src/models/confirmation.d.ts similarity index 100% rename from dist/models/confirmation.d.ts rename to dist/src/models/confirmation.d.ts diff --git a/dist/models/confirmation.js b/dist/src/models/confirmation.js similarity index 100% rename from dist/models/confirmation.js rename to dist/src/models/confirmation.js diff --git a/dist/models/event.d.ts b/dist/src/models/event.d.ts similarity index 100% rename from dist/models/event.d.ts rename to dist/src/models/event.d.ts diff --git a/dist/models/event.js b/dist/src/models/event.js similarity index 100% rename from dist/models/event.js rename to dist/src/models/event.js diff --git a/dist/src/models/invalidEmail.d.ts b/dist/src/models/invalidEmail.d.ts new file mode 100644 index 0000000..00b4d7a --- /dev/null +++ b/dist/src/models/invalidEmail.d.ts @@ -0,0 +1,6 @@ +import { ClubInfo } from './club'; +export interface InvalidEmail { + firstName: string; + invalidEmail: string; + club: ClubInfo; +} diff --git a/dist/models/rich.js b/dist/src/models/invalidEmail.js similarity index 100% rename from dist/models/rich.js rename to dist/src/models/invalidEmail.js diff --git a/dist/models/location.d.ts b/dist/src/models/location.d.ts similarity index 100% rename from dist/models/location.d.ts rename to dist/src/models/location.d.ts diff --git a/dist/models/location.js b/dist/src/models/location.js similarity index 100% rename from dist/models/location.js rename to dist/src/models/location.js diff --git a/dist/models/rich.d.ts b/dist/src/models/rich.d.ts similarity index 100% rename from dist/models/rich.d.ts rename to dist/src/models/rich.d.ts diff --git a/dist/models/welcome.js b/dist/src/models/rich.js similarity index 100% rename from dist/models/welcome.js rename to dist/src/models/rich.js diff --git a/dist/models/welcome.d.ts b/dist/src/models/welcome.d.ts similarity index 100% rename from dist/models/welcome.d.ts rename to dist/src/models/welcome.d.ts diff --git a/dist/services/ses/types.js b/dist/src/models/welcome.js similarity index 100% rename from dist/services/ses/types.js rename to dist/src/models/welcome.js diff --git a/dist/services/ses/index.d.ts b/dist/src/services/ses/index.d.ts similarity index 100% rename from dist/services/ses/index.d.ts rename to dist/src/services/ses/index.d.ts diff --git a/dist/services/ses/index.js b/dist/src/services/ses/index.js similarity index 100% rename from dist/services/ses/index.js rename to dist/src/services/ses/index.js diff --git a/dist/services/ses/types.d.ts b/dist/src/services/ses/types.d.ts similarity index 100% rename from dist/services/ses/types.d.ts rename to dist/src/services/ses/types.d.ts diff --git a/dist/src/services/ses/types.js b/dist/src/services/ses/types.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/src/services/ses/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/templates/assets/img/wingpoint-logo.png b/dist/src/templates/assets/img/wingpoint-logo.png similarity index 100% rename from dist/templates/assets/img/wingpoint-logo.png rename to dist/src/templates/assets/img/wingpoint-logo.png diff --git a/dist/templates/confirmation.html b/dist/src/templates/confirmation.html similarity index 100% rename from dist/templates/confirmation.html rename to dist/src/templates/confirmation.html diff --git a/dist/templates/css/app.css b/dist/src/templates/css/app.css similarity index 100% rename from dist/templates/css/app.css rename to dist/src/templates/css/app.css diff --git a/dist/templates/event.html b/dist/src/templates/event.html similarity index 100% rename from dist/templates/event.html rename to dist/src/templates/event.html diff --git a/dist/templates/generic.html b/dist/src/templates/generic.html similarity index 100% rename from dist/templates/generic.html rename to dist/src/templates/generic.html diff --git a/dist/templates/index.html b/dist/src/templates/index.html similarity index 100% rename from dist/templates/index.html rename to dist/src/templates/index.html diff --git a/dist/src/templates/invalidEmail.html b/dist/src/templates/invalidEmail.html new file mode 100644 index 0000000..8e037cd --- /dev/null +++ b/dist/src/templates/invalidEmail.html @@ -0,0 +1 @@ +My Basic Email Template Subject
{{club.name}}

Hi {{firstName}},


We noticed the unknown email: {{invalidEmail}} is attempting to login, or reset their password.


This typically means a member has forgot the email they use to login to the platform. If you recognize this email, or know who the member could be, please reach out to them to help them login.

                                                           
\ No newline at end of file diff --git a/dist/templates/placeholder.html b/dist/src/templates/placeholder.html similarity index 100% rename from dist/templates/placeholder.html rename to dist/src/templates/placeholder.html diff --git a/dist/templates/post.html b/dist/src/templates/post.html similarity index 100% rename from dist/templates/post.html rename to dist/src/templates/post.html diff --git a/dist/templates/welcome.html b/dist/src/templates/welcome.html similarity index 100% rename from dist/templates/welcome.html rename to dist/src/templates/welcome.html diff --git a/dist/transform/constants.d.ts b/dist/src/transform/constants.d.ts similarity index 100% rename from dist/transform/constants.d.ts rename to dist/src/transform/constants.d.ts diff --git a/dist/transform/constants.js b/dist/src/transform/constants.js similarity index 100% rename from dist/transform/constants.js rename to dist/src/transform/constants.js diff --git a/dist/transform/transform.d.ts b/dist/src/transform/transform.d.ts similarity index 75% rename from dist/transform/transform.d.ts rename to dist/src/transform/transform.d.ts index 6b6db89..02cbc6b 100644 --- a/dist/transform/transform.d.ts +++ b/dist/src/transform/transform.d.ts @@ -2,11 +2,14 @@ import * as core from 'club-hub-core'; import { EventInfo } from '../models/event'; import { RichContent } from '../models/rich'; import { WelcomeContent } from '../models/welcome'; +import { InvalidEmail } from '../models/invalidEmail'; import { ConfirmationInfo } from '../models/confirmation'; import { ClubInfo } from '../models/club'; export declare const BuildGenericContent: (content: string, club: core.Club.Model) => RichContent; export declare const BuildEventContent: (event: core.Event.Model, club: core.Club.Model, link: string) => EventInfo; export declare const BuildWelcomeContent: (user: core.User.Model, club: core.Club.Model, inviteLink: string) => WelcomeContent; +export declare const BuildInvalidEmailAdminNotificationContent: (adminName: string, invalidEmail: string, club: core.Club.Model) => InvalidEmail; +export declare const CompileResetPasswordInvalidEmail: (post: core.Post.Model, club: core.Club.Model, link: string) => RichContent; export declare const BuildPostContent: (post: core.Post.Model, club: core.Club.Model, link: string) => RichContent; export declare const BuildConfirmationContent: (reservation: core.Event.Reservation, event: core.Event.Model, group: core.Calendar.Group, club: core.Club.Model, url: string) => ConfirmationInfo; export declare const BuildClubInfo: (club: core.Club.Model) => ClubInfo; diff --git a/dist/transform/transform.js b/dist/src/transform/transform.js similarity index 89% rename from dist/transform/transform.js rename to dist/src/transform/transform.js index 9c94938..7b67725 100644 --- a/dist/transform/transform.js +++ b/dist/src/transform/transform.js @@ -47,6 +47,25 @@ exports.BuildWelcomeContent = (user, club, inviteLink) => { }; return welcomeContent; }; +exports.BuildInvalidEmailAdminNotificationContent = (adminName, invalidEmail, club) => { + const invalidEmailContent = { + firstName: adminName, + invalidEmail, + club: exports.BuildClubInfo(club), + }; + return invalidEmailContent; +}; +exports.CompileResetPasswordInvalidEmail = (post, club, link) => { + const postInfo = { + name: post.title, + photoURL: post.image.md, + content: post.richContent.html, + url: link, + cta: 'View Post', + club: exports.BuildClubInfo(club), + }; + return postInfo; +}; exports.BuildPostContent = (post, club, link) => { const postInfo = { name: post.title, diff --git a/dist/tests/config.test.d.ts b/dist/tests/config.test.d.ts new file mode 100644 index 0000000..53eb506 --- /dev/null +++ b/dist/tests/config.test.d.ts @@ -0,0 +1 @@ +import 'mocha'; diff --git a/dist/tests/config.test.js b/dist/tests/config.test.js new file mode 100644 index 0000000..f8fd25a --- /dev/null +++ b/dist/tests/config.test.js @@ -0,0 +1,16 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +require("mocha"); +before(function () { + return __awaiter(this, void 0, void 0, function* () { + this.timeout(2000); + }); +}); diff --git a/dist/tests/emails.d.ts b/dist/tests/emails.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/tests/emails.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/tests/emails.js b/dist/tests/emails.js new file mode 100644 index 0000000..8510964 --- /dev/null +++ b/dist/tests/emails.js @@ -0,0 +1,62 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const assert = require("assert"); +const dotenv = require("dotenv"); +const event_1 = require("./factories/event"); +const post_1 = require("./factories/post"); +const club_1 = require("./factories/club"); +const emails = require("../src/index"); +const ses_1 = require("../src/services/ses"); +dotenv.config(); +const sender = 'kevin@meshstudio.io'; +const recipient = 'tayhalla@gmail.com'; +let emailToSend; +describe('Emails', function () { + describe('Events', function () { + it('should build an event email', function () { + return __awaiter(this, void 0, void 0, function* () { + const event = event_1.NewEventObj(); + const club = club_1.NewClubObj(); + const email = yield emails.CompileConfirmationEmail({}, event, {}, club, ''); + assert(email); + }); + }); + }); + describe('Posts', function () { + it('should build an post email', function () { + return __awaiter(this, void 0, void 0, function* () { + const post = post_1.NewPostObj(); + const club = club_1.NewClubObj(); + const email = yield emails.CompilePostEmail(post, club, ''); + assert(email); + }); + }); + }); + describe('InvalidEmail', function () { + it('should build an invalid email notification', function () { + return __awaiter(this, void 0, void 0, function* () { + const club = club_1.NewClubObj(); + const email = yield emails.CompileInvalidEmailAdminNotification('Taylor', 'taylor@whodis.com', club); + console.log(email); + assert(email); + emailToSend = email; + }); + }); + }); + describe('Send Email', function () { + it('should build an event email', function () { + return __awaiter(this, void 0, void 0, function* () { + const response = yield ses_1.default.sendHTMLEmail(sender, [recipient], ['tayhalla@gmail.com'], [], `Test Send`, emailToSend); + console.log("Response", response); + }); + }); + }); +}); diff --git a/dist/tests/factories/club.d.ts b/dist/tests/factories/club.d.ts new file mode 100644 index 0000000..c4fdc51 --- /dev/null +++ b/dist/tests/factories/club.d.ts @@ -0,0 +1,3 @@ +import * as core from 'club-hub-core'; +declare const newClubObj: () => core.Club.Model; +export { newClubObj as NewClubObj }; diff --git a/dist/tests/factories/club.js b/dist/tests/factories/club.js new file mode 100644 index 0000000..5dd749a --- /dev/null +++ b/dist/tests/factories/club.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Factory = require("factory.ts"); +const Faker = require("faker"); +const core = require("club-hub-core"); +const location_1 = require("./submodels/location"); +const clubFactory = Factory.makeFactory({ + name: Factory.each((i) => Faker.name.title()), + locations: [location_1.NewLocationObj()], + userGroups: [], + type: core.Club.Type.Golf, + tzid: '', + lat: '', + lon: '', + image: {}, + clubSettings: { + primaryColor: '#fead0d' + } +}); +const newClubObj = () => { + return clubFactory.build({}); +}; +exports.NewClubObj = newClubObj; diff --git a/dist/tests/factories/event.d.ts b/dist/tests/factories/event.d.ts new file mode 100644 index 0000000..30628aa --- /dev/null +++ b/dist/tests/factories/event.d.ts @@ -0,0 +1,3 @@ +import * as core from 'club-hub-core'; +declare const newEventObj: () => core.Event.Model; +export { newEventObj as NewEventObj }; diff --git a/dist/tests/factories/event.js b/dist/tests/factories/event.js new file mode 100644 index 0000000..ad467b9 --- /dev/null +++ b/dist/tests/factories/event.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Factory = require("factory.ts"); +const Faker = require("faker"); +const location_1 = require("./submodels/location"); +const reservation = { + creator: "", + owner: "", + participants: [] +}; +const EventFactory = Factory.makeFactory({ + calendarID: "", + clubID: "", + image: {}, + location: location_1.NewLocationObj(), + name: Factory.each((i) => Faker.lorem.word()), + remoteID: Factory.each((i) => Faker.random.uuid()), + price: '20', + shortLink: undefined, + richContent: { html: '

Howdy

' }, + reservations: [reservation] +}); +const newEventObj = () => { + return EventFactory.build({}); +}; +exports.NewEventObj = newEventObj; diff --git a/dist/tests/factories/post.d.ts b/dist/tests/factories/post.d.ts new file mode 100644 index 0000000..2a4541b --- /dev/null +++ b/dist/tests/factories/post.d.ts @@ -0,0 +1,3 @@ +import * as core from 'club-hub-core'; +declare const newPostObj: () => core.Post.Model; +export { newPostObj as NewPostObj }; diff --git a/dist/tests/factories/post.js b/dist/tests/factories/post.js new file mode 100644 index 0000000..b331021 --- /dev/null +++ b/dist/tests/factories/post.js @@ -0,0 +1,79 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Factory = require("factory.ts"); +const Faker = require("faker"); +const core = require("club-hub-core"); +const testPostContent = `

\n

 

\n

Dear +OTTO Members,

\n

 

\n

As we bear through the heat in +Scottsdale, we trust that you all are making the most of the summer! For those of you who are out of town for the +summer, please reach out to a member of our team if you require any assistance in transporting, servicing or +preparing your vehicles in anticipation of your return to the valley.

\n

 

\n

It was a pleasure to host those of you who attended our July Breakfast Club and Happy Hour +events. If you haven’t had a chance to come to either of these recurring events yet, we urge you to mark them +on your calendar so that you don’t miss out on them in the coming months. The Breakfast Club (every second +Saturday) and Happy Hour (every third Thursday), will continue to serve as opportunities to further embed yourself +within the OTTO community, welcome our newest members and take a peek at the newest cars to arrive in the main +Collection Room.

\n

 

\n

+

\n

 

\n

+There are a few important dates for the month of August that we would like to make you aware of:

\n

 

\n

OTTO will be closed on Thursday, August +15th for a private event. We will be moving some vehicles in the warehouse for privacy and security. If +you have any questions or concerns about your vehicle being relocated within the warehouse, please contact a member +of the OTTO Staff. Please note – the cars will not leave the collection room at any time, they will simply be +reorganized for the event.

\n

 

\n

For those Members with a +vehicle(s) in the Main Collection Room needing access to their vehicle on August 15th, we request that vehicle +pickup is made prior to close on Wednesday, August 14th. If this creates any conflict, please contact OTTO Staff for +special arrangements.

\n

 

\n

Due to the closure on August +15th, our monthly Happy Hour event will be delayed one week and will take place on Thursday, August +22nd. Please continue to check the app for the latest event information.

\n

\n

+

\n

 

\n

+As the weather cools down, the schedule at OTTO will heat up. We are in the process of scheduling multiple landmark +events in the fall such as the joint return of Discommon and Analog Shift, a Fireside Chat with the Jacksons, +Speaker event with Magnus Walker and more.

\n

 

\n

Also, +we’d like to remind you and your guests that neither OTTO employees nor any catering staff are allowed to +accept tips at any time. While we appreciate the gesture, OTTO membership is all-inclusive and any attempts to tip +will be respectfully declined.

\n

 

\n

As always, please do +not hesitate to reach out if there is anything that we can do for you.

\n

 

\n

 

\n

Thank you,

\n

 

\n

The OTTO Team

`; +const PostFactory = Factory.makeFactory({ + clubID: "", + title: Factory.each((i) => Faker.name.title()), + author: "", + image: { + lg: Faker.internet.url(), + md: Faker.internet.url(), + sm: Faker.internet.url(), + xs: Faker.internet.url(), + micro: Faker.internet.url(), + }, + attachments: Factory.each((i) => buildAttachments()), + subtitle: Factory.each((i) => Faker.lorem.words(3)), + publicationDate: new Date(), + richContent: { + text: Factory.each((i) => Faker.lorem.words(10)).toString(), + html: testPostContent, + status: core.IShared.PublicationStatus.Published, + } +}); +const buildAttachments = () => { + return [ + { + remoteUrl: Faker.internet.url(), + attachmentType: core.Post.AttachmentType.PNG + } + ]; +}; +const newPostObj = () => { + return PostFactory.build({}); +}; +exports.NewPostObj = newPostObj; diff --git a/dist/tests/factories/submodels/location.d.ts b/dist/tests/factories/submodels/location.d.ts new file mode 100644 index 0000000..210bf48 --- /dev/null +++ b/dist/tests/factories/submodels/location.d.ts @@ -0,0 +1,2 @@ +declare const newLocationObj: () => any; +export { newLocationObj as NewLocationObj }; diff --git a/dist/tests/factories/submodels/location.js b/dist/tests/factories/submodels/location.js new file mode 100644 index 0000000..7514476 --- /dev/null +++ b/dist/tests/factories/submodels/location.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Factory = require("factory.ts"); +const Faker = require("faker"); +const locationFactory = Factory.makeFactory({ + name: Factory.each((i) => 'Clubhouse'), + address1: Factory.each((i) => Faker.address.streetAddress()), + city: Factory.each((i) => Faker.address.city()), + state: Factory.each((i) => Faker.address.state()), + zip: Factory.each((i) => Faker.address.zipCode()), + contactName: Factory.each((i) => Faker.name.firstName()), + phone: Factory.each((i) => Faker.phone.phoneNumber()), + email: Factory.each((i) => Faker.internet.email()) +}); +const newLocationObj = () => { + return locationFactory.build({}); +}; +exports.NewLocationObj = newLocationObj; diff --git a/src/index.ts b/src/index.ts index ab79a40..6116c87 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,6 +21,7 @@ export { transform } import * as constants from './transform/constants' import { WelcomeContent } from './models/welcome'; +import { InvalidEmail } from './models/invalidEmail' export { constants } @@ -95,6 +96,19 @@ export const CompileWelcomeEmail = (user: core.User.Model, club: core.Club.Model return CompileEmail(path, welcomeInfo, club) } +/** + * Compiles a new welcome email. + * @param event The ClubHub user for the email. + * @param club The ClubHub club to which the email is associated. + */ + export const CompileInvalidEmailAdminNotification = (adminName: string, invalidEmail: string, club: core.Club.Model): Promise => { + // Transform our event Info + const invalidEmailInfo: InvalidEmail = transform.BuildInvalidEmailAdminNotificationContent(adminName, invalidEmail, club) + + // Compile the template and return the promise. + const path: string = `${__dirname}/templates/invalidEmail.html` + return CompileEmail(path, invalidEmailInfo, club) +} export const CompileServiceEmail = (info: ConfirmationInfo, club: core.Club.Model) => { // Compile the template and return the promise. diff --git a/src/models/invalidEmail.ts b/src/models/invalidEmail.ts new file mode 100644 index 0000000..17b05c7 --- /dev/null +++ b/src/models/invalidEmail.ts @@ -0,0 +1,7 @@ +import { ClubInfo } from './club' + +export interface InvalidEmail { + firstName: string + invalidEmail: string + club: ClubInfo +} diff --git a/src/templates/data-prod/invalidEmail.json b/src/templates/data-prod/invalidEmail.json new file mode 100644 index 0000000..e15b48d --- /dev/null +++ b/src/templates/data-prod/invalidEmail.json @@ -0,0 +1,4 @@ +{ + "firstName": "{{firstName}}", + "invalidEmail": "{{invalidEmail}}" +} \ No newline at end of file diff --git a/src/templates/data/invalidEmail.json b/src/templates/data/invalidEmail.json new file mode 100644 index 0000000..b264359 --- /dev/null +++ b/src/templates/data/invalidEmail.json @@ -0,0 +1,4 @@ +{ + "firstName": "Taylor", + "invalidEmail": "taylor@whodis.com" +} \ No newline at end of file diff --git a/src/templates/pages/invalidEmail.html b/src/templates/pages/invalidEmail.html new file mode 100644 index 0000000..b38d13f --- /dev/null +++ b/src/templates/pages/invalidEmail.html @@ -0,0 +1,38 @@ +--- +subject: My Basic Email Template Subject +--- + + + + + +
+ + {{club.name}} + +
+
+
+ + + +
+

+ Hi {{invalidEmail.firstName}}, +

+
+

+ We noticed the unknown email: {{invalidEmail.invalidEmail}} is attempting to login, or reset their password. +

+
+

+ This typically means a member has forgot the email they use to login + to the platform. If you recognize this email, or know who the member could be, + please reach out to them to help them login. +

+
+ + + + +{{> footer}} \ No newline at end of file diff --git a/src/transform/transform.ts b/src/transform/transform.ts index 66b1635..5d2bbc2 100644 --- a/src/transform/transform.ts +++ b/src/transform/transform.ts @@ -4,6 +4,7 @@ import { oc } from 'ts-optchain' import { EventInfo } from '../models/event' import { RichContent } from '../models/rich' import { WelcomeContent } from '../models/welcome' +import { InvalidEmail } from '../models/invalidEmail' import { ConfirmationInfo } from '../models/confirmation' import { ClubInfo } from '../models/club' @@ -72,6 +73,38 @@ export const BuildWelcomeContent = (user: core.User.Model, club: core.Club.Model return welcomeContent } +/** + * Builds a welcomeContent object for a welcome email. + * @param event The user for the email. + * @param club The club for the email. + */ + export const BuildInvalidEmailAdminNotificationContent = (adminName: string, invalidEmail: string, club: core.Club.Model): InvalidEmail => { + const invalidEmailContent: InvalidEmail = { + firstName: adminName, + invalidEmail, + club: BuildClubInfo(club), + } + return invalidEmailContent +} + +/** + * Builds a Riobject for a post. + * @param event The post for the email. + * @param club The club for the email. + */ + export const CompileResetPasswordInvalidEmail = (post: core.Post.Model, club: core.Club.Model, link: string): RichContent => { + const postInfo: RichContent = { + name: post.title, + photoURL: post.image.md, + content: post.richContent.html, + url: link, + cta: 'View Post', + club: BuildClubInfo(club), + + } + return postInfo +} + /** * Builds a Riobject for a post. * @param event The post for the email. diff --git a/tests/emails.ts b/tests/emails.ts index 2285063..268c3d2 100644 --- a/tests/emails.ts +++ b/tests/emails.ts @@ -17,7 +17,7 @@ import SESService from '../src/services/ses' dotenv.config() const sender = 'kevin@meshstudio.io' -const recipient = 'meshkevin@outlook.com' +const recipient = 'tayhalla@gmail.com' let emailToSend: string describe('Emails', function () { @@ -36,14 +36,22 @@ describe('Emails', function () { const club: core.Club.Model = NewClubObj() const email: string = await emails.CompilePostEmail(post, club, '') assert(email) - emailToSend = email }) }) + describe('InvalidEmail', function () { + it('should build an invalid email notification', async function () { + const club: core.Club.Model = NewClubObj() + const email: string = await emails.CompileInvalidEmailAdminNotification('Taylor', 'taylor@whodis.com', club) + console.log(email) + assert(email) + emailToSend = email + }) + }) describe.skip('Send Email', function () { it('should build an event email', async function () { - const response = await SESService.sendHTMLEmail(sender, [recipient], ['tayhalla@gmail.com', sender], [], `Test Send`, emailToSend) + const response = await SESService.sendHTMLEmail(sender, [recipient], ['tayhalla@gmail.com'], [], `Test Send`, emailToSend) console.log("Response", response) }); }); diff --git a/tsconfig.json b/tsconfig.json index d327e57..8c16a87 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,7 +30,6 @@ "**/*.spec.ts", "dist", "src/clubs", - "tests" ], "include": [ "./"