Use SETNAME when updating user-wide realname

This commit is contained in:
Simon Ser 2022-03-30 15:11:25 +02:00
parent d7b5f5d12c
commit a45f9c3274
1 changed files with 14 additions and 2 deletions

16
user.go
View File

@ -1018,9 +1018,21 @@ func (u *user) updateUser(ctx context.Context, record *User) error {
// Re-connect to networks which use the default realname
var needUpdate []Network
for _, net := range u.networks {
if net.Realname == "" {
needUpdate = append(needUpdate, net.Network)
if net.Realname != "" {
continue
}
// We only need to call updateNetwork for upstreams that don't
// support setname
if uc := net.conn; uc != nil && uc.caps.IsEnabled("setname") {
uc.SendMessage(ctx, &irc.Message{
Command: "SETNAME",
Params: []string{GetRealname(&u.User, &net.Network)},
})
continue
}
needUpdate = append(needUpdate, net.Network)
}
var netErr error