Skip to content

Commit

Permalink
Drop server/homeserver/host for users on the same server (local)
Browse files Browse the repository at this point in the history
  • Loading branch information
hloeung committed Feb 25, 2024
1 parent 358e5b8 commit c959f3e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions bridge/matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,26 +719,30 @@ func (m *Matrix) createUser(userID id.UserID) *bridge.UserInfo {
me = true
}

nick, host, err := userID.Parse()
localpart, homeserver, err := userID.Parse()
if err != nil {
return nil
}

displayName := nick + "@" + host

m.RLock()

displayName := localpart + "@" + homeserver
if user, ok := m.users[userID]; ok {
displayName = user.Displayname
}

m.RUnlock()

// Drop the homeserver/host part if it's a user on the same homeserver as us.
nick := localpart + "@" + homeserver
myUser := strings.Split(m.mc.UserID.String(), ":")
if homeserver == myUser[1] {
nick = localpart
}

info := &bridge.UserInfo{
Nick: nick + "@" + host,
User: userID.String(),
Nick: nick,
User: "~" + localpart,
Real: displayName,
Host: host,
Host: homeserver,
// Roles: mmuser.Roles,
Ghost: true,
Me: me,
Expand Down

0 comments on commit c959f3e

Please sign in to comment.