(users []*common.User)
| 307 | } |
| 308 | |
| 309 | func normalizeUsers(users []*common.User) []*common.User { |
| 310 | lastByEmail := make(map[string]*common.User, len(users)) |
| 311 | |
| 312 | for _, user := range users { |
| 313 | switch { |
| 314 | case user == nil, |
| 315 | user.GetEmail() == "", |
| 316 | user.GetProxies() == nil, |
| 317 | user.GetProxies().GetWireguard() == nil, |
| 318 | user.GetProxies().GetWireguard().GetPublicKey() == "", |
| 319 | len(user.GetProxies().GetWireguard().GetPeerIps()) == 0: |
| 320 | continue |
| 321 | } |
| 322 | lastByEmail[user.GetEmail()] = user |
| 323 | } |
| 324 | |
| 325 | normalized := make([]*common.User, 0, len(lastByEmail)) |
| 326 | for _, user := range lastByEmail { |
| 327 | normalized = append(normalized, user) |
| 328 | } |
| 329 | |
| 330 | return normalized |
| 331 | } |
no test coverage detected