Skip to content

Commit a829f67

Browse files
authored
type ids exposed by the api (keybase#21975)
* type ids exposed by the api * ConvIDStr * refactor * cleanup * revert bot settings change * kbfs * bind
1 parent 793f8ee commit a829f67

68 files changed

Lines changed: 472 additions & 428 deletions

Some content is hidden

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

‎go/badges/badgestate.go‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ type BadgeState struct {
4040
env *libkb.Env
4141
state keybase1.BadgeState
4242

43-
inboxVers chat1.InboxVers
44-
// Map from ConversationID.String to BadgeConversationInfo.
45-
chatUnreadMap map[string]keybase1.BadgeConversationInfo
43+
inboxVers chat1.InboxVers
44+
chatUnreadMap map[chat1.ConvIDStr]keybase1.BadgeConversationInfo
4645

4746
walletUnreadMap map[stellar1.AccountID]int
4847
}
@@ -63,7 +62,7 @@ func newBadgeState(log logger.Logger, env *libkb.Env) *BadgeState {
6362
log: log,
6463
env: env,
6564
inboxVers: chat1.InboxVers(0),
66-
chatUnreadMap: make(map[string]keybase1.BadgeConversationInfo),
65+
chatUnreadMap: make(map[chat1.ConvIDStr]keybase1.BadgeConversationInfo),
6766
walletUnreadMap: make(map[stellar1.AccountID]int),
6867
localChatState: dummyLocalChatState{},
6968
}
@@ -426,7 +425,7 @@ func (b *BadgeState) UpdateWithChatFull(ctx context.Context, update chat1.Unread
426425
case chat1.SyncInboxResType_CURRENT:
427426
case chat1.SyncInboxResType_INCREMENTAL:
428427
case chat1.SyncInboxResType_CLEAR:
429-
b.chatUnreadMap = make(map[string]keybase1.BadgeConversationInfo)
428+
b.chatUnreadMap = make(map[chat1.ConvIDStr]keybase1.BadgeConversationInfo)
430429
}
431430

432431
for _, upd := range update.Updates {
@@ -442,7 +441,7 @@ func (b *BadgeState) Clear() {
442441

443442
b.state = keybase1.BadgeState{}
444443
b.inboxVers = chat1.InboxVers(0)
445-
b.chatUnreadMap = make(map[string]keybase1.BadgeConversationInfo)
444+
b.chatUnreadMap = make(map[chat1.ConvIDStr]keybase1.BadgeConversationInfo)
446445
b.walletUnreadMap = make(map[stellar1.AccountID]int)
447446
}
448447

‎go/bind/extension.go‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,24 @@ func (n *extensionNotifyListener) NewChatActivity(uid keybase1.UID, activity cha
9696
// skip pending message notification
9797
return
9898
}
99-
strConvID := activity.IncomingMessage().ConvID.String()
99+
convID := activity.IncomingMessage().ConvID.String()
100100
outboxID := msg.GetOutboxID()
101101
if outboxID != nil {
102102
n.trigger(*outboxID)
103103
}
104-
extensionPushResult(nil, strConvID, "message")
104+
extensionPushResult(nil, convID, "message")
105105
case chat1.ChatActivityType_FAILED_MESSAGE:
106106
err := errors.New("message failed")
107107
recs := activity.FailedMessage().OutboxRecords
108108
for _, r := range recs {
109-
strConvID := r.ConvID.String()
109+
convID := r.ConvID.String()
110110
n.trigger(r.OutboxID)
111-
extensionPushResult(err, strConvID, "message")
111+
extensionPushResult(err, convID, "message")
112112
}
113113
for _, r := range recs {
114-
strConvID := r.ConvID.String()
114+
convID := r.ConvID.String()
115115
strOutboxID := r.OutboxID.String()
116-
extensionRegisterFailure(ctx, n.G(), err, strConvID, strOutboxID)
116+
extensionRegisterFailure(ctx, n.G(), err, convID, strOutboxID)
117117
}
118118
}
119119
}
@@ -321,12 +321,12 @@ func extensionRegisterSendNonblock(ctx context.Context, gc *globals.Context, con
321321
}(bctx)
322322
}
323323

