config: re-add displayname template

Fixes #1057
This commit is contained in:
Tulir Asokan
2026-04-03 15:09:18 +03:00
parent 9b92aa3d50
commit cbff082e4d
8 changed files with 73 additions and 47 deletions
+3 -4
View File
@@ -47,7 +47,6 @@ import (
"go.mau.fi/mautrix-telegram/pkg/connector/matrixfmt"
"go.mau.fi/mautrix-telegram/pkg/connector/store"
"go.mau.fi/mautrix-telegram/pkg/connector/telegramfmt"
"go.mau.fi/mautrix-telegram/pkg/connector/util"
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram"
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/auth"
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/updates"
@@ -430,12 +429,12 @@ func (t *TelegramClient) onPing() {
}
}
func userToRemoteProfile(
func (t *TelegramConnector) userToRemoteProfile(
self *tg.User,
ghost *bridgev2.Ghost,
prevState *status.RemoteProfile,
) (profile status.RemoteProfile, name string) {
profile.Name = util.FormatFullName(self.FirstName, self.LastName, self.Deleted, self.ID)
profile.Name = t.Config.FormatDisplayname(self.FirstName, self.LastName, self.Username, self.Deleted, self.ID)
if self.Phone != "" {
profile.Phone = "+" + strings.TrimPrefix(self.Phone, "+")
} else if prevState != nil {
@@ -455,7 +454,7 @@ func userToRemoteProfile(
}
func (t *TelegramClient) updateRemoteProfile(ctx context.Context, self *tg.User, ghost *bridgev2.Ghost) bool {
newProfile, newName := userToRemoteProfile(self, ghost, &t.userLogin.RemoteProfile)
newProfile, newName := t.main.userToRemoteProfile(self, ghost, &t.userLogin.RemoteProfile)
if t.userLogin.RemoteProfile != newProfile || t.userLogin.RemoteName != newName {
t.userLogin.RemoteProfile = newProfile
t.userLogin.RemoteName = newName