Skip to content

Commit

Permalink
syncing up to 1cfe8fc3169b9728b7e0150e0edaecc390f65317
Browse files Browse the repository at this point in the history
Co-authored-by: Joey Greco <[email protected]>
  • Loading branch information
superblocksadmin and joeyagreco committed Oct 30, 2024
1 parent e421359 commit 41a3cae
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Include signing algorithms with verification keys when registering agent
- Include signing algorithm and public key in response from Sign endpoint (`/v1/signature/sign`)
- Set errors on responses for all resources that fail to get re-signed during a signature rotation job
- Improved error messages in Email Plugin

## v1.15.1

Expand Down
69 changes: 67 additions & 2 deletions postman/collection.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"info": {
"_postman_id": "ff2052f4-9acc-4efe-8b1c-e8616d464336",
"_postman_id": "5435b4bc-a466-4819-a943-1c14adbfdb6c",
"name": "collection.json - [HTTP] Superblocks Orchestrator",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "28659047"
"_exporter_id": "25579613"
},
"item": [
{
Expand Down Expand Up @@ -13325,6 +13325,71 @@
]
}
]
},
{
"name": "email",
"item": [
{
"name": "execute",
"item": [
{
"name": "no api key",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const response = pm.response.json();",
"",
"pm.test(\"assert response body\", () => {",
" pm.expect(response.execution.length).to.gt(0);",
" pm.expect(response.status).to.be.eql(\"STATUS_COMPLETED\");",
" pm.expect(response.errors).to.eql([{",
" \"name\": \"IntegrationError\",",
" \"message\": \"Payment required. Email isn't available for your organization's plan. Upgrade your account or [contact sales](mailto://[email protected]) to use this feature.\",",
" \"blockPath\": \"put\"",
" }])",
"});",
"",
"pm.test(\"assert status\", () => {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"options\": {\n \"include_events\": false\n },\n \"definition\": {\n \"api\": {\n \"metadata\": {\n \"name\": \"s3 integration test\",\n \"organization\": \"00000000-0000-0000-0000-000000000001\"\n },\n \"blocks\": [\n {\n \"name\": \"put\",\n \"step\": {\n \"integration\": \"email-i\",\n \"email\": {\n \"emailTo\": \"[email protected]\",\n \"emailSubject\": \"bar\"\n }\n }\n }\n ]\n },\n \"integrations\": {\n \"email-i\": {\n \"authentication\": {\n \"custom\": {\n \"apiKey\": {\n \"value\": \"\"\n },\n \"senderEmail\": {\n \"value\": \"foo\"\n },\n \"senderName\": {\n \"value\": \"bar\"\n }\n }\n }\n }\n }\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{orchestrator_scheme}}://{{orchestrator_host}}:{{orchestrator_port}}/v2/execute",
"protocol": "{{orchestrator_scheme}}",
"host": [
"{{orchestrator_host}}"
],
"port": "{{orchestrator_port}}",
"path": [
"v2",
"execute"
]
}
},
"response": []
}
]
}
]
}
]
},
Expand Down
5 changes: 4 additions & 1 deletion workers/javascript/packages/plugins/email/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ export default class EmailPlugin extends BasePlugin {

createClient(datasourceConfiguration: EmailDatasourceConfiguration): MailService {
const key = datasourceConfiguration.authentication?.custom?.apiKey?.value ?? '';
// NOTE: (joey) the api key will be empty when an organization is not allowed to use this plugin
if (isEmpty(key)) {
throw new IntegrationError(`No API key found`, ErrorCode.INTEGRATION_MISSING_REQUIRED_FIELD, { pluginName: this.pluginName });
const errorMsg =
"Payment required. Email isn't available for your organization's plan. Upgrade your account or [contact sales](mailto://[email protected]) to use this feature.";
throw new IntegrationError(errorMsg, ErrorCode.INTEGRATION_MISSING_REQUIRED_FIELD, { pluginName: this.pluginName });
}

sgMail.setApiKey(key);
Expand Down

0 comments on commit 41a3cae

Please sign in to comment.