324-
func extensionRegisterFailure(ctx context.Context, gc *globals.Context, err error, strConvID,
324+
func extensionRegisterFailure(ctx context.Context, gc *globals.Context, err error, convIDStr chat1.ConvIDStr,
325325
strOutboxID string) {
326326
if err == nil {
327327
return
328328
}
329-
convID, err := chat1.MakeConvID(strConvID)
329+
convID, err := chat1.MakeConvID(convIDStr.String())
330330
if err != nil {
331331
kbCtx.Log.CDebugf(ctx, "extensionRegisterFailure: invalid convID: %s", err)
332332
return
@@ -476,14 +476,14 @@ func ExtensionPostText(strConvID, name string, public bool, membersType int, bod
476476
return nil
477477
}
478478

479-
func extensionPushResult(err error, strConvID, typ string) {
479+
func extensionPushResult(err error, convID chat1.ConvIDStr, typ string) {
480480
var msg string
481481
if err != nil {
482482
msg = fmt.Sprintf("We could not send your %s. Please try from the Keybase app.", typ)
483483
} else {
484484
msg = fmt.Sprintf("Your %s was shared successfully.", typ)
485485
}
486-
extensionPusher.LocalNotification("extension", msg, -1, "default", strConvID, "chat.extension")
486+
extensionPusher.LocalNotification("extension", msg, -1, "default", convID.String(), "chat.extension")
487487
}
488488

489489
func extensionCreateUploadTemp(ctx context.Context, gc *globals.Context, outboxID chat1.OutboxID,
@@ -689,7 +689,7 @@ func savedConvFile() *encrypteddb.EncryptedFile {
689689

690690
func putSavedConv(ctx context.Context, strConvID, name string, public bool, membersType int) {
691691
item := storage.SharedInboxItem{
692-
ConvID: strConvID,
692+
ConvID: chat1.ConvIDStr(strConvID),
693693
Name: name,
694694
Public: public,
695695
MembersType: chat1.ConversationMembersType(membersType),

‎go/bind/keybase.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ func pushPendingMessageFailure(obrs []chat1.OutboxRecord, pusher PushNotifier) {
489489
kbCtx.Log.Debug("pushPendingMessageFailure: pushing convID: %s", obr.ConvID)
490490
pusher.LocalNotification("failedpending",
491491
"Heads up! Your message hasn't sent yet, tap here to retry.",
492-
-1, "default", obr.ConvID.String(), "chat.failedpending")
492+
-1, "default", obr.ConvID.String().String(), "chat.failedpending")
493493
return
494494
}
495495
}

‎go/chat/botcommands_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func TestBotCommandManager(t *testing.T) {
131131
require.Equal(t, "status", cmds[0].Name)
132132

133133
// test team
134-
teamID, err := keybase1.TeamIDFromString(teamConv.Triple.Tlfid.String())
134+
teamID, err := keybase1.TeamIDFromString(teamConv.Triple.Tlfid.String().String())
135135
require.NoError(t, err)
136136
pollForSeqno := func(expectedSeqno keybase1.Seqno) {
137137
found := false

‎go/chat/bots/commands.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type CachingBotCommandManager struct {
6464
edb *encrypteddb.EncryptedDB
6565
commandUpdateCh chan *commandUpdaterJob
6666
queuedUpdatedMu sync.Mutex
67-
queuedUpdates map[string]*commandUpdaterJob
67+
queuedUpdates map[chat1.ConvIDStr]*commandUpdaterJob
6868
}
6969

7070
func NewCachingBotCommandManager(g *globals.Context, ri func() chat1.RemoteInterface) *CachingBotCommandManager {
@@ -80,7 +80,7 @@ func NewCachingBotCommandManager(g *globals.Context, ri func() chat1.RemoteInter
8080
ri: ri,
8181
edb: encrypteddb.New(g.ExternalG(), dbFn, keyFn),
8282
commandUpdateCh: make(chan *commandUpdaterJob, 100),
83-
queuedUpdates: make(map[string]*commandUpdaterJob),
83+
queuedUpdates: make(map[chat1.ConvIDStr]*commandUpdaterJob),
8484
}
8585
}
8686

‎go/chat/commands/giphy.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func (d defaultGiphySearcher) Search(mctx libkb.MetaContext, apiKeySource types.
2727
type Giphy struct {
2828
sync.Mutex
2929
*baseCommand
30-
shownResults map[string]*string
31-
shownWindow map[string]bool
30+
shownResults map[chat1.ConvIDStr]*string
31+
shownWindow map[chat1.ConvIDStr]bool
3232
currentOpCancelFn context.CancelFunc
3333
currentOpDoneCb chan struct{}
3434
searcher giphySearcher
@@ -38,8 +38,8 @@ func NewGiphy(g *globals.Context) *Giphy {
3838
usage := "Search for and post GIFs"
3939
return &Giphy{
4040
baseCommand: newBaseCommand(g, "giphy", "[search terms]", usage, true),
41-
shownResults: make(map[string]*string),
42-
shownWindow: make(map[string]bool),
41+
shownResults: make(map[chat1.ConvIDStr]*string),
42+
shownWindow: make(map[chat1.ConvIDStr]bool),
4343
searcher: defaultGiphySearcher{},
4444
}
4545
}

‎go/chat/convsource.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ func (s *HybridConversationSource) Push(ctx context.Context, convID chat1.Conver
501501
return decmsg, continuousUpdate, err
502502
}
503503
if msg.ClientHeader.Sender.Eq(uid) && conv.GetMembersType() == chat1.ConversationMembersType_TEAM {
504-
teamID, err := keybase1.TeamIDFromString(conv.Conv.Metadata.IdTriple.Tlfid.String())
504+
teamID, err := keybase1.TeamIDFromString(conv.Conv.Metadata.IdTriple.Tlfid.String().String())
505505
if err != nil {
506506
s.Debug(ctx, "Push: failed to get team ID: %v", err)
507507
} else {

‎go/chat/ephemeral_purger.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ func (q *queueItem) String() string {
3636
type priorityQueue struct {
3737
sync.RWMutex
3838

39-
queue []*queueItem
40-
// convID -> *queueItem
41-
itemMap map[string]*queueItem
39+
queue []*queueItem
40+
itemMap map[chat1.ConvIDStr]*queueItem
4241
}
4342

4443
func newPriorityQueue() *priorityQueue {
4544
return &priorityQueue{
4645
queue: []*queueItem{},
47-
itemMap: make(map[string]*queueItem),
46+
itemMap: make(map[chat1.ConvIDStr]*queueItem),
4847
}
4948
}
5049

‎go/chat/flip/chat_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type chatClient struct {
2929
ch chan GameMessageWrappedEncoded
3030
server *chatServer
3131
dealer *Dealer
32-
history map[string]bool
32+
history map[chat1.ConvIDStr]bool
3333
clock clockwork.FakeClock
3434
deliver func(m GameMessageWrappedEncoded)
3535
}
@@ -123,7 +123,7 @@ func (s *chatServer) newClient() *chatClient {
123123
me: newTestUser(),
124124
ch: make(chan GameMessageWrappedEncoded, 1000),
125125
server: s,
126-
history: make(map[string]bool),
126+
history: make(map[chat1.ConvIDStr]bool),
127127
}
128128
ret.dealer = NewDealer(ret)
129129
ret.deliver = func(m GameMessageWrappedEncoded) {

‎go/chat/flip/dealer.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (m GameMessageWrapped) GameMetadata() GameMetadata {
3939
}
4040

4141
func (g GameMetadata) ToKey() GameKey {
42-
return GameKey(strings.Join([]string{g.Initiator.U.String(), g.Initiator.D.String(), g.ConversationID.String(), g.GameID.String()}, ","))
42+
return GameKey(strings.Join([]string{g.Initiator.U.String(), g.Initiator.D.String(), g.ConversationID.String().String(), g.GameID.String().String()}, ","))
4343
}
4444

4545
func (g GameMetadata) String() string {

0 commit comments

Comments
 (0)