1package chat 2 3import ( 4 "github.com/keybase/client/go/chat/globals" 5 "github.com/keybase/client/go/chat/types" 6 "github.com/keybase/client/go/protocol/keybase1" 7) 8 9type CtxFactory struct { 10 globals.Contextified 11} 12 13var _ types.ContextFactory = (*CtxFactory)(nil) 14 15func NewCtxFactory(g *globals.Context) types.ContextFactory { 16 return &CtxFactory{ 17 Contextified: globals.NewContextified(g), 18 } 19} 20 21func (c *CtxFactory) NewKeyFinder() types.KeyFinder { 22 return NewKeyFinder(c.G()) 23} 24 25func (c *CtxFactory) NewUPAKFinder() types.UPAKFinder { 26 return NewCachingUPAKFinder(c.G()) 27} 28 29// For testing 30type mockCtxFactory struct { 31 globals.Contextified 32 cryptKeys []keybase1.CryptKey 33} 34 35var _ types.ContextFactory = (*mockCtxFactory)(nil) 36 37func newMockCtxFactory(g *globals.Context, cryptKeys []keybase1.CryptKey) types.ContextFactory { 38 return &mockCtxFactory{ 39 Contextified: globals.NewContextified(g), 40 cryptKeys: cryptKeys, 41 } 42} 43 44func (c *mockCtxFactory) NewKeyFinder() types.KeyFinder { 45 return NewKeyFinderMock(c.cryptKeys) 46} 47 48func (c *mockCtxFactory) NewUPAKFinder() types.UPAKFinder { 49 return NewCachingUPAKFinder(c.G()) 50} 51