Skip to content

Commit 20de7bc

Browse files
authored
Refactor Context to globals.ChatCtx and StorageLockTab to utils pkg [CORE-10300] (keybase#16252)
* wip move locktab to utils * init once * fix test compile * revert locktab in storage * refactor chat/context to globals * fix boxer tests * RequestContext -> ChatCtx * CtxFactory * fix test * fix test
1 parent fe5827a commit 20de7bc

42 files changed

Lines changed: 648 additions & 562 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎go/bind/extension.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func presentInboxItem(item storage.SharedInboxItem, username string) storage.Sha
252252
func ExtensionGetInbox() (res string, err error) {
253253
defer kbCtx.Trace("ExtensionGetInbox", func() error { return err })()
254254
gc := globals.NewContext(kbCtx, kbChatCtx)
255-
ctx := chat.Context(context.Background(), gc,
255+
ctx := globals.ChatCtx(context.Background(), gc,
256256
keybase1.TLFIdentifyBehavior_CHAT_GUI, nil, chat.NewCachingIdentifyNotifier(gc))
257257
uid, err := assertLoggedInUID(ctx, gc)
258258
if err != nil {
@@ -292,7 +292,7 @@ func extensionGetDeviceID(ctx context.Context, gc *globals.Context) (res gregor1
292292

293293
func extensionRegisterSendNonblock(ctx context.Context, gc *globals.Context, convID chat1.ConversationID,
294294
outboxID chat1.OutboxID) {
295-
bctx := chat.BackgroundContext(ctx, gc)
295+
bctx := globals.BackgroundChatCtx(ctx, gc)
296296
go func(ctx context.Context) {
297297
deviceID, err := extensionGetDeviceID(ctx, gc)
298298
if err != nil {
@@ -429,7 +429,7 @@ func extensionNewSender(g *globals.Context) types.Sender {
429429
func ExtensionPostText(strConvID, name string, public bool, membersType int, body string) (err error) {
430430
defer kbCtx.Trace("ExtensionPostText", func() error { return err })()
431431
gc := globals.NewContext(kbCtx, kbChatCtx)
432-
ctx := chat.Context(context.Background(), gc,
432+
ctx := globals.ChatCtx(context.Background(), gc,
433433
keybase1.TLFIdentifyBehavior_CHAT_GUI, nil, chat.NewCachingIdentifyNotifier(gc))
434434
defer func() { err = flattenError(err) }()
435435
defer func() {
@@ -501,7 +501,7 @@ func ExtensionPostImage(strConvID, name string, public bool, membersType int,
501501
baseWidth, baseHeight, previewWidth, previewHeight int, previewData []byte) (err error) {
502502
defer kbCtx.Trace("ExtensionPostImage", func() error { return err })()
503503
gc := globals.NewContext(kbCtx, kbChatCtx)
504-
ctx := chat.Context(context.Background(), gc,
504+
ctx := globals.ChatCtx(context.Background(), gc,
505505
keybase1.TLFIdentifyBehavior_CHAT_GUI, nil, chat.NewCachingIdentifyNotifier(gc))
506506
defer func() { err = flattenError(err) }()
507507
uid, err := assertLoggedInUID(ctx, gc)
@@ -559,7 +559,7 @@ func ExtensionPostVideo(strConvID, name string, public bool, membersType int,
559559
duration, baseWidth, baseHeight, previewWidth, previewHeight int, previewData []byte) (err error) {
560560
defer kbCtx.Trace("ExtensionPostVideo", func() error { return err })()
561561
gc := globals.NewContext(kbCtx, kbChatCtx)
562-
ctx := chat.Context(context.Background(), gc,
562+
ctx := globals.ChatCtx(context.Background(), gc,
563563
keybase1.TLFIdentifyBehavior_CHAT_GUI, nil, chat.NewCachingIdentifyNotifier(gc))
564564
defer func() { err = flattenError(err) }()
565565
uid, err := assertLoggedInUID(ctx, gc)
@@ -607,7 +607,7 @@ func ExtensionPostFile(strConvID, name string, public bool, membersType int,
607607
caption string, filename string) (err error) {
608608
defer kbCtx.Trace("ExtensionPostFile", func() error { return err })()
609609
gc := globals.NewContext(kbCtx, kbChatCtx)
610-
ctx := chat.Context(context.Background(), gc,
610+
ctx := globals.ChatCtx(context.Background(), gc,
611611
keybase1.TLFIdentifyBehavior_CHAT_GUI, nil, chat.NewCachingIdentifyNotifier(gc))
612612
defer func() { err = flattenError(err) }()
613613
uid, err := assertLoggedInUID(ctx, gc)
@@ -691,7 +691,7 @@ func putSavedConv(ctx context.Context, strConvID, name string, public bool, memb
691691
func ExtensionGetSavedConv() string {
692692
defer kbCtx.Trace("ExtensionGetSavedConv", func() error { return nil })()
693693
gc := globals.NewContext(kbCtx, kbChatCtx)
694-
ctx := chat.Context(context.Background(), gc,
694+
ctx := globals.ChatCtx(context.Background(), gc,
695695
keybase1.TLFIdentifyBehavior_CHAT_GUI, nil, chat.NewCachingIdentifyNotifier(gc))
696696
if _, err := assertLoggedInUID(ctx, gc); err != nil {
697697
kbCtx.Log.CDebugf(ctx, "ExtensionGetSavedConv: failed to get uid: %s", err)

‎go/bind/keybase.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func HandleBackgroundNotification(strConvID, body string, intMembersType int, di
447447
return nil
448448
}
449449
gc := globals.NewContext(kbCtx, kbChatCtx)
450-
ctx := chat.Context(context.Background(), gc,
450+
ctx := globals.ChatCtx(context.Background(), gc,
451451
keybase1.TLFIdentifyBehavior_CHAT_GUI, nil, chat.NewCachingIdentifyNotifier(gc))
452452

453453
defer kbCtx.CTrace(ctx, fmt.Sprintf("HandleBackgroundNotification(%s,%v,%d,%d,%s,%d,%d)",

‎go/chat/activitynotifier.go‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ func (n *NotifyRouterActivityRouter) kuid(uid gregor1.UID) keybase1.UID {
5353
func (n *NotifyRouterActivityRouter) Activity(ctx context.Context, uid gregor1.UID,
5454
topicType chat1.TopicType, activity *chat1.ChatActivity, source chat1.ChatActivitySource) {
5555
defer n.Trace(ctx, func() error { return nil }, "Activity(%v,%v)", topicType, source)()
56-
ctx = BackgroundContext(ctx, n.G())
56+
ctx = globals.BackgroundChatCtx(ctx, n.G())
5757
n.notifyCh <- func() {
5858
n.G().NotifyRouter.HandleNewChatActivity(ctx, n.kuid(uid), topicType, activity, source)
5959
}
6060
}
6161

6262
func (n *NotifyRouterActivityRouter) TypingUpdate(ctx context.Context, updates []chat1.ConvTypingUpdate) {
6363
defer n.Trace(ctx, func() error { return nil }, "TypingUpdate")()
64-
ctx = BackgroundContext(ctx, n.G())
64+
ctx = globals.BackgroundChatCtx(ctx, n.G())
6565
n.notifyCh <- func() {
6666
n.G().NotifyRouter.HandleChatTypingUpdate(ctx, updates)
6767
}
@@ -70,7 +70,7 @@ func (n *NotifyRouterActivityRouter) TypingUpdate(ctx context.Context, updates [
7070
func (n *NotifyRouterActivityRouter) JoinedConversation(ctx context.Context, uid gregor1.UID,
7171
convID chat1.ConversationID, topicType chat1.TopicType, conv *chat1.InboxUIItem) {
7272
defer n.Trace(ctx, func() error { return nil }, "JoinedConversation(%s,%v)", convID, topicType)()
73-
ctx = BackgroundContext(ctx, n.G())
73+
ctx = globals.BackgroundChatCtx(ctx, n.G())
7474
n.notifyCh <- func() {
7575
n.G().NotifyRouter.HandleChatJoinedConversation(ctx, n.kuid(uid), convID, topicType, conv)
7676
}
@@ -79,7 +79,7 @@ func (n *NotifyRouterActivityRouter) JoinedConversation(ctx context.Context, uid
7979
func (n *NotifyRouterActivityRouter) LeftConversation(ctx context.Context, uid gregor1.UID,
8080
convID chat1.ConversationID, topicType chat1.TopicType) {
8181
defer n.Trace(ctx, func() error { return nil }, "LeftConversation(%s,%v)", convID, topicType)()
82-
ctx = BackgroundContext(ctx, n.G())
82+
ctx = globals.BackgroundChatCtx(ctx, n.G())
8383
n.notifyCh <- func() {
8484
n.G().NotifyRouter.HandleChatLeftConversation(ctx, n.kuid(uid), convID, topicType)
8585
}
@@ -88,7 +88,7 @@ func (n *NotifyRouterActivityRouter) LeftConversation(ctx context.Context, uid g
8888
func (n *NotifyRouterActivityRouter) ResetConversation(ctx context.Context, uid gregor1.UID,
8989
convID chat1.ConversationID, topicType chat1.TopicType) {
9090
defer n.Trace(ctx, func() error { return nil }, "ResetConversation(%s,%v)", convID, topicType)()
91-
ctx = BackgroundContext(ctx, n.G())
91+
ctx = globals.BackgroundChatCtx(ctx, n.G())
9292
n.notifyCh <- func() {
9393
n.G().NotifyRouter.HandleChatResetConversation(ctx, n.kuid(uid), convID, topicType)
9494
}
@@ -97,7 +97,7 @@ func (n *NotifyRouterActivityRouter) ResetConversation(ctx context.Context, uid
9797
func (n *NotifyRouterActivityRouter) KBFSToImpteamUpgrade(ctx context.Context, uid gregor1.UID,
9898
convID chat1.ConversationID, topicType chat1.TopicType) {
9999
defer n.Trace(ctx, func() error { return nil }, "KBFSToImpteamUpgrade(%s,%v)", convID, topicType)()
100-
ctx = BackgroundContext(ctx, n.G())
100+
ctx = globals.BackgroundChatCtx(ctx, n.G())
101101
n.notifyCh <- func() {
102102
n.G().NotifyRouter.HandleChatKBFSToImpteamUpgrade(ctx, n.kuid(uid), convID, topicType)
103103
}
@@ -106,7 +106,7 @@ func (n *NotifyRouterActivityRouter) KBFSToImpteamUpgrade(ctx context.Context, u
106106
func (n *NotifyRouterActivityRouter) SetConvRetention(ctx context.Context, uid gregor1.UID,
107107
convID chat1.ConversationID, topicType chat1.TopicType, conv *chat1.InboxUIItem) {
108108
defer n.Trace(ctx, func() error { return nil }, "SetConvRetention(%s,%v)", convID, topicType)()
109-
ctx = BackgroundContext(ctx, n.G())
109+
ctx = globals.BackgroundChatCtx(ctx, n.G())
110110
n.notifyCh <- func() {
111111
n.G().NotifyRouter.HandleChatSetConvRetention(ctx, n.kuid(uid), convID, topicType, conv)
112112
}
@@ -115,7 +115,7 @@ func (n *NotifyRouterActivityRouter) SetConvRetention(ctx context.Context, uid g
115115
func (n *NotifyRouterActivityRouter) SetTeamRetention(ctx context.Context, uid gregor1.UID,
116116
teamID keybase1.TeamID, topicType chat1.TopicType, convs []chat1.InboxUIItem) {
117117
defer n.Trace(ctx, func() error { return nil }, "SetTeamRetention(%s,%v)", teamID, topicType)()
118-
ctx = BackgroundContext(ctx, n.G())
118+
ctx = globals.BackgroundChatCtx(ctx, n.G())
119119
n.notifyCh <- func() {
120120
n.G().NotifyRouter.HandleChatSetTeamRetention(ctx, n.kuid(uid), teamID, topicType, convs)
121121
}
@@ -124,7 +124,7 @@ func (n *NotifyRouterActivityRouter) SetTeamRetention(ctx context.Context, uid g
124124
func (n *NotifyRouterActivityRouter) SetConvSettings(ctx context.Context, uid gregor1.UID,
125125
convID chat1.ConversationID, topicType chat1.TopicType, conv *chat1.InboxUIItem) {
126126
defer n.Trace(ctx, func() error { return nil }, "SetConvSettings(%s,%v)", convID, topicType)()
127-
ctx = BackgroundContext(ctx, n.G())
127+
ctx = globals.BackgroundChatCtx(ctx, n.G())
128128
n.notifyCh <- func() {
129129
n.G().NotifyRouter.HandleChatSetConvSettings(ctx, n.kuid(uid), convID, topicType, conv)
130130
}
@@ -133,15 +133,15 @@ func (n *NotifyRouterActivityRouter) SetConvSettings(ctx context.Context, uid gr
133133
func (n *NotifyRouterActivityRouter) SubteamRename(ctx context.Context, uid gregor1.UID,
134134
convIDs []chat1.ConversationID, topicType chat1.TopicType, convs []chat1.InboxUIItem) {
135135
defer n.Trace(ctx, func() error { return nil }, "SubteamRename(%v,%d convs)", topicType, len(convs))()
136-
ctx = BackgroundContext(ctx, n.G())
136+
ctx = globals.BackgroundChatCtx(ctx, n.G())
137137
n.notifyCh <- func() {
138138
n.G().NotifyRouter.HandleChatSubteamRename(ctx, n.kuid(uid), convIDs, topicType, convs)
139139
}
140140
}
141141

142142
func (n *NotifyRouterActivityRouter) InboxSyncStarted(ctx context.Context, uid gregor1.UID) {
143143
defer n.Trace(ctx, func() error { return nil }, "InboxSyncStarted")()
144-
ctx = BackgroundContext(ctx, n.G())
144+
ctx = globals.BackgroundChatCtx(ctx, n.G())
145145
n.notifyCh <- func() {
146146
n.G().NotifyRouter.HandleChatInboxSyncStarted(ctx, n.kuid(uid))
147147
}
@@ -150,15 +150,15 @@ func (n *NotifyRouterActivityRouter) InboxSyncStarted(ctx context.Context, uid g
150150
func (n *NotifyRouterActivityRouter) InboxSynced(ctx context.Context, uid gregor1.UID,
151151
topicType chat1.TopicType, syncRes chat1.ChatSyncResult) {
152152
defer n.Trace(ctx, func() error { return nil }, "InboxSynced(%v)", topicType)()
153-
ctx = BackgroundContext(ctx, n.G())
153+
ctx = globals.BackgroundChatCtx(ctx, n.G())
154154
n.notifyCh <- func() {
155155
n.G().NotifyRouter.HandleChatInboxSynced(ctx, n.kuid(uid), topicType, syncRes)
156156
}
157157
}
158158

159159
func (n *NotifyRouterActivityRouter) InboxStale(ctx context.Context, uid gregor1.UID) {
160160
defer n.Trace(ctx, func() error { return nil }, "InboxStale")()
161-
ctx = BackgroundContext(ctx, n.G())
161+
ctx = globals.BackgroundChatCtx(ctx, n.G())
162162
n.notifyCh <- func() {
163163
n.G().NotifyRouter.HandleChatInboxStale(ctx, n.kuid(uid))
164164
}
@@ -167,7 +167,7 @@ func (n *NotifyRouterActivityRouter) InboxStale(ctx context.Context, uid gregor1
167167
func (n *NotifyRouterActivityRouter) ThreadsStale(ctx context.Context, uid gregor1.UID,
168168
updates []chat1.ConversationStaleUpdate) {
169169
defer n.Trace(ctx, func() error { return nil }, "ThreadsStale")()
170-
ctx = BackgroundContext(ctx, n.G())
170+
ctx = globals.BackgroundChatCtx(ctx, n.G())
171171
n.notifyCh <- func() {
172172
n.G().NotifyRouter.HandleChatThreadsStale(ctx, n.kuid(uid), updates)
173173
}
@@ -176,7 +176,7 @@ func (n *NotifyRouterActivityRouter) ThreadsStale(ctx context.Context, uid grego
176176
func (n *NotifyRouterActivityRouter) TLFFinalize(ctx context.Context, uid gregor1.UID,
177177
convID chat1.ConversationID, topicType chat1.TopicType, finalizeInfo chat1.ConversationFinalizeInfo, conv *chat1.InboxUIItem) {
178178
defer n.Trace(ctx, func() error { return nil }, "TLFFinalize(%s,%v)", convID, topicType)()
179-
ctx = BackgroundContext(ctx, n.G())
179+
ctx = globals.BackgroundChatCtx(ctx, n.G())
180180
n.notifyCh <- func() {
181181
n.G().NotifyRouter.HandleChatTLFFinalize(ctx, n.kuid(uid), convID, topicType, finalizeInfo, conv)
182182
}
@@ -185,7 +185,7 @@ func (n *NotifyRouterActivityRouter) TLFFinalize(ctx context.Context, uid gregor
185185
func (n *NotifyRouterActivityRouter) TLFResolve(ctx context.Context, uid gregor1.UID,
186186
convID chat1.ConversationID, topicType chat1.TopicType, resolveInfo chat1.ConversationResolveInfo) {
187187
defer n.Trace(ctx, func() error { return nil }, "TLFResolve(%s,%v)", convID, topicType)()
188-
ctx = BackgroundContext(ctx, n.G())
188+
ctx = globals.BackgroundChatCtx(ctx, n.G())
189189
n.notifyCh <- func() {
190190
n.G().NotifyRouter.HandleChatTLFResolve(ctx, n.kuid(uid), convID, topicType, resolveInfo)
191191
}
@@ -194,7 +194,7 @@ func (n *NotifyRouterActivityRouter) TLFResolve(ctx context.Context, uid gregor1
194194
func (n *NotifyRouterActivityRouter) AttachmentUploadStart(ctx context.Context, uid gregor1.UID,
195195
convID chat1.ConversationID, outboxID chat1.OutboxID) {
196196
defer n.Trace(ctx, func() error { return nil }, "AttachmentUploadStart(%s,%s)", convID, outboxID)()
197-
ctx = BackgroundContext(ctx, n.G())
197+
ctx = globals.BackgroundChatCtx(ctx, n.G())
198198
n.notifyCh <- func() {
199199
n.G().NotifyRouter.HandleChatAttachmentUploadStart(ctx, n.kuid(uid), convID, outboxID)
200200
}
@@ -203,7 +203,7 @@ func (n *NotifyRouterActivityRouter) AttachmentUploadStart(ctx context.Context,
203203
func (n *NotifyRouterActivityRouter) AttachmentUploadProgress(ctx context.Context, uid gregor1.UID,
204204
convID chat1.ConversationID, outboxID chat1.OutboxID, bytesComplete, bytesTotal int64) {
205205
defer n.Trace(ctx, func() error { return nil }, "AttachmentUploadProgress(%s,%s)", convID, outboxID)()
206-
ctx = BackgroundContext(ctx, n.G())
206+
ctx = globals.BackgroundChatCtx(ctx, n.G())
207207
n.notifyCh <- func() {
208208
n.G().NotifyRouter.HandleChatAttachmentUploadProgress(ctx, n.kuid(uid), convID, outboxID,
209209
bytesComplete, bytesTotal)
@@ -213,7 +213,7 @@ func (n *NotifyRouterActivityRouter) AttachmentUploadProgress(ctx context.Contex
213213
func (n *NotifyRouterActivityRouter) PromptUnfurl(ctx context.Context, uid gregor1.UID,
214214
convID chat1.ConversationID, msgID chat1.MessageID, domain string) {
215215
defer n.Trace(ctx, func() error { return nil }, "PromptUnfurl(%s,%s)", convID, msgID)()
216-
ctx = BackgroundContext(ctx, n.G())
216+
ctx = globals.BackgroundChatCtx(ctx, n.G())
217217
n.notifyCh <- func() {
218218
n.G().NotifyRouter.HandleChatPromptUnfurl(ctx, n.kuid(uid), convID, msgID, domain)
219219
}

‎go/chat/attachment_httpsrv.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (r *AttachmentHTTPSrv) GetGiphyURL(ctx context.Context, giphyURL string) st
217217
}
218218

219219
func (r *AttachmentHTTPSrv) servePendingPreview(w http.ResponseWriter, req *http.Request) {
220-
ctx := Context(context.Background(), r.G(), keybase1.TLFIdentifyBehavior_CHAT_GUI, nil,
220+
ctx := globals.ChatCtx(context.Background(), r.G(), keybase1.TLFIdentifyBehavior_CHAT_GUI, nil,
221221
NewSimpleIdentifyNotifier(r.G()))
222222
defer r.Trace(ctx, func() error { return nil }, "servePendingPreview")()
223223
strOutboxID := req.URL.Query().Get("key")
@@ -238,7 +238,7 @@ func (r *AttachmentHTTPSrv) servePendingPreview(w http.ResponseWriter, req *http
238238
}
239239

240240
func (r *AttachmentHTTPSrv) serveUnfurlAsset(w http.ResponseWriter, req *http.Request) {
241-
ctx := Context(context.Background(), r.G(), keybase1.TLFIdentifyBehavior_CHAT_GUI, nil,
241+
ctx := globals.ChatCtx(context.Background(), r.G(), keybase1.TLFIdentifyBehavior_CHAT_GUI, nil,
242242
NewSimpleIdentifyNotifier(r.G()))
243243
defer r.Trace(ctx, func() error { return nil }, "serveUnfurlAsset")()
244244
key := req.URL.Query().Get("key")
@@ -270,7 +270,7 @@ func (r *AttachmentHTTPSrv) serveUnfurlAsset(w http.ResponseWriter, req *http.Re
270270
}
271271

272272
func (r *AttachmentHTTPSrv) serveGiphyLink(w http.ResponseWriter, req *http.Request) {
273-
ctx := Context(context.Background(), r.G(), keybase1.TLFIdentifyBehavior_CHAT_GUI, nil,
273+
ctx := globals.ChatCtx(context.Background(), r.G(), keybase1.TLFIdentifyBehavior_CHAT_GUI, nil,
274274
NewSimpleIdentifyNotifier(r.G()))
275275
defer r.Trace(ctx, func() error { return nil }, "serveGiphyLink")()
276276
key := req.URL.Query().Get("key")
@@ -396,7 +396,7 @@ func (r *AttachmentHTTPSrv) serveVideoHostPage(ctx context.Context, w http.Respo
396396
}
397397

398398
func (r *AttachmentHTTPSrv) serve(w http.ResponseWriter, req *http.Request) {
399-
ctx := Context(context.Background(), r.G(), keybase1.TLFIdentifyBehavior_CHAT_GUI, nil,
399+
ctx := globals.ChatCtx(context.Background(), r.G(), keybase1.TLFIdentifyBehavior_CHAT_GUI, nil,
400400
NewSimpleIdentifyNotifier(r.G()))
401401
defer r.Trace(ctx, func() error { return nil }, "serve")()
402402
key := req.URL.Query().Get("key")

‎go/chat/boxer.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func (b *Boxer) UnboxMessage(ctx context.Context, boxed chat1.MessageBoxed, conv
295295
if info == nil {
296296
info = new(types.BoxerEncryptionInfo)
297297
keyMembersType := b.getEffectiveMembersType(ctx, boxed, conv.GetMembersType())
298-
encryptionKey, err := CtxKeyFinder(ctx, b.G()).FindForDecryption(ctx,
298+
encryptionKey, err := globals.CtxKeyFinder(ctx, b.G()).FindForDecryption(ctx,
299299
tlfName, boxed.ClientHeader.Conv.Tlfid, conv.GetMembersType(),
300300
conv.IsPublic(), boxed.KeyGeneration, keyMembersType == chat1.ConversationMembersType_KBFS)
301301
if err != nil {
@@ -310,7 +310,7 @@ func (b *Boxer) UnboxMessage(ctx context.Context, boxed chat1.MessageBoxed, conv
310310
// If the message is exploding, load the ephemeral key.
311311
var ephemeralSeed *keybase1.TeamEk
312312
if boxed.IsEphemeral() {
313-
ek, err := CtxKeyFinder(ctx, b.G()).EphemeralKeyForDecryption(
313+
ek, err := globals.CtxKeyFinder(ctx, b.G()).EphemeralKeyForDecryption(
314314
b.G().MetaContext(ctx), tlfName, boxed.ClientHeader.Conv.Tlfid, conv.GetMembersType(),
315315
boxed.ClientHeader.TlfPublic, boxed.EphemeralMetadata().Generation,
316316
&boxed.ServerHeader.Ctime)
@@ -1115,7 +1115,7 @@ func (b *Boxer) UnboxThread(ctx context.Context, boxed chat1.ThreadViewBoxed, co
11151115
}
11161116

11171117
func (b *Boxer) getUsernameAndDevice(ctx context.Context, uid keybase1.UID, deviceID keybase1.DeviceID) (string, string, string, error) {
1118-
nun, devName, devType, err := CtxUPAKFinder(ctx, b.G()).LookupUsernameAndDevice(ctx, uid, deviceID)
1118+
nun, devName, devType, err := globals.CtxUPAKFinder(ctx, b.G()).LookupUsernameAndDevice(ctx, uid, deviceID)
11191119
if err != nil {
11201120
return "", "", "", err
11211121
}
@@ -1294,7 +1294,7 @@ func (b *Boxer) GetEncryptionInfo(ctx context.Context, msg *chat1.MessagePlainte
12941294
if err != nil {
12951295
return res, err
12961296
}
1297-
encryptionKey, nameInfo, err := CtxKeyFinder(ctx, b.G()).FindForEncryption(ctx,
1297+
encryptionKey, nameInfo, err := globals.CtxKeyFinder(ctx, b.G()).FindForEncryption(ctx,
12981298
tlfName, msg.ClientHeader.Conv.Tlfid, membersType,
12991299
msg.ClientHeader.TlfPublic)
13001300
if err != nil {
@@ -1308,7 +1308,7 @@ func (b *Boxer) GetEncryptionInfo(ctx context.Context, msg *chat1.MessagePlainte
13081308
var ephemeralSeed *keybase1.TeamEk
13091309
var pairwiseMACRecipients []keybase1.KID
13101310
if msg.IsEphemeral() {
1311-
ek, err := CtxKeyFinder(ctx, b.G()).EphemeralKeyForEncryption(
1311+
ek, err := globals.CtxKeyFinder(ctx, b.G()).EphemeralKeyForEncryption(
13121312
b.G().MetaContext(ctx), tlfName, msg.ClientHeader.Conv.Tlfid, membersType, msg.ClientHeader.TlfPublic)
13131313
if err != nil {
13141314
return res, NewBoxingCryptKeysError(err)
@@ -1337,7 +1337,7 @@ func (b *Boxer) GetEncryptionInfo(ctx context.Context, msg *chat1.MessagePlainte
13371337
// - It leaves us more flexibility in the future. If say we
13381338
// introduce a best-effort rekey mechanism for ephmeral keys,
13391339
// existing pairwise MACs will Just Work™ after a rekey.
1340-
shouldPairwiseMAC, recipients, err := CtxKeyFinder(ctx, b.G()).ShouldPairwiseMAC(
1340+
shouldPairwiseMAC, recipients, err := globals.CtxKeyFinder(ctx, b.G()).ShouldPairwiseMAC(
13411341
ctx, tlfName, msg.ClientHeader.Conv.Tlfid, membersType, msg.ClientHeader.TlfPublic)
13421342
if err != nil {
13431343
return res, err
@@ -1910,7 +1910,7 @@ func (b *Boxer) ValidSenderKey(ctx context.Context, sender gregor1.UID, key []by
19101910
kid := keybase1.KIDFromSlice(key)
19111911
ctime2 := gregor1.FromTime(ctime)
19121912

1913-
cachedUserLoader := CtxUPAKFinder(ctx, b.G())
1913+
cachedUserLoader := globals.CtxUPAKFinder(ctx, b.G())
19141914
if cachedUserLoader == nil {
19151915
return false, false, nil, NewTransientUnboxingError(fmt.Errorf("no CachedUserLoader available in context"))
19161916
}

0 commit comments

Comments
 (0)