Reject adding peer if already exists with the pub key (#925)

This commit is contained in:
Misha Bragin 2023-06-02 17:32:55 +02:00 committed by GitHub
parent b2447cd9a3
commit 612ae253fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -495,6 +495,11 @@ func (am *DefaultAccountManager) AddPeer(setupKey, userID string, peer *Peer) (*
return nil, nil, err
}
_, err = account.FindPeerByPubKey(peer.Key)
if err == nil {
return nil, nil, status.Errorf(status.PreconditionFailed, "peer has been already registered")
}
opEvent := &activity.Event{
Timestamp: time.Now().UTC(),
AccountID: account.Id,