diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 56145705..0b95d5be 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,6 +12,7 @@ Changelog - Enh #367: Allow message title and body be provided by `GET` request for new messages - Enh #368: Add push notifications when FCM Push Module is active - Fix #371: Don't send notification to deactivated user +- Fix #373: Display full name only when it is configured in general settings 3.1.1 (September 19, 2023) --------------------------- diff --git a/widgets/InboxMessagePreview.php b/widgets/InboxMessagePreview.php index 7f9f0da9..2ae85908 100644 --- a/widgets/InboxMessagePreview.php +++ b/widgets/InboxMessagePreview.php @@ -70,7 +70,12 @@ private function lastParticipant(): ?User private function getUsername(): string { - $profile = $this->lastParticipant()->profile; + $user = $this->lastParticipant(); + $profile = $user->profile; + + if ($profile === null || Yii::$app->settings->get('displayNameFormat') != '{profile.firstname} {profile.lastname}') { + return $user->displayName; + } $lastname = $this->isGroupChat() ? mb_substr($profile->lastname, 0, 1) @@ -107,10 +112,9 @@ private function getMessagePreview(): string } if ($this->isGroupChat()) { - $lastUser = $this->getLastEntry()->user; $prefix = $this->isOwnLastEntry() ? Yii::t('MailModule.base', 'You') - : Html::encode($lastUser->profile->firstname . ' ' . mb_substr($lastUser->profile->lastname, 0, 1)); + : Html::encode($this->getUsername()); $prefix .= ': '; } else { $prefix = '';