Skip to content

Commit e58ed9a

Browse files
authored
Merge pull request #19 from RhubarbPHP/fix/EnsureRecipientReturned
fix: Ensure recipient is returned with the Sendable
2 parents a19be1b + ec03582 commit e58ed9a

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
### 1.2.4
4+
5+
* Fixed CommunicationItem `getSendable()` to include the recipient on the `Sendable`.
6+
* Removed duplicate `FailureReason` field from CommunicationItem
7+
* Changed `FailureReason` to LongStringColumn in CommunicationItemSendAttempt to ensure full message logged.
8+
39
### 1.2.3
410

511
* Fixed: Mysql 5.6 support by optionally not using native json columns

src/Models/CommunicationItem.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
namespace Rhubarb\Scaffolds\Communications\Models;
44

55
use Rhubarb\Crown\DateTime\RhubarbDateTime;
6-
use Rhubarb\Crown\Sendables\Email\Email;
6+
use Rhubarb\Crown\Sendables\Email\EmailRecipient;
7+
use Rhubarb\Crown\Sendables\Sendable;
78
use Rhubarb\Scaffolds\Communications\Settings\CommunicationsSettings;
89
use Rhubarb\Stem\Filters\AndGroup;
910
use Rhubarb\Stem\Filters\Equals;
1011
use Rhubarb\Stem\Models\Model;
1112
use Rhubarb\Stem\Repositories\MySql\Schema\Columns\MySqlEnumColumn;
1213
use Rhubarb\Stem\Repositories\MySql\Schema\Columns\MySqlJsonColumn;
1314
use Rhubarb\Stem\Schema\Columns\AutoIncrementColumn;
14-
use Rhubarb\Stem\Schema\Columns\BooleanColumn;
1515
use Rhubarb\Stem\Schema\Columns\DateTimeColumn;
1616
use Rhubarb\Stem\Schema\Columns\ForeignKeyColumn;
1717
use Rhubarb\Stem\Schema\Columns\LongStringColumn;
@@ -59,7 +59,6 @@ protected function createSchema()
5959
new MySqlJsonColumn("Data", "", true, CommunicationsSettings::singleton()->nativeJSONColumns),
6060
new DateTimeColumn("DateCreated"),
6161
new DateTimeColumn("DateSent"),
62-
new StringColumn("FailureReason", 500),
6362
new StringColumn("ProviderMessageID", 200),
6463
new StringColumn("ProviderStatus", 50),
6564
new DateTimeColumn("ProviderStatusChangeTime")
@@ -108,13 +107,17 @@ protected function beforeSave()
108107
}
109108

110109
/**
111-
* @return Email
110+
* @return Sendable
111+
* @throws \Rhubarb\Crown\Exceptions\EmailException
112112
*/
113113
public function getSendable()
114114
{
115115
$className = $this->SendableClassName;
116116

117-
return $className::fromArray($this->Data);
117+
/** @var Sendable $sendable */
118+
$sendable = $className::fromArray($this->Data);
119+
$sendable->addRecipient(new EmailRecipient($this->Recipient));
120+
return $sendable;
118121
}
119122

120123
public function addAttachment($path, $newName = "")

src/Models/CommunicationItemSendAttempt.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Rhubarb\Stem\Schema\Columns\DateTimeColumn;
1010
use Rhubarb\Stem\Schema\Columns\ForeignKeyColumn;
1111
use Rhubarb\Stem\Schema\Columns\IntegerColumn;
12+
use Rhubarb\Stem\Schema\Columns\LongStringColumn;
1213
use Rhubarb\Stem\Schema\Columns\StringColumn;
1314
use Rhubarb\Stem\Schema\ModelSchema;
1415

@@ -28,7 +29,7 @@ protected function createSchema()
2829
new DateTimeColumn("DateSent"),
2930
new IntegerColumn("SystemProcessID"),
3031
new MySqlEnumColumn("Status", self::STATUS_NOT_SENT, [self::STATUS_NOT_SENT, self::STATUS_SUCCESS, self::STATUS_FAILED]),
31-
new StringColumn("FailureReason", 500),
32+
new LongStringColumn("FailureReason"),
3233
new StringColumn("ProviderMessageID", 200)
3334
);
3435

@@ -39,7 +40,7 @@ protected function beforeSave()
3940
{
4041
parent::beforeSave();
4142

42-
if ($this->isNewRecord()){
43+
if ($this->isNewRecord()) {
4344
$this->SystemProcessID = getmypid();
4445
$this->DateSent = new RhubarbDateTime("now");
4546
}

0 commit comments

Comments
 (0)