forked from keybase/client
/
tlf.go
59 lines (49 loc) · 2.28 KB
/
tlf.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package service
import (
"fmt"
"golang.org/x/net/context"
"github.com/keybase/client/go/chat"
"github.com/keybase/client/go/chat/globals"
"github.com/keybase/client/go/chat/utils"
keybase1 "github.com/keybase/client/go/protocol/keybase1"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
)
type tlfHandler struct {
*BaseHandler
utils.DebugLabeler
globals.Contextified
tlfInfoSource *chat.KBFSNameInfoSource
}
func newTlfHandler(xp rpc.Transporter, g *globals.Context) *tlfHandler {
return &tlfHandler{
BaseHandler: NewBaseHandler(g.ExternalG(), xp),
Contextified: globals.NewContextified(g),
DebugLabeler: utils.NewDebugLabeler(g.ExternalG(), "TlfHandler", false),
tlfInfoSource: chat.NewKBFSNameInfoSource(g),
}
}
func (h *tlfHandler) CryptKeys(ctx context.Context, arg keybase1.TLFQuery) (res keybase1.GetTLFCryptKeysRes, err error) {
defer h.Trace(ctx, &err,
fmt.Sprintf("CryptKeys(tlf=%s,mode=%v)", arg.TlfName, arg.IdentifyBehavior))()
var breaks []keybase1.TLFIdentifyFailure
ctx = globals.ChatCtx(ctx, h.G(), arg.IdentifyBehavior, &breaks, chat.NewCachingIdentifyNotifier(h.G()))
return h.tlfInfoSource.CryptKeys(ctx, arg.TlfName)
}
func (h *tlfHandler) PublicCanonicalTLFNameAndID(ctx context.Context, arg keybase1.TLFQuery) (res keybase1.CanonicalTLFNameAndIDWithBreaks, err error) {
defer h.Trace(ctx, &err,
fmt.Sprintf("PublicCanonicalTLFNameAndID(tlf=%s,mode=%v)", arg.TlfName,
arg.IdentifyBehavior))()
var breaks []keybase1.TLFIdentifyFailure
ctx = globals.ChatCtx(ctx, h.G(), arg.IdentifyBehavior, &breaks, chat.NewCachingIdentifyNotifier(h.G()))
return h.tlfInfoSource.PublicCanonicalTLFNameAndID(ctx, arg.TlfName)
}
func (h *tlfHandler) CompleteAndCanonicalizePrivateTlfName(ctx context.Context, arg keybase1.TLFQuery) (res keybase1.CanonicalTLFNameAndIDWithBreaks, err error) {
defer h.Trace(ctx, &err,
fmt.Sprintf("CompleteAndCanonicalizePrivateTlfName(tlf=%s,mode=%v)", arg.TlfName,
arg.IdentifyBehavior))()
var breaks []keybase1.TLFIdentifyFailure
ctx = globals.ChatCtx(ctx, h.G(), arg.IdentifyBehavior, &breaks, chat.NewCachingIdentifyNotifier(h.G()))
return h.tlfInfoSource.CompleteAndCanonicalizePrivateTlfName(ctx, arg.TlfName)
}