Return error when peer is not valid (#1573)

Fix count with invalid peers
This commit is contained in:
Maycon Santos
2024-02-13 10:59:31 +01:00
committed by GitHub
parent dd14db6478
commit e890fdae54
2 changed files with 13 additions and 4 deletions

View File

@@ -115,6 +115,13 @@ func (am *DefaultAccountManager) SaveGroup(accountID, userID string, newGroup *G
if err != nil {
return err
}
for _, peerID := range newGroup.Peers {
if account.Peers[peerID] == nil {
return status.Errorf(status.InvalidArgument, "peer with ID \"%s\" not found", peerID)
}
}
oldGroup, exists := account.Groups[newGroup.ID]
account.Groups[newGroup.ID] = newGroup