Skip to content

Commit

Permalink
disable in go
Browse files Browse the repository at this point in the history
  • Loading branch information
buoyad committed Sep 17, 2019
1 parent 10d8c2a commit f1e531b
Showing 1 changed file with 48 additions and 50 deletions.
98 changes: 48 additions & 50 deletions go/contacts/phonebook.go
Expand Up @@ -71,58 +71,56 @@ type assertionToNameCache struct {
const assertionToNameCurrentVer = 1

func ResolveAndSaveContacts(mctx libkb.MetaContext, provider ContactsProvider, contacts []keybase1.Contact) (newlyResolved []keybase1.ProcessedContact, err error) {
resolveResults, err := ResolveContacts(mctx, provider, contacts, keybase1.RegionCode(""))
if err != nil {
return nil, err
}
_, err = ResolveContacts(mctx, provider, contacts, keybase1.RegionCode(""))
return nil, err

// find newly resolved
s := mctx.G().SyncedContactList
currentContacts, err := s.RetrieveContacts(mctx)

newlyResolvedMap := make(map[string]keybase1.ProcessedContact)
if err == nil {
unres := make(map[string]struct{})
for _, contact := range currentContacts {
if !contact.Resolved {
// We resolve based on display name, not assertion, so we don't
// duplicate multiple assertions for the same contact.
unres[contact.ContactName] = struct{}{}
}
}

for _, resolution := range resolveResults {
if _, wasUnresolved := unres[resolution.ContactName]; wasUnresolved && resolution.Resolved {
// We only want to show one resolution per username.
newlyResolvedMap[resolution.Username] = resolution
}
}
} else {
mctx.Warning("error retrieving synced contacts; continuing: %s", err)
}

if len(newlyResolvedMap) == 0 {
return newlyResolved, s.SaveProcessedContacts(mctx, resolveResults)
}

resolutionsForPeoplePage := make([]ContactResolution, 0, len(newlyResolvedMap))
for _, contact := range newlyResolvedMap {
resolutionsForPeoplePage = append(resolutionsForPeoplePage, ContactResolution{
Description: fmt.Sprintf("%s — %s", contact.ContactName,
contact.Component.ValueString()),
ResolvedUser: keybase1.User{
Uid: contact.Uid,
Username: contact.Username,
},
})
newlyResolved = append(newlyResolved, contact)
}
err = SendEncryptedContactResolutionToServer(mctx, resolutionsForPeoplePage)
if err != nil {
mctx.Warning("Could not add resolved contacts to people page: %v; returning contacts anyway", err)
}

return newlyResolved, s.SaveProcessedContacts(mctx, resolveResults)
// s := mctx.G().SyncedContactList
// currentContacts, err := s.RetrieveContacts(mctx)

// newlyResolvedMap := make(map[string]keybase1.ProcessedContact)
// if err == nil {
// unres := make(map[string]struct{})
// for _, contact := range currentContacts {
// if !contact.Resolved {
// // We resolve based on display name, not assertion, so we don't
// // duplicate multiple assertions for the same contact.
// unres[contact.ContactName] = struct{}{}
// }
// }

// for _, resolution := range resolveResults {
// if _, wasUnresolved := unres[resolution.ContactName]; wasUnresolved && resolution.Resolved {
// // We only want to show one resolution per username.
// newlyResolvedMap[resolution.Username] = resolution
// }
// }
// } else {
// mctx.Warning("error retrieving synced contacts; continuing: %s", err)
// }

// if len(newlyResolvedMap) == 0 {
// return newlyResolved, s.SaveProcessedContacts(mctx, resolveResults)
// }

// resolutionsForPeoplePage := make([]ContactResolution, 0, len(newlyResolvedMap))
// for _, contact := range newlyResolvedMap {
// resolutionsForPeoplePage = append(resolutionsForPeoplePage, ContactResolution{
// Description: fmt.Sprintf("%s — %s", contact.ContactName,
// contact.Component.ValueString()),
// ResolvedUser: keybase1.User{
// Uid: contact.Uid,
// Username: contact.Username,
// },
// })
// newlyResolved = append(newlyResolved, contact)
// }
// err = SendEncryptedContactResolutionToServer(mctx, resolutionsForPeoplePage)
// if err != nil {
// mctx.Warning("Could not add resolved contacts to people page: %v; returning contacts anyway", err)
// }

// return newlyResolved, s.SaveProcessedContacts(mctx, resolveResults)
}

func makeAssertionToName(contacts []keybase1.ProcessedContact) (res map[string]string) {
Expand Down

0 comments on commit f1e531b

Please sign in to comment.