Skip to content

Commit

Permalink
feat: support blank or missing recipients on API request (per <bitwar…
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Feb 21, 2023
1 parent e46dcc2 commit 9eb5f6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/controllers/web/my-account/validate-alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ function validateAlias(ctx, next) {
);
else body.recipients = [];

if (_.isEmpty(body.recipients)) body.recipients = [ctx.state.user.email];

ctx.state.body = body;

return next();
Expand Down
16 changes: 8 additions & 8 deletions app/views/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,14 @@ curl -X GET BASE_URI/v1/domains/DOMAIN_NAME/aliases \

> `POST /v1/domains/DOMAIN_NAME/aliases`
| Body Parameter | Required | Type | Description |
| ---------------------------- | -------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | No | String | Alias name (if not provided or if blank, then a random alias is generated) |
| `recipients` | Yes | String or Array | List of recipients (must be line-break/space/comma separated String or Array of valid email addresses, fully-qualified domain names ("FQDN"), IP addresses, and/or webhook URL's) |
| `description` | No | String | Alias description |
| `labels` | No | String or Array | List of labels (must be line-break/space/comma separated String or Array) |
| `has_recipient_verification` | No | Boolean | Whether to enable to require recipients to click an email verification link for emails to flow through (defaults to the domain's setting if not explicitly set in the request body) |
| `is_enabled` | No | Boolean | Whether to enable to disable this alias (if disabled, emails will be routed nowhere but return successful status codes) |
| Body Parameter | Required | Type | Description |
| ---------------------------- | -------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | No | String | Alias name (if not provided or if blank, then a random alias is generated) |
| `recipients` | No | String or Array | List of recipients (must be line-break/space/comma separated String or Array of valid email addresses, fully-qualified domain names ("FQDN"), IP addresses, and/or webhook URL's – and if not provided or is an empty Array, then the user's email making the API request will be set as the recipient) |
| `description` | No | String | Alias description |
| `labels` | No | String or Array | List of labels (must be line-break/space/comma separated String or Array) |
| `has_recipient_verification` | No | Boolean | Whether to enable to require recipients to click an email verification link for emails to flow through (defaults to the domain's setting if not explicitly set in the request body) |
| `is_enabled` | No | Boolean | Whether to enable to disable this alias (if disabled, emails will be routed nowhere but return successful status codes) |

> Example Request:
Expand Down

0 comments on commit 9eb5f6a

Please sign in to comment.