Allow setting ens name
This commit is contained in:
parent
ca6246d5f2
commit
54b3689814
|
@ -20,6 +20,8 @@ func (m *Messenger) AddContact(ctx context.Context, request *requests.AddContact
|
|||
|
||||
pubKey := request.ID.String()
|
||||
|
||||
ensName := request.ENSName
|
||||
|
||||
contact, ok := m.allContacts.Load(pubKey)
|
||||
if !ok {
|
||||
var err error
|
||||
|
@ -29,6 +31,14 @@ func (m *Messenger) AddContact(ctx context.Context, request *requests.AddContact
|
|||
}
|
||||
}
|
||||
|
||||
if ensName != "" {
|
||||
clock := m.getTimesource().GetCurrentTime()
|
||||
err := m.ensVerifier.ENSVerified(pubKey, ensName, clock)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if err := m.addENSNameToContact(contact); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -87,12 +97,12 @@ func (m *Messenger) AddContact(ctx context.Context, request *requests.AddContact
|
|||
}
|
||||
m.scheduleSyncFilter(filter)
|
||||
|
||||
// Finally we send a contact update so they are notified we added them
|
||||
ensName, err := m.settings.ENSName()
|
||||
ensName, err = m.settings.ENSName()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Finally we send a contact update so they are notified we added them
|
||||
response, err := m.sendContactUpdate(context.Background(), pubKey, ensName, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -11,6 +11,7 @@ var ErrAddContactInvalidID = errors.New("add-contact: invalid id")
|
|||
type AddContact struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
ENSName string `json:"ensName"`
|
||||
}
|
||||
|
||||
func (a *AddContact) Validate() error {
|
||||
|
|
Loading…
Reference in New Issue