Skip to content

Commit eddc472

Browse files
committed
Use blank identify ui if none available
1 parent bd6a96d commit eddc472

12 files changed

Lines changed: 91 additions & 17 deletions

File tree

‎go/chat/identify_ui.go‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package chat
2+
3+
import "github.com/keybase/client/go/protocol/keybase1"
4+
5+
type chatNullIdentifyUI struct{}
6+
7+
func (c chatNullIdentifyUI) Start(string, keybase1.IdentifyReason, bool) error { return nil }
8+
func (c chatNullIdentifyUI) FinishWebProofCheck(keybase1.RemoteProof, keybase1.LinkCheckResult) error {
9+
return nil
10+
}
11+
func (c chatNullIdentifyUI) FinishSocialProofCheck(keybase1.RemoteProof, keybase1.LinkCheckResult) error {
12+
return nil
13+
}
14+
func (c chatNullIdentifyUI) Confirm(*keybase1.IdentifyOutcome) (keybase1.ConfirmResult, error) {
15+
return keybase1.ConfirmResult{}, nil
16+
}
17+
func (c chatNullIdentifyUI) DisplayCryptocurrency(keybase1.Cryptocurrency) error { return nil }
18+
func (c chatNullIdentifyUI) DisplayKey(keybase1.IdentifyKey) error { return nil }
19+
func (c chatNullIdentifyUI) ReportLastTrack(*keybase1.TrackSummary) error { return nil }
20+
func (c chatNullIdentifyUI) LaunchNetworkChecks(*keybase1.Identity, *keybase1.User) error { return nil }
21+
func (c chatNullIdentifyUI) DisplayTrackStatement(string) error { return nil }
22+
func (c chatNullIdentifyUI) DisplayUserCard(keybase1.UserCard) error { return nil }
23+
func (c chatNullIdentifyUI) ReportTrackToken(keybase1.TrackToken) error { return nil }
24+
func (c chatNullIdentifyUI) Cancel() error { return nil }
25+
func (c chatNullIdentifyUI) Finish() error { return nil }
26+
func (c chatNullIdentifyUI) DisplayTLFCreateWithInvite(keybase1.DisplayTLFCreateWithInviteArg) error {
27+
return nil
28+
}
29+
func (c chatNullIdentifyUI) Dismiss(string, keybase1.DismissReason) error { return nil }

‎go/chat/tlf.go‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
type KBFSTLFInfoSource struct {
1818
utils.DebugLabeler
1919
libkb.Contextified
20+
identifier types.Identifier
2021
}
2122

2223
func NewKBFSTLFInfoSource(g *libkb.GlobalContext) *KBFSTLFInfoSource {
@@ -26,6 +27,12 @@ func NewKBFSTLFInfoSource(g *libkb.GlobalContext) *KBFSTLFInfoSource {
2627
}
2728
}
2829

