Skip to content

Commit

Permalink
Merge branch 'release/v1.0.7' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-lebleu committed Apr 16, 2021
2 parents 83c781d + 046d102 commit 1fb9223
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 26 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [v1.0.6](https://github.com/konfer-be/cliam/compare/v1.0.5...v1.0.6)
## [v1.0.7](https://github.com/konfer-be/cliam/compare/v1.0.6...v1.0.7)

### Commits

- Sandbox for sparkpost & mailgun [`7327e7d`](https://github.com/konfer-be/cliam/commit/7327e7df6c98cb4d2a21bae8b6deecf3b10dd428)

## [v1.0.6](https://github.com/konfer-be/cliam/compare/v1.0.5...v1.0.6) - 2021-04-16

### Commits

- Update changelog [`8baef60`](https://github.com/konfer-be/cliam/commit/8baef60e65863c8475388bcbfd9fd76d4962ff84)
- Fix declaration [`26424e4`](https://github.com/konfer-be/cliam/commit/26424e4f8688bc4dcfa86105be73c027152fb6f9)

## [v1.0.5](https://github.com/konfer-be/cliam/compare/v1.0.4...v1.0.5) - 2021-04-16
Expand Down
2 changes: 2 additions & 0 deletions lib/transporters/mailgun/mailgun.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const compiler_enum_1 = require("./../../types/enums/compiler.enum");
* @see https://nodemailer.com/smtp/
* @see https://www.npmjs.com/package/nodemailer-mailgun-transport
* @see https://documentation.mailgun.com/en/latest/index.html
* @see https://documentation.mailgun.com/en/latest/user_manual.html#introduction
*
*/
class MailgunTransporter extends transporter_class_1.Transporter {
/**
Expand Down
31 changes: 22 additions & 9 deletions lib/types/decorators/debug.decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const Debug = (transporter) => {
if (output) {
if (container_service_1.Container.configuration?.sandbox?.active) {
switch (transporter) {
case transporter_enum_1.TRANSPORTER.mailgun:
Object.assign(output, { testmode: true });
break;
case transporter_enum_1.TRANSPORTER.mailjet:
Object.assign(output, {
SandboxMode: true,
Expand All @@ -27,15 +30,6 @@ const Debug = (transporter) => {
});
output.Messages[0].From = { Email: container_service_1.Container.configuration.sandbox.from.email, Name: container_service_1.Container.configuration.sandbox.from.name };
break;
case transporter_enum_1.TRANSPORTER.sendgrid:
Object.assign(output, {
mail_settings: {
sandbox_mode: {
enable: true
}
}
});
break;
case transporter_enum_1.TRANSPORTER.postmark:
output.from = `${container_service_1.Container.configuration.sandbox.from.name} ${container_service_1.Container.configuration.sandbox.from.email}`;
output.to = [].concat(output.to).map((recipient) => {
Expand All @@ -52,6 +46,25 @@ const Debug = (transporter) => {
});
}
break;
case transporter_enum_1.TRANSPORTER.sendgrid:
Object.assign(output, {
mail_settings: {
sandbox_mode: {
enable: true
}
}
});
break;
case transporter_enum_1.TRANSPORTER.sparkpost:
Object.assign(output, {
options: {
sandbox: true
},
content: {
from: container_service_1.Container.configuration.sandbox.to.email
}
});
break;
}
}
return output;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cliam",
"version": "1.0.6",
"version": "1.0.7",
"engines": {
"node": ">=14.16"
},
Expand Down
2 changes: 2 additions & 0 deletions src/transporters/mailgun/mailgun.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { COMPILER } from './../../types/enums/compiler.enum';
* @see https://nodemailer.com/smtp/
* @see https://www.npmjs.com/package/nodemailer-mailgun-transport
* @see https://documentation.mailgun.com/en/latest/index.html
* @see https://documentation.mailgun.com/en/latest/user_manual.html#introduction
*
*/
export class MailgunTransporter extends Transporter implements ITransporter {

Expand Down
56 changes: 42 additions & 14 deletions src/types/decorators/debug.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,31 @@ const Debug = ( transporter: string ): any => {
return ( target: Record<string,({...args}: any)=>any>, key: string ) => {
const method = target[key] as ({...args}: any) => any;
target[key] = function (...args: any[]): any {
const output = method.apply(this, args) as { Message?: {From: { Email: string, Name: string}}, Messages?: Array<{From: { Email: string, Name: string}}>, from?: string, to?: Array<string>, cc?: Array<string>, bcc?: Array<string>, html?: string, text?: string };
const output = method.apply(this, args) as {
Message?: {
From: {
Email: string,
Name: string
}
},
Messages?: Array<{From: { Email: string, Name: string}}>,
from?: string,
to?: Array<string>,
cc?: Array<string>,
bcc?: Array<string>,
html?: string,
text?: string,
options?: { sandbox: boolean },
content?: {
from?: string
}
};
if (output) {
if (Container.configuration?.sandbox?.active) {
switch(transporter) {
case TRANSPORTER.mailgun:
Object.assign(output, { testmode: true })
break;
case TRANSPORTER.mailjet:
Object.assign(output, {
SandboxMode: true,
Expand All @@ -25,15 +46,6 @@ const Debug = ( transporter: string ): any => {
});
output.Messages[0].From = { Email: Container.configuration.sandbox.from.email, Name: Container.configuration.sandbox.from.name };
break;
case TRANSPORTER.sendgrid:
Object.assign(output, {
mail_settings: {
sandbox_mode: {
enable: true
}
}
});
break;
case TRANSPORTER.postmark:
output.from = `${Container.configuration.sandbox.from.name} ${Container.configuration.sandbox.from.email}`;
output.to = [].concat(output.to).map( (recipient) => {
Expand All @@ -50,6 +62,25 @@ const Debug = ( transporter: string ): any => {
});
}
break;
case TRANSPORTER.sendgrid:
Object.assign(output, {
mail_settings: {
sandbox_mode: {
enable: true
}
}
});
break;
case TRANSPORTER.sparkpost:
Object.assign(output, {
options: {
sandbox: true
},
content: {
from: Container.configuration.sandbox.to.email
}
});
break;
}
}
return output;
Expand All @@ -59,7 +90,4 @@ const Debug = ( transporter: string ): any => {
}
}

export { Debug }



export { Debug }
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"**/**/node_modules",
"node_modules"
]
}
}

0 comments on commit 1fb9223

Please sign in to comment.