Skip to content

Commit 99eff04

Browse files
committed
Fix #388: Notification not sent to the participant added to the conversion
1 parent b22b338 commit 99eff04

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

docs/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Unreleased
55
----------------------
66
- Enh #382: Implement provider for meta searching
77
- Enh #188: Add "Like" to message entries
8+
- Fix #388: Notification not sent to the participant added to the conversion
89

910
3.2.1 (April 15, 2024)
1011
----------------------

models/Message.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public function getLastEntry(): ?MessageEntry
189189
if ($this->_lastEntry === null) {
190190
$this->_lastEntry = MessageEntry::find()
191191
->where(['message_id' => $this->id])
192+
->andWhere(['not', ['entry_content' => null]])
192193
->orderBy('created_at DESC')
193194
->limit(1)
194195
->one();
@@ -229,7 +230,7 @@ public function getLastActiveParticipant(bool $includeMe = false): User
229230
public function deleteEntry($entry)
230231
{
231232
if ($entry->message->id == $this->id) {
232-
if($this->getEntries()->count() > 1) {
233+
if ($this->getEntries()->count() > 1) {
233234
$entry->delete();
234235
} else {
235236
$this->delete();

models/forms/InviteParticipantForm.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace humhub\modules\mail\models\forms;
44

5+
use humhub\modules\mail\helpers\Url;
56
use humhub\modules\mail\models\Message;
67
use humhub\modules\mail\models\MessageNotification;
78
use humhub\modules\mail\models\UserMessage;
9+
use humhub\modules\mail\permissions\SendMail;
10+
use humhub\modules\user\models\User;
811
use Yii;
912
use yii\base\Model;
10-
use humhub\modules\user\models\User;
11-
use humhub\modules\mail\permissions\SendMail;
1213
use yii\helpers\Html;
13-
use humhub\modules\mail\helpers\Url;
1414

1515
/**
1616
* @package humhub.modules.mail.forms
@@ -72,9 +72,9 @@ public function checkRecipient($attribute, $params)
7272
$name = Html::encode($user->getDisplayName());
7373
if (Yii::$app->user->identity->is($user)) {
7474
$this->addError($attribute, Yii::t('MailModule.forms_InviteRecipientForm', "You cannot send a email to yourself!"));
75-
} else if($this->message->isParticipant($user)) {
75+
} else if ($this->message->isParticipant($user)) {
7676
$this->addError($attribute, Yii::t('MailModule.forms_InviteRecipientForm', "User {name} is already participating!", ['name' => $name]));
77-
} else if(!$user->can(SendMail::class) && !Yii::$app->user->isAdmin()){
77+
} else if (!$user->can(SendMail::class) && !Yii::$app->user->isAdmin()) {
7878
$this->addError($attribute, Yii::t('MailModule.forms_InviteRecipientForm', "You are not allowed to send user {name} is already!", ['name' => $name]));
7979
} else {
8080
$this->recipientUsers[] = $user;
@@ -95,7 +95,7 @@ public function getUrl()
9595

9696
public function save()
9797
{
98-
if(!$this->validate()) {
98+
if (!$this->validate()) {
9999
return false;
100100
}
101101

@@ -106,7 +106,7 @@ public function save()
106106
'is_originator' => 0
107107
]);
108108

109-
if($userMessage->save()) {
109+
if ($userMessage->save()) {
110110
(new MessageNotification($this->message))->notify($user);
111111
}
112112
}

widgets/InboxMessagePreview.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private function getMessageTime(): string
155155

156156
public function getLastEntry(): ?MessageEntry
157157
{
158-
return $this->getMessage()->getLastEntry();
158+
return $this->getMessage()->lastEntry;
159159
}
160160

161161
private function isGroupChat(): bool

0 commit comments

Comments
 (0)