Skip to content

Commit

Permalink
fix sbs notification chat for multiple chats
Browse files Browse the repository at this point in the history
  • Loading branch information
jakob223 committed Sep 10, 2019
1 parent b51436d commit bfe671f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
9 changes: 3 additions & 6 deletions go/teams/chatmessaging.go
Expand Up @@ -97,7 +97,7 @@ func SendChatInviteWelcomeMessage(ctx context.Context, g *libkb.GlobalContext, t
}

func SendChatSBSResolutionMessage(ctx context.Context, g *libkb.GlobalContext,
team, assertionUser, assertionService string,
convID chat1.ConversationID, team, assertionUser, assertionService string,
prover keybase1.UID) (res bool) {

if !g.Env.SendSystemChatMessages() {
Expand All @@ -118,11 +118,8 @@ func SendChatSBSResolutionMessage(ctx context.Context, g *libkb.GlobalContext,
AssertionService: assertionService,
})
body := chat1.NewMessageBodyWithSystem(subBody)

if err = g.ChatHelper.SendMsgByName(ctx, team, nil,
chat1.ConversationMembersType_IMPTEAMNATIVE,
keybase1.TLFIdentifyBehavior_CHAT_CLI, body,
chat1.MessageType_SYSTEM); err != nil {
if err = g.ChatHelper.SendMsgByID(ctx, convID, team, body,
chat1.MessageType_SYSTEM, keybase1.TLFVisibility_PRIVATE); err != nil {
g.Log.CDebugf(ctx, "SendChatSBSResolutionMessage: failed to send message: %s", err)
return false
}
Expand Down
25 changes: 20 additions & 5 deletions go/teams/handler.go
Expand Up @@ -6,6 +6,9 @@ import (
"errors"
"fmt"

"github.com/keybase/client/go/protocol/chat1"
"github.com/keybase/client/go/protocol/gregor1"

"github.com/keybase/client/go/engine"
"github.com/keybase/client/go/gregor"
"github.com/keybase/client/go/libkb"
Expand Down Expand Up @@ -445,6 +448,22 @@ func handleSBSSingle(ctx context.Context, g *libkb.GlobalContext, teamID keybase
return removeInviteID(ctx, team, invite.Id)
}

var convID chat1.ConversationID
var iteamName string
if team.IsImplicit() {
iteamName, err = team.ImplicitTeamDisplayNameString(ctx)
if err != nil {
return err
}
uid := gregor1.UID(g.ActiveDevice.UID().ToBytes())
conv, err := g.ChatHelper.NewConversation(ctx, uid, iteamName, nil,
chat1.TopicType_CHAT, chat1.ConversationMembersType_IMPTEAMNATIVE, keybase1.TLFVisibility_PRIVATE)
if err != nil {
return err
}
convID = conv.GetConvID()
}

tx := CreateAddMemberTx(team)
if err := tx.AddMemberBySBS(ctx, verifiedInvitee, invite.Role); err != nil {
return err
Expand All @@ -455,13 +474,9 @@ func handleSBSSingle(ctx context.Context, g *libkb.GlobalContext, teamID keybase

// Send chat welcome message
if team.IsImplicit() {
iteamName, err := team.ImplicitTeamDisplayNameString(ctx)
if err != nil {
return err
}
g.Log.CDebugf(ctx,
"sending resolution message for successful SBS handle")
SendChatSBSResolutionMessage(ctx, g, iteamName,
SendChatSBSResolutionMessage(ctx, g, convID, iteamName,
string(invite.Name), ityp, verifiedInvitee.Uid)

} else {
Expand Down

0 comments on commit bfe671f

Please sign in to comment.