Addressing feedback
This commit is contained in:
parent
3e8eed5faf
commit
f87a38074a
|
@ -2,12 +2,15 @@ package protocol
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/status-im/status-go/multiaccounts/settings"
|
||||
"github.com/status-im/status-go/protocol/encryption/multidevice"
|
||||
"github.com/status-im/status-go/protocol/identity"
|
||||
"github.com/status-im/status-go/protocol/identity/alias"
|
||||
"github.com/status-im/status-go/server"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -144,3 +147,30 @@ func (m *Messenger) SetSocialLinks(socialLinks *identity.SocialLinks) error {
|
|||
|
||||
return m.publishContactCode()
|
||||
}
|
||||
|
||||
func (m *Messenger) setInstallationHostname() error {
|
||||
ourInstallation, ok := m.allInstallations.Load(m.installationID)
|
||||
if !ok {
|
||||
m.logger.Error("Messenger's installationID is not set or not loadable")
|
||||
return nil
|
||||
}
|
||||
|
||||
var imd *multidevice.InstallationMetadata
|
||||
if ourInstallation.InstallationMetadata == nil {
|
||||
imd = new(multidevice.InstallationMetadata)
|
||||
} else {
|
||||
imd = ourInstallation.InstallationMetadata
|
||||
}
|
||||
|
||||
// If the name is already set, don't do anything
|
||||
if len(imd.Name) != 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
hn, err := server.GetDeviceName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
imd.Name = fmt.Sprintf("%s %s", hn, imd.Name)
|
||||
return m.setInstallationMetadata(m.installationID, imd)
|
||||
}
|
||||
|
|
|
@ -2,16 +2,13 @@ package protocol
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
gethcommon "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/status-im/status-go/protocol/common"
|
||||
"github.com/status-im/status-go/protocol/encryption/multidevice"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
"github.com/status-im/status-go/server"
|
||||
"github.com/status-im/status-go/services/wallet"
|
||||
)
|
||||
|
||||
|
@ -35,45 +32,6 @@ func (m *Messenger) garbageCollectRemovedSavedAddresses() error {
|
|||
return m.savedAddressesManager.DeleteSoftRemovedSavedAddresses(uint64(time.Now().AddDate(0, 0, -30).Unix()))
|
||||
}
|
||||
|
||||
func (m *Messenger) setInstallationHostname() error {
|
||||
randomDeviceIDLen := 5
|
||||
|
||||
ourInstallation, ok := m.allInstallations.Load(m.installationID)
|
||||
if !ok {
|
||||
m.logger.Error("Messenger's installationID is not set or not loadable")
|
||||
return nil
|
||||
}
|
||||
|
||||
var imd *multidevice.InstallationMetadata
|
||||
if ourInstallation.InstallationMetadata == nil {
|
||||
imd = new(multidevice.InstallationMetadata)
|
||||
} else {
|
||||
imd = ourInstallation.InstallationMetadata
|
||||
}
|
||||
|
||||
// If the name is already set, don't do anything
|
||||
// TODO check the full working mechanics of this
|
||||
if len(imd.Name) > randomDeviceIDLen {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(imd.Name) == 0 {
|
||||
n, err := common.RandomAlphabeticalString(randomDeviceIDLen)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
imd.Name = n
|
||||
}
|
||||
|
||||
hn, err := server.GetDeviceName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
imd.Name = fmt.Sprintf("%s %s", hn, imd.Name)
|
||||
return m.setInstallationMetadata(m.installationID, imd)
|
||||
}
|
||||
|
||||
func (m *Messenger) dispatchSyncSavedAddress(ctx context.Context, syncMessage protobuf.SyncSavedAddress) error {
|
||||
if !m.hasPairedDevices() {
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue