Skip to content

Commit

Permalink
Return successful response if contact not found
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed May 24, 2023
1 parent e34e249 commit bb7cc6b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Release Notes for Campaign

## 2.7.1 - Unreleased
## 2.7.1 - 2023-05-24
### Changed
- Sendout previews now include template variables for the current sendout as well as a dummy contact ([#386](https://github.com/putyourlightson/craft-campaign/issues/386)).
- Webhooks now return a successful response when receiving the email address of a contact that does not exist ([#388](https://github.com/putyourlightson/craft-campaign/issues/388)).

## 2.7.0 - 2023-05-13
### Added
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private function _callWebhook(string $event, string $email = null): Response
$contact = Campaign::$plugin->contacts->getContactByEmail($email);

if ($contact === null) {
return $this->_asRawFailure('Contact not found.');
return $this->_asRawSuccess();
}

if ($event == 'complained') {
Expand All @@ -325,6 +325,8 @@ private function _asRawSuccess(string $message = ''): Response
*/
private function _asRawFailure(string $message = ''): Response
{
Campaign::$plugin->log($message, [], Logger::LEVEL_WARNING);

return $this->asRaw(Craft::t('campaign', $message))
->setStatusCode(400);
}
Expand Down
1 change: 1 addition & 0 deletions src/models/SettingsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SettingsModel extends Model

/**
* @var array|null The allowed IP addresses for incoming webhook requests from Postmark
* @link https://postmarkapp.com/support/article/800-ips-for-firewalls#webhooks
* @since 1.19.0
*/
public ?array $postmarkAllowedIpAddresses = [
Expand Down

0 comments on commit bb7cc6b

Please sign in to comment.