Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed Jan 16, 2023
2 parents 4faf790 + b53fcb7 commit 7c15f74
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 23 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
POSTMARK_API_KEY=
MAILGUN_API_KEY=
MAILGUN_DOMAIN=
MAILGUN_BASEURL=
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3.2.0
with:
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v3.9.0
with:
distribution: "adopt"
distribution: "temurin"
java-version: "11"

- name: Cache CommandBox Dependencies
uses: actions/cache@v1
uses: actions/cache@v3
if: ${{ true }}
with:
path: ~/.CommandBox/artifacts
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Upload Build Artifacts
if: success()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3.1.1
with:
name: ${{ env.MODULE_ID }}
path: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: taiki-e/create-gh-release-action@v1.5.0
- uses: actions/checkout@v3.2.0
- uses: taiki-e/create-gh-release-action@v1.6.1
with:
# Produced by the build/Build.cfc
changelog: changelog.md
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3.2.0

- uses: Ortus-Solutions/[email protected]
with:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ jobs:
cfengine: [ "lucee@5", "adobe@2018", "adobe@2021" ]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3.2.0

- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v3.9.0
with:
distribution: "adopt"
distribution: "temurin"
java-version: "11"

- name: Setup CommandBox CLI
uses: Ortus-Solutions/[email protected]

- name: Cache CommandBox Dependencies
uses: actions/cache@v1
uses: actions/cache@v3
if: ${{ true }}
with:
path: ~/.CommandBox/artifacts
Expand Down Expand Up @@ -67,15 +67,15 @@ jobs:
box testbox run --verbose outputFile=test-harness/tests/results/test-results outputFormats=json,antjunit
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: test-harness/tests/results/**/*.xml
junit_files: test-harness/tests/results/**/*.xml
check_name: "${{ matrix.cfengine }} Test Results"

- name: Upload Test Results to Artifacts
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3.1.1
with:
name: test-results-${{ matrix.cfengine }}
path: |
Expand All @@ -90,7 +90,7 @@ jobs:
- name: Upload Debug Logs To Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3.1.1
with:
name: Failure Debugging Info - ${{ matrix.cfengine }}
path: |
Expand Down
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"ColdBox Mail Services",
"version":"2.6.2",
"version":"2.7.0",
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbmailservices/@build.version@/[email protected]@.zip",
"author":"Ortus Solutions.com <[email protected]",
"slug":"cbmailservices",
Expand Down
23 changes: 23 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
----


## [v2.7.0] => 2023-JAN-16

A big thanks to @richardherbert for all the updates in this release.

### Fixed

* FIXED var scoping of attachments variable
* Updated to handle a response that is not JSON
* 🐛 FIX: Update GHA to avoid deprecated syntax

### Added

* Added test for MAILGUN_BASEURL property
* Updated to make MAILGUN_APIURL optional
* Added support for Mailgun EU region by making MAILGUN_APIURL an optional property with https://api.mailgun.net/v3/ as the default.

### Changed

* Updated all GHA actions to latest versions and moved to use `temurin` Java distributions from adopt due to deprecation of the service.

----


## [v2.6.2] => 2022-DEC-20

### Fixed
Expand Down
23 changes: 20 additions & 3 deletions models/protocols/MailgunProtocol.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* - apikey : The mailgun secret api key
* - domain : The mailgun domain to send the email through
*
* An optional property, "baseURL" is required when using an EU region
* - baseURL : The mailgun region where the Mailgun domain was created
*
* @author Scott Steinbeck <[email protected]>
*/
component
Expand All @@ -24,7 +27,6 @@ component
MailgunProtocol function init( struct properties = {} ){
variables.name = "Mailgun";
variables.DEFAULT_TIMEOUT = 30; // in seconds
variables.MAILGUN_APIURL = "https://api.mailgun.net/v3/";
// super size it
super.init( argumentCollection = arguments );

Expand All @@ -40,6 +42,14 @@ component
throw( message = "ApiKey is Required", type = "MailgunProtocol.PropertyNotFound" );
}

// Check for Base URL property
if ( !propertyExists( "baseURL" ) ) {
// No baseURL key was found, so use the US default.
variables.MAILGUN_APIURL = "https://api.mailgun.net/v3/";
} else {
variables.MAILGUN_APIURL = getProperty( "baseURL" );
}

return this;
}

Expand Down Expand Up @@ -101,7 +111,7 @@ component
data.delete( "bodyTokens" ); // cleanup payload

// Process the mail attachments and encode them how mailgun likes them
attachments = arguments.payload
var attachments = arguments.payload
.getMailParams()
.filter( function( thisParam ){
return structKeyExists( arguments.thisParam, "file" );
Expand Down Expand Up @@ -185,7 +195,14 @@ component
}

// Inflate HTTP Results
var mailgunResults = deserializeJSON( httpResults.fileContent.toString() );
if( isJSON( httpResults.fileContent.toString() ) ) {
var mailgunResults = deserializeJSON( httpResults.fileContent.toString() );
} else {
results.messages = [ 'Error sending mail. Mailgun returned "#httpResults.fileContent.toString()#".' ];

return results;
}

// Process Mailgun Results
if ( mailgunResults.message eq "Queued. Thank you." ) {
results.error = false;
Expand Down
9 changes: 6 additions & 3 deletions test-harness/tests/specs/protocols/MailgunProtocolTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ component extends="coldbox.system.testing.BaseTestCase" {
variables.mailservice = getInstance( "MailService@cbmailservices" );
variables.apikey = getUtil().getSystemSetting( "MAILGUN_API_KEY", "MAILGUN_API_KEY" );
variables.domain = getUtil().getSystemSetting( "MAILGUN_DOMAIN", "MAILGUN_DOMAIN" );
variables.baseURL = getUtil().getSystemSetting( "MAILGUN_BASEURL", "MAILGUN_BASEURL" );
}

/*********************************** BDD SUITES ***********************************/
Expand All @@ -23,15 +24,17 @@ component extends="coldbox.system.testing.BaseTestCase" {
describe( "Mailgun Protocol", function(){
beforeEach( function( currentSpec ){
// Create a mock instance of the protocol.
variables.protocol = createMock( "cbmailservices.models.protocols.MailgunProtocol" ).init( {
apiKey : variables.apikey,
domain : variables.domain
variables.protocol = createMock( "cbmailservices.models.protocols.MailgunProtocol" ).init( {
apiKey : variables.apikey,
domain : variables.domain,
baseURL : variables.baseURL
} );
} );

it( "can be inited correctly", function(){
expect( variables.protocol.propertyExists( "apiKey" ) ).toBeTrue();
expect( variables.protocol.propertyExists( "domain" ) ).toBeTrue();
expect( variables.protocol.propertyExists( "baseURL" ) ).toBeTrue();
} );

it( "data is formatted for sending to mailgun", function(){
Expand Down

0 comments on commit 7c15f74

Please sign in to comment.