Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add teams and slack parent activity id support, remove not used activityId field from gRPC #1387

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions pkg/api/cloudteams/cloud_teams.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions pkg/bot/slack_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ func (b *CloudSlack) handleMessage(ctx context.Context, event slackMessage) erro
IsKnown: exists,
CommandOrigin: event.CommandOrigin,
SlackState: event.State,
ParentActivityID: event.GetTimestamp(),
},
Message: request,
User: execute.UserInput{
Expand Down Expand Up @@ -587,7 +588,7 @@ func (b *CloudSlack) send(ctx context.Context, event slackMessage, resp interact
return fmt.Errorf("while posting Slack message visible only to user: %w", err)
}
} else {
if ts := b.getThreadOptionIfNeeded(event, file); ts != nil {
if ts := b.getThreadOptionIfNeeded(resp, event, file); ts != nil {
options = append(options, ts)
}

Expand Down Expand Up @@ -636,7 +637,7 @@ func (b *CloudSlack) BotName() string {
return fmt.Sprintf("<@%s>", b.botID)
}

func (b *CloudSlack) getThreadOptionIfNeeded(event slackMessage, file *slack.File) slack.MsgOption {
func (b *CloudSlack) getThreadOptionIfNeeded(resp interactive.CoreMessage, event slackMessage, file *slack.File) slack.MsgOption {
if file != nil {
// If the message was already as a file attachment, reply it a given thread
for _, share := range file.Shares.Public {
Expand All @@ -646,6 +647,10 @@ func (b *CloudSlack) getThreadOptionIfNeeded(event slackMessage, file *slack.Fil
}
}

if resp.ParentActivityID != "" {
return slack.MsgOptionTS(resp.Message.ParentActivityID)
}

if ts := event.GetTimestamp(); ts != "" {
return slack.MsgOptionTS(ts)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/bot/teams_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ func (b *CloudTeams) handleStreamMessage(ctx context.Context, data *pb.CloudActi
MessageType: pb.MessageType_MESSAGE_EXECUTOR,
TeamId: channel.teamID,
ConversationId: conversationRef.Conversation.ID,
ActivityId: conversationRef.ActivityID, // activity ID allows us to send it as a thread message
Data: raw,
},
}, nil
Expand All @@ -309,6 +308,7 @@ func (b *CloudTeams) processMessage(ctx context.Context, act schema.Activity, ch
SourceBindings: channel.Bindings.Sources,
CommandOrigin: b.mapToCommandOrigin(act),
DisplayName: channelDisplayName,
ParentActivityID: act.Conversation.ID,
},
Message: trimmedMsg,
User: execute.UserInput{
Expand Down Expand Up @@ -389,7 +389,6 @@ func (b *CloudTeams) sendAgentActivity(ctx context.Context, msg interactive.Core
Message: &pb.Message{
MessageType: pb.MessageType_MESSAGE_SOURCE,
TeamId: channel.teamID,
ActivityId: "", // empty so it will be sent on root instead of sending as a thread message
ConversationId: channel.ID,
Data: raw,
},
Expand Down
1 change: 0 additions & 1 deletion proto/cloud_teams.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ enum MessageType {

message Message {
string teamId = 1;
string activityId = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to remove the field as we updated the plugin contract version recently. Is that correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's about cloud_teams, so it is not related, it's only about control-plane <-> agent communication. They should work properly as this field was not used anyway 👍

string conversationId = 3;
MessageType messageType = 4;
bytes data = 5;
Expand Down
Loading