Skip to content

Commit 7299cab

Browse files
authored
Add teams and slack parent activity id support, remove not used activityId field from gRPC (#1387)
1 parent 577e1e8 commit 7299cab

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

pkg/api/cloudteams/cloud_teams.pb.go

+2-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bot/slack_cloud.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ func (b *CloudSlack) handleMessage(ctx context.Context, event slackMessage) erro
514514
IsKnown: exists,
515515
CommandOrigin: event.CommandOrigin,
516516
SlackState: event.State,
517+
ParentActivityID: event.GetTimestamp(),
517518
},
518519
Message: request,
519520
User: execute.UserInput{
@@ -587,7 +588,7 @@ func (b *CloudSlack) send(ctx context.Context, event slackMessage, resp interact
587588
return fmt.Errorf("while posting Slack message visible only to user: %w", err)
588589
}
589590
} else {
590-
if ts := b.getThreadOptionIfNeeded(event, file); ts != nil {
591+
if ts := b.getThreadOptionIfNeeded(resp, event, file); ts != nil {
591592
options = append(options, ts)
592593
}
593594

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

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

650+
if resp.ParentActivityID != "" {
651+
return slack.MsgOptionTS(resp.Message.ParentActivityID)
652+
}
653+
649654
if ts := event.GetTimestamp(); ts != "" {
650655
return slack.MsgOptionTS(ts)
651656
}

pkg/bot/teams_cloud.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ func (b *CloudTeams) handleStreamMessage(ctx context.Context, data *pb.CloudActi
285285
MessageType: pb.MessageType_MESSAGE_EXECUTOR,
286286
TeamId: channel.teamID,
287287
ConversationId: conversationRef.Conversation.ID,
288-
ActivityId: conversationRef.ActivityID, // activity ID allows us to send it as a thread message
289288
Data: raw,
290289
},
291290
}, nil
@@ -309,6 +308,7 @@ func (b *CloudTeams) processMessage(ctx context.Context, act schema.Activity, ch
309308
SourceBindings: channel.Bindings.Sources,
310309
CommandOrigin: b.mapToCommandOrigin(act),
311310
DisplayName: channelDisplayName,
311+
ParentActivityID: act.Conversation.ID,
312312
},
313313
Message: trimmedMsg,
314314
User: execute.UserInput{
@@ -389,7 +389,6 @@ func (b *CloudTeams) sendAgentActivity(ctx context.Context, msg interactive.Core
389389
Message: &pb.Message{
390390
MessageType: pb.MessageType_MESSAGE_SOURCE,
391391
TeamId: channel.teamID,
392-
ActivityId: "", // empty so it will be sent on root instead of sending as a thread message
393392
ConversationId: channel.ID,
394393
Data: raw,
395394
},

proto/cloud_teams.proto

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ enum MessageType {
1616

1717
message Message {
1818
string teamId = 1;
19-
string activityId = 2;
2019
string conversationId = 3;
2120
MessageType messageType = 4;
2221
bytes data = 5;

0 commit comments

Comments
 (0)