Skip to content
Snippets Groups Projects
Commit dde8285e authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

Merge branch 'hotfix/return-raw-username' into 'release'

Search & lookup should return users.username

See merge request elixxir/user-discovery-bot!44
parents c601af6e 83fa19a4
No related branches found
No related tags found
3 merge requests!50Revert "update deps",!48Release,!44Search & lookup should return users.username
...@@ -60,7 +60,7 @@ func (m *Manager) handleLookup(msg *ud.LookupSend, c single.Contact) *ud.LookupR ...@@ -60,7 +60,7 @@ func (m *Manager) handleLookup(msg *ud.LookupSend, c single.Contact) *ud.LookupR
return response return response
} }
if len(usr.Facts) > 0 && usr.Facts[0].Type == uint8(fact.Username) { if len(usr.Facts) > 0 && usr.Facts[0].Type == uint8(fact.Username) {
response.Username = usr.Facts[0].Fact response.Username = usr.Username
} }
response.PubKey = usr.DhPub response.PubKey = usr.DhPub
......
...@@ -67,12 +67,13 @@ func TestManager_handleLookup(t *testing.T) { ...@@ -67,12 +67,13 @@ func TestManager_handleLookup(t *testing.T) {
uid := id.NewIdFromString("zezima", id.User, t) uid := id.NewIdFromString("zezima", id.User, t)
c := single.NewContact(uid, &cyclic.Int{}, &cyclic.Int{}, singleUse.TagFP{}, 8) c := single.NewContact(uid, &cyclic.Int{}, &cyclic.Int{}, singleUse.TagFP{}, 8)
username := "ZeZima"
expectedDhPub := "DhPub" expectedDhPub := "DhPub"
err := m.db.InsertUser(&storage.User{Id: uid.Marshal(), DhPub: []byte(expectedDhPub), Facts: []storage.Fact{ err := m.db.InsertUser(&storage.User{Id: uid.Marshal(), DhPub: []byte(expectedDhPub), Username: username, Facts: []storage.Fact{
{ {
Hash: []byte("hash"), Hash: []byte("hash"),
UserId: uid.Marshal(), UserId: uid.Marshal(),
Fact: "zezima", Fact: strings.ToLower(username),
Type: 0, Type: 0,
Signature: []byte("Signature"), Signature: []byte("Signature"),
Verified: true, Verified: true,
...@@ -92,8 +93,8 @@ func TestManager_handleLookup(t *testing.T) { ...@@ -92,8 +93,8 @@ func TestManager_handleLookup(t *testing.T) {
"\nexpected: %s\nreceived: %s", expectedDhPub, resp.Error) "\nexpected: %s\nreceived: %s", expectedDhPub, resp.Error)
} }
if resp.Username != "zezima" { if resp.Username != username {
t.Errorf("Should have gotten username zezima, instead got: %s", resp.Username) t.Errorf("Should have gotten username %s, instead got: %s", username, resp.Username)
} }
} }
......
...@@ -78,7 +78,7 @@ func (m *Manager) handleSearch(msg *ud.SearchSend, c single.Contact) *ud.SearchR ...@@ -78,7 +78,7 @@ func (m *Manager) handleSearch(msg *ud.SearchSend, c single.Contact) *ud.SearchR
var uFacts []*ud.HashFact var uFacts []*ud.HashFact
for _, f := range u.Facts { for _, f := range u.Facts {
if f.Type == uint8(fact.Username) { if f.Type == uint8(fact.Username) {
contact.Username = f.Fact contact.Username = u.Username
} }
uFacts = append(uFacts, &ud.HashFact{ uFacts = append(uFacts, &ud.HashFact{
Hash: f.Hash, Hash: f.Hash,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment