()
| 659 | } |
| 660 | |
| 661 | func GetUniqueUserId() int { |
| 662 | |
| 663 | // if highestUserId is zero, loop through users and get real highest. |
| 664 | |
| 665 | highestUserId := 0 |
| 666 | |
| 667 | idx := GetUserIndex() |
| 668 | if idx.Exists() { |
| 669 | |
| 670 | highestUserId = idx.GetHighestUserId() |
| 671 | |
| 672 | } else { |
| 673 | |
| 674 | // Check all user id's of offline users |
| 675 | SearchOfflineUsers(func(u *UserRecord) bool { |
| 676 | |
| 677 | if u.UserId > highestUserId { |
| 678 | highestUserId = u.UserId |
| 679 | } |
| 680 | |
| 681 | return true |
| 682 | }) |
| 683 | |
| 684 | // Check all user id's of online users |
| 685 | for _, u := range GetAllActiveUsers() { |
| 686 | if u.UserId > highestUserId { |
| 687 | highestUserId = u.UserId |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | } |
| 692 | |
| 693 | // Increment the highestUserId before returning a new one |
| 694 | highestUserId += 1 |
| 695 | |
| 696 | return highestUserId |
| 697 | } |
| 698 | |
| 699 | // DeleteUser permanently removes a user record, their YAML file, and all index |
| 700 | // entries. It refuses to delete a user that is currently online. |
no test coverage detected