Skip to content

Commit

Permalink
1.16.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Croker committed Oct 7, 2020
1 parent 7562b2b commit b2c6e46
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Campaign

## 1.16.2 - 2020-10-07
### Fixed
- Fixed a bug in which links could be invalidly created if using Craft CMS 3.5.12 or above ([#180](https://github.com/putyourlightson/craft-campaign/issues/180)).

## 1.16.1 - 2020-10-07
### Fixed
- Fixed a bug in which campaign and mailing list reports were throwing errors ([#179](https://github.com/putyourlightson/craft-campaign/issues/179)).
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "putyourlightson/craft-campaign",
"description": "Send and manage email campaigns, contacts and mailing lists.",
"version": "1.16.1",
"version": "1.16.2",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/campaign",
"license": "proprietary",
Expand Down
4 changes: 2 additions & 2 deletions src/services/SendoutsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ private function _convertLinks(string $body, ContactElement $contact, SendoutEle
{
// Get base URL
$path = Craft::$app->getConfig()->getGeneral()->actionTrigger.'/campaign/t/click';
$baseUrl = UrlHelper::siteUrl($path, ['cid' => $contact->cid, 'sid' => $sendout->sid, 'lid' => '']);
$baseUrl = UrlHelper::siteUrl($path, ['cid' => $contact->cid, 'sid' => $sendout->sid]);

// Use DOMDocument to parse links
$dom = new DOMDocument();
Expand Down Expand Up @@ -795,7 +795,7 @@ private function _convertLinks(string $body, ContactElement $contact, SendoutEle
$lid = $this->_links[$key];

// Replace href attribute
$element->setAttribute('href', $baseUrl.$lid);
$element->setAttribute('href', $baseUrl.'&lid='.$lid);
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/_craft/templates/html.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
HTML email

<a href="http://link.com">Link</a>
11 changes: 10 additions & 1 deletion tests/unit/services/SendoutsServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,17 @@ public function testSendEmailSent()
// Assert that the message subject is correct
$this->assertEquals($this->sendout->subject, $this->message->getSubject());

// Get the message body, removing email body nastiness
$body = $this->message->getSwiftMessage()->toString();
$body = str_replace(['3D', "=\r\n"], '', $body);

// Assert that the message body contains a link with the correct IDs
$this->assertStringContainsStringIgnoringCase('&amp;cid='.$this->contact->cid, $body);
$this->assertStringContainsStringIgnoringCase('&amp;sid='.$this->sendout->sid, $body);
$this->assertStringContainsStringIgnoringCase('&amp;lid=', $body);

// Assert that the message body contains the tracking image
$this->assertStringContainsStringIgnoringCase('campaign/t/open', $this->message->getSwiftMessage()->toString());
$this->assertStringContainsStringIgnoringCase('campaign/t/open', $body);
}

public function testSendEmailFailed()
Expand Down

0 comments on commit b2c6e46

Please sign in to comment.