Skip to content

Commit

Permalink
Display full name only when it is configured in general settings
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Jan 22, 2024
1 parent 9a72dce commit d158017
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
---------------------------
Expand Down
10 changes: 7 additions & 3 deletions widgets/InboxMessagePreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = '';
Expand Down

0 comments on commit d158017

Please sign in to comment.