Skip to content

Commit

Permalink
Fix #173: New message creation notification fails
Browse files Browse the repository at this point in the history
  • Loading branch information
luke- committed Mar 28, 2020
1 parent e3d7068 commit dec36aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

1.0.15 - March 28, 2020
-----------------------
- Fix #173: New message creation notification fails


1.0.14 - March 17, 2020
-----------------------
Expand Down
17 changes: 12 additions & 5 deletions models/forms/CreateMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public function save()
return false;
}

if (!$this->informRecipients()) {
$transaction->rollBack();
return false;
}

if(!$this->saveOriginatorUserMessage()) {
$transaction->rollBack();
return false;
Expand All @@ -128,16 +133,18 @@ public function save()

private function saveRecipients()
{
$recepients = [];
// Attach also Recipients
foreach ($this->getRecipients() as $recipient) {
if ($this->messageInstance->addRecepient($recipient)) {
$recepients[] = $recipient;
}
$this->messageInstance->addRecepient($recipient);
}

return true;
}

private function informRecipients() {

// Inform recipients (We need to add all before)
foreach ($recepients as $recipient) {
foreach ($this->getRecipients() as $recipient) {
try {
$this->messageInstance->notify($recipient);
} catch (\Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Mail",
"description": "A private messaging system for direct communication",
"keywords": ["mail", "messaging", "communication"],
"version": "1.0.14",
"version": "1.0.15",
"humhub": {
"minVersion": "1.3.3"
},
Expand Down

0 comments on commit dec36aa

Please sign in to comment.