30+
func NewKBFSTLFInfoSourceWithIdentifier(g *libkb.GlobalContext, identifier types.Identifier) *KBFSTLFInfoSource {
31+
s := NewKBFSTLFInfoSource(g)
32+
s.identifier = identifier
33+
return s
34+
}
35+
2936
func (t *KBFSTLFInfoSource) tlfKeysClient() (*keybase1.TlfKeysClient, error) {
3037
xp := t.G().ConnectionManager.LookupByClientType(keybase1.ClientType_KBFS)
3138
if xp == nil {
@@ -73,6 +80,9 @@ func (t *KBFSTLFInfoSource) CryptKeys(ctx context.Context, tlfName string) (res
7380
return res, err
7481
}
7582

83+
// skip identify:
84+
query.IdentifyBehavior = keybase1.TLFIdentifyBehavior_CHAT_SKIP
85+
7686
resp, err := tlfClient.GetTLFCryptKeys(ctx, query)
7787
if err != nil {
7888
return resp, err
@@ -158,6 +168,23 @@ func (t *KBFSTLFInfoSource) identifyTLF(ctx context.Context, arg keybase1.TLFQue
158168
}
159169

160170
func (t *KBFSTLFInfoSource) identifyUser(ctx context.Context, assertion string, private bool, idBehavior keybase1.TLFIdentifyBehavior) (keybase1.TLFIdentifyFailure, error) {
171+
172+
// if an identify UI is registered, then use it
173+
sessionID, idUI, err := t.G().UIRouter.GetIdentifyUICtx(ctx)
174+
if err != nil {
175+
return keybase1.TLFIdentifyFailure{}, err
176+
}
177+
178+
if idUI == nil {
179+
if t.identifier != nil {
180+
t.G().Log.Debug("using KBFSTLFInfoSource.identifier to identify")
181+
return t.identifier.Identify(ctx, assertion, private, idBehavior)
182+
}
183+
184+
sessionID = 0
185+
idUI = chatNullIdentifyUI{}
186+
}
187+
161188
reason := "You accessed a public conversation."
162189
if private {
163190
reason = fmt.Sprintf("You accessed a private conversation with %s.", assertion)
@@ -171,11 +198,6 @@ func (t *KBFSTLFInfoSource) identifyUser(ctx context.Context, assertion string,
171198
IdentifyBehavior: idBehavior,
172199
}
173200

174-
sessionID, idUI, err := t.G().UIRouter.GetIdentifyUICtx(ctx)
175-
if err != nil {
176-
return keybase1.TLFIdentifyFailure{}, err
177-
}
178-
179201
ectx := engine.Context{
180202
IdentifyUI: idUI,
181203
SessionID: sessionID,

‎go/engine/engine.go‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package engine
66
import (
77
"fmt"
88
"net/url"
9+
"runtime/debug"
910

1011
"github.com/keybase/client/go/libkb"
1112
)
@@ -121,11 +122,14 @@ func wantsDelegateUI(e Engine, kind libkb.UIKind) bool {
121122

122123
func check(c libkb.UIConsumer, ctx *Context) error {
123124
if err := checkUI(c, ctx); err != nil {
124-
return CheckError{fmt.Sprintf("%s: %s", c.Name(), err)}
125+
return err
125126
}
126127

127128
for _, sub := range c.SubConsumers() {
128129
if err := check(sub, ctx); err != nil {
130+
if _, ok := err.(CheckError); ok {
131+
return err
132+
}
129133
return CheckError{fmt.Sprintf("%s: %s", sub.Name(), err)}
130134
}
131135
}
@@ -136,7 +140,7 @@ func check(c libkb.UIConsumer, ctx *Context) error {
136140
func checkUI(c libkb.UIConsumer, ctx *Context) error {
137141
for _, ui := range c.RequiredUIs() {
138142
if !ctx.HasUI(ui) {
139-
return CheckError{fmt.Sprintf("requires ui %q", ui)}
143+
return CheckError{fmt.Sprintf("%s: requires ui %q\n\n%s", c.Name(), ui, string(debug.Stack()))}
140144
}
141145
}
142146
return nil

‎go/protocol/keybase1/tlf_keys.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const (
1717
TLFIdentifyBehavior_CHAT_GUI_STRICT TLFIdentifyBehavior = 3
1818
TLFIdentifyBehavior_KBFS_REKEY TLFIdentifyBehavior = 4
1919
TLFIdentifyBehavior_KBFS_QR TLFIdentifyBehavior = 5
20+
TLFIdentifyBehavior_CHAT_SKIP TLFIdentifyBehavior = 6
2021
)
2122

2223
var TLFIdentifyBehaviorMap = map[string]TLFIdentifyBehavior{
@@ -26,6 +27,7 @@ var TLFIdentifyBehaviorMap = map[string]TLFIdentifyBehavior{
2627
"CHAT_GUI_STRICT": 3,
2728
"KBFS_REKEY": 4,
2829
"KBFS_QR": 5,
30+
"CHAT_SKIP": 6,
2931
}
3032

3133
var TLFIdentifyBehaviorRevMap = map[TLFIdentifyBehavior]string{
@@ -35,6 +37,7 @@ var TLFIdentifyBehaviorRevMap = map[TLFIdentifyBehavior]string{
3537
3: "CHAT_GUI_STRICT",
3638
4: "KBFS_REKEY",
3739
5: "KBFS_QR",
40+
6: "CHAT_SKIP",
3841
}
3942

4043
func (e TLFIdentifyBehavior) String() string {

‎go/service/chat_local.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ type chatLocalHandler struct {
4848

4949
// newChatLocalHandler creates a chatLocalHandler.
5050
func newChatLocalHandler(xp rpc.Transporter, g *libkb.GlobalContext, store *chat.AttachmentStore, gh *gregorHandler) *chatLocalHandler {
51-
tlf := chat.NewKBFSTLFInfoSource(g)
51+
base := NewBaseHandler(xp)
52+
tlf := chat.NewKBFSTLFInfoSourceWithIdentifier(g, NewChatIdentifier(g, base.NewRemoteIdentifyUI(0, g)))
5253
h := &chatLocalHandler{
53-
BaseHandler: NewBaseHandler(xp),
54+
BaseHandler: base,
5455
Contextified: libkb.NewContextified(g),
5556
DebugLabeler: utils.NewDebugLabeler(g, "ChatLocalHandler", false),
5657
gh: gh,

‎go/service/identify.go‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ func (u *RemoteIdentifyUI) DisplayTLFCreateWithInvite(arg keybase1.DisplayTLFCre
206206
return u.uicli.DisplayTLFCreateWithInvite(ctx, arg)
207207
}
208208

209-
/*
210209
type ChatIdentifier struct {
211210
libkb.Contextified
212211
ui libkb.IdentifyUI
@@ -260,4 +259,3 @@ func (c *ChatIdentifier) Identify(ctx context.Context, assertion string, private
260259
return frep, nil
261260

262261
}
263-
*/

‎go/service/main.go‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ func (d *Service) Handle(c net.Conn) {
156156
return
157157
}
158158

159+
// create an identifier
160+
/*
161+
cli := rpc.NewClient(xp, libkb.ErrorUnwrapper{})
162+
idUI := &RemoteIdentifyUI{
163+
Contextified: libkb.NewContextified(d.G()),
164+
uicli: keybase1.IdentifyUiClient{Cli: cli},
165+
logUI: &LogUI{cli: &keybase1.LogUiClient{Cli: cli}},
166+
}
167+
identifier := NewChatIdentifier(d.G(), idUI)
168+
*/
169+
159170
// Run the server and wait for it to finish.
160171
<-server.Run()
161172
// err is always non-nil.
@@ -251,8 +262,6 @@ func (d *Service) RunBackgroundOperations(uir *UIRouter) {
251262
func (d *Service) createMessageDeliverer() {
252263
ri := d.chatRemoteClient
253264
si := func() libkb.SecretUI { return chat.DelivererSecretUI{} }
254-
// base := NewBaseHandler(xp)
255-
// tlf := chat.NewKBFSTLFInfoSource(d.G(), NewChatIdentifier(g, base.NewRemoteIdentifyUI(0, g)))
256265
tlf := chat.NewKBFSTLFInfoSource(d.G())
257266

258267
sender := chat.NewBlockingSender(d.G(), chat.NewBoxer(d.G(), tlf), d.attachmentstore, ri, si)

‎go/service/tlf.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ type tlfHandler struct {
2626
}
2727

2828
func newTlfHandler(xp rpc.Transporter, g *libkb.GlobalContext) *tlfHandler {
29+
base := NewBaseHandler(xp)
30+
tlf := chat.NewKBFSTLFInfoSourceWithIdentifier(g, NewChatIdentifier(g, base.NewRemoteIdentifyUI(0, g)))
2931
return &tlfHandler{
30-
BaseHandler: NewBaseHandler(xp),
32+
BaseHandler: base,
3133
Contextified: libkb.NewContextified(g),
3234
DebugLabeler: utils.NewDebugLabeler(g, "TlfHandler", false),
33-
tlfInfoSource: chat.NewKBFSTLFInfoSource(g),
35+
tlfInfoSource: tlf,
3436
}
3537
}
3638

‎protocol/avdl/keybase1/tlf_keys.avdl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ protocol tlfKeys {
1212
CHAT_GUI_2,
1313
CHAT_GUI_STRICT_3,
1414
KBFS_REKEY_4,
15-
KBFS_QR_5
15+
KBFS_QR_5,
16+
CHAT_SKIP_6
1617
}
1718

1819
@typedef("string")

‎protocol/js/flow-types.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ export const TlfKeysTLFIdentifyBehavior = {
487487
chatGuiStrict: 3,
488488
kbfsRekey: 4,
489489
kbfsQr: 5,
490+
chatSkip: 6,
490491
}
491492

492493
export const UiPromptDefault = {
@@ -4631,6 +4632,7 @@ export type TLFIdentifyBehavior =
46314632
| 3 // CHAT_GUI_STRICT_3
46324633
| 4 // KBFS_REKEY_4
46334634
| 5 // KBFS_QR_5
4635+
| 6 // CHAT_SKIP_6
46344636

46354637
export type TLFIdentifyFailure = {
46364638
user: User,

0 commit comments

Comments
 (0)