@@ -22,7 +22,12 @@ type UIAdapter struct {
2222 username string
2323 iFollowThem bool
2424 sentResult bool
25+ // An upcall is when the service initiates the ID interaction.
26+ // An downcall is when the frontend initiates the ID.
27+ // Probably as directed by KBFS or the CLI.
28+ // "Tell Nojima we're about to hit him."
2529 isUpcall bool
30+ priorityMap map [string ]int // map from proof key to display priority
2631}
2732
2833var _ libkb.IdentifyUI = (* UIAdapter )(nil )
@@ -32,6 +37,7 @@ func NewUIAdapter(mctx libkb.MetaContext, ui keybase1.Identify3UiInterface) (*UI
3237 MetaContextified : libkb .NewMetaContextified (mctx ),
3338 ui : ui ,
3439 }
40+ ret .initPriorityMap ()
3541 return ret , nil
3642}
3743
@@ -93,6 +99,39 @@ func (i *UIAdapter) Start(user string, reason keybase1.IdentifyReason, force boo
9399 return err
94100}
95101
102+ func (i * UIAdapter ) initPriorityMap () {
103+ i .priorityMap = make (map [string ]int )
104+ for _ , displayConfig := range i .M ().G ().GetProofServices ().ListDisplayConfigs () {
105+ i .priorityMap [displayConfig .Key ] = displayConfig .Priority
106+ var altKey string
107+ switch displayConfig .Key {
108+ case "zcash.t" , "zcash.z" , "zcash.s" :
109+ altKey = "zcash"
110+ case "bitcoin" :
111+ altKey = "btc"
112+ case "http" , "https" , "dns" :
113+ altKey = "web"
114+ }
115+ if len (altKey ) > 0 {
116+ if _ , ok := i .priorityMap [altKey ]; ! ok {
117+ i .priorityMap [altKey ] = displayConfig .Priority
118+ }
119+ }
120+ }
121+ }
122+
123+ func (i * UIAdapter ) priority (key string ) int {
124+ if i .priorityMap == nil {
125+ return 0 // should be impossible but don't crash.
126+ }
127+ p , ok := i .priorityMap [key ]
128+ if ! ok {
129+ // Put it at the bottom of the list.
130+ return 9999999
131+ }
132+ return p
133+ }
134+
96135// return true if we need an upgrade
97136func (i * UIAdapter ) setRowStatus (arg * keybase1.Identify3UpdateRowArg , lcr keybase1.LinkCheckResult ) bool {
98137
@@ -162,64 +201,76 @@ func (i *UIAdapter) setRowStatus(arg *keybase1.Identify3UpdateRowArg, lcr keybas
162201 return needUpgrade
163202}
164203
165- func (i * UIAdapter ) finishRemoteCheck (proof keybase1.RemoteProof , lcr keybase1.LinkCheckResult ) error {
166- if lcr .BreaksTracking {
167- i .session .SetTrackBroken ()
168- }
169-
170- arg := keybase1.Identify3UpdateRowArg {
171- Key : proof .Key ,
172- Value : proof .Value ,
173- SigID : proof .SigID ,
204+ func (i * UIAdapter ) rowPartial (proof keybase1.RemoteProof , lcr * keybase1.LinkCheckResult ) (row keybase1.Identify3UpdateRowArg ) {
205+ row = keybase1.Identify3UpdateRowArg {
206+ Key : proof .Key ,
207+ Value : proof .Value ,
208+ SigID : proof .SigID ,
209+ Priority : i .priority (proof .Key ),
174210 }
175211
176212 var humanURLOrSigchainURL string
177- if lcr .Hint != nil {
213+ if lcr != nil && lcr .Hint != nil {
178214 humanURLOrSigchainURL = lcr .Hint .HumanUrl
179215 }
180216 if len (humanURLOrSigchainURL ) == 0 {
181217 humanURLOrSigchainURL = i .makeSigchainViewURL (proof .SigID )
182218 }
183219
184- arg .ProofURL = humanURLOrSigchainURL
220+ iconKey := proof .Key
221+ row .ProofURL = humanURLOrSigchainURL
185222 switch proof .ProofType {
186223 case keybase1 .ProofType_TWITTER :
187- arg .SiteURL = fmt .Sprintf ("https://twitter.com/%v" , proof .Value )
224+ row .SiteURL = fmt .Sprintf ("https://twitter.com/%v" , proof .Value )
225+ iconKey = "twitter"
188226 case keybase1 .ProofType_GITHUB :
189- arg .SiteURL = fmt .Sprintf ("https://github.com/%v" , proof .Value )
227+ row .SiteURL = fmt .Sprintf ("https://github.com/%v" , proof .Value )
228+ iconKey = "github"
190229 case keybase1 .ProofType_REDDIT :
191- arg .SiteURL = fmt .Sprintf ("https://reddit.com/user/%v" , proof .Value )
230+ row .SiteURL = fmt .Sprintf ("https://reddit.com/user/%v" , proof .Value )
231+ iconKey = "reddit"
192232 case keybase1 .ProofType_HACKERNEWS :
193- arg .SiteURL = fmt .Sprintf ("https://news.ycombinator.com/user?id=%v" , proof .Value )
233+ row .SiteURL = fmt .Sprintf ("https://news.ycombinator.com/user?id=%v" , proof .Value )
234+ iconKey = "hackernews"
194235 case keybase1 .ProofType_FACEBOOK :
195- arg .SiteURL = fmt .Sprintf ("https://facebook.com/%v" , proof .Value )
236+ row .SiteURL = fmt .Sprintf ("https://facebook.com/%v" , proof .Value )
237+ iconKey = "facebook"
196238 case keybase1 .ProofType_GENERIC_SOCIAL :
197- arg .SiteURL = humanURLOrSigchainURL
239+ row .SiteURL = humanURLOrSigchainURL
198240 serviceType := i .G ().GetProofServices ().GetServiceType (proof .Key )
199241 if serviceType != nil {
200242 if serviceType , ok := serviceType .(* externals.GenericSocialProofServiceType ); ok {
201243 profileURL , err := serviceType .ProfileURL (proof .Value )
202244 if err == nil {
203- arg .SiteURL = profileURL
245+ row .SiteURL = profileURL
204246 }
205247 }
206248 }
207- arg .ProofURL = i .makeSigchainViewURL (proof .SigID )
249+ row .ProofURL = i .makeSigchainViewURL (proof .SigID )
208250 case keybase1 .ProofType_GENERIC_WEB_SITE :
209251 protocol := "https"
210252 if proof .Key != "https" {
211253 protocol = "http"
212254 }
213- arg .SiteURL = fmt .Sprintf ("%v://%v" , protocol , proof .Value )
255+ row .SiteURL = fmt .Sprintf ("%v://%v" , protocol , proof .Value )
256+ iconKey = "web"
214257 case keybase1 .ProofType_DNS :
215- arg .SiteURL = fmt .Sprintf ("http://%v" , proof .Value )
216- arg .ProofURL = i .makeSigchainViewURL (proof .SigID )
258+ row .SiteURL = fmt .Sprintf ("http://%v" , proof .Value )
259+ row .ProofURL = i .makeSigchainViewURL (proof .SigID )
260+ iconKey = "web"
217261 default :
218- if lcr .Hint != nil {
219- arg .SiteURL = humanURLOrSigchainURL
220- }
262+ row .SiteURL = humanURLOrSigchainURL
263+ }
264+ row .SiteIcon = externals .MakeIcons (i .M (), iconKey , "logo_black" , 16 )
265+ return row
266+ }
267+
268+ func (i * UIAdapter ) finishRemoteCheck (proof keybase1.RemoteProof , lcr keybase1.LinkCheckResult ) error {
269+ if lcr .BreaksTracking {
270+ i .session .SetTrackBroken ()
221271 }
222272
273+ arg := i .rowPartial (proof , & lcr )
223274 needUpgrade := i .setRowStatus (& arg , lcr )
224275 if needUpgrade {
225276 i .session .SetNeedUpgrade ()
@@ -266,12 +317,14 @@ func (i *UIAdapter) displayKey(key keybase1.IdentifyKey) {
266317 }
267318
268319 arg := keybase1.Identify3UpdateRowArg {
269- Key : "pgp" ,
270- Value : hex .EncodeToString (key .PGPFingerprint ),
271- SigID : key .SigID ,
272- SiteURL : i .makeKeybaseProfileURL (),
320+ Key : "pgp" ,
321+ Value : hex .EncodeToString (key .PGPFingerprint ),
322+ SigID : key .SigID ,
323+ Priority : i .priority ("pgp" ),
324+ SiteURL : i .makeKeybaseProfileURL (),
273325 // key.SigID is blank if the PGP key was there pre-sigchain
274326 ProofURL : i .makeSigchainViewURL (key .SigID ),
327+ SiteIcon : externals .MakeIcons (i .M (), "pgp" , "logo_black" , 16 ),
275328 }
276329
277330 switch {
@@ -316,13 +369,10 @@ func (i *UIAdapter) plumbUncheckedProofs(proofs []keybase1.IdentifyRow) {
316369}
317370
318371func (i * UIAdapter ) plumbUncheckedProof (row keybase1.IdentifyRow ) {
319- i .updateRow (keybase1.Identify3UpdateRowArg {
320- Key : row .Proof .Key ,
321- Value : row .Proof .Value ,
322- State : keybase1 .Identify3RowState_CHECKING ,
323- Color : keybase1 .Identify3RowColor_GRAY ,
324- SigID : row .Proof .SigID ,
325- })
372+ arg := i .rowPartial (row .Proof , nil )
373+ arg .State = keybase1 .Identify3RowState_CHECKING
374+ arg .Color = keybase1 .Identify3RowColor_GRAY
375+ i .updateRow (arg )
326376}
327377
328378func (i * UIAdapter ) updateRow (arg keybase1.Identify3UpdateRowArg ) error {
@@ -399,10 +449,12 @@ func (i *UIAdapter) plumbCryptocurrency(crypto keybase1.Cryptocurrency) {
399449 i .updateRow (keybase1.Identify3UpdateRowArg {
400450 Key : key ,
401451 Value : crypto .Address ,
452+ Priority : i .priority (key ),
402453 State : keybase1 .Identify3RowState_VALID ,
403454 Color : keybase1 .Identify3RowColor_GREEN ,
404455 SigID : crypto .SigID ,
405456 SiteURL : i .makeSigchainViewURL (crypto .SigID ),
457+ SiteIcon : externals .MakeIcons (i .M (), key , "logo_black" , 16 ),
406458 ProofURL : i .makeSigchainViewURL (crypto .SigID ),
407459 })
408460}
@@ -411,21 +463,21 @@ func (i *UIAdapter) plumbStellarAccount(str keybase1.StellarAccount) {
411463 i .updateRow (keybase1.Identify3UpdateRowArg {
412464 Key : "stellar" ,
413465 Value : str .FederationAddress ,
466+ Priority : i .priority ("stellar" ),
414467 State : keybase1 .Identify3RowState_VALID ,
415468 Color : keybase1 .Identify3RowColor_GREEN ,
416469 SigID : str .SigID ,
417470 SiteURL : i .makeSigchainViewURL (str .SigID ),
471+ SiteIcon : externals .MakeIcons (i .M (), "stellar" , "logo_black" , 16 ),
418472 ProofURL : i .makeSigchainViewURL (str .SigID ),
419473 })
420474}
421475
422476func (i * UIAdapter ) plumbRevoked (row keybase1.RevokedProof ) {
423- i .updateRow (keybase1.Identify3UpdateRowArg {
424- Key : row .Proof .Key ,
425- Value : row .Proof .Value ,
426- State : keybase1 .Identify3RowState_REVOKED ,
427- Color : keybase1 .Identify3RowColor_RED ,
428- })
477+ arg := i .rowPartial (row .Proof , nil )
478+ arg .State = keybase1 .Identify3RowState_REVOKED
479+ arg .Color = keybase1 .Identify3RowColor_RED
480+ i .updateRow (arg )
429481}
430482
431483func (i * UIAdapter ) plumbRevokeds (rows []keybase1.RevokedProof ) {
0 commit comments