Skip to content

Commit af74a8d

Browse files
committed
change format for reactions field
1 parent 41c1dc4 commit af74a8d

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

pkg/handler/conversations.go

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,17 @@ var validFilterKeys = map[string]struct{}{
3838
"during": {},
3939
}
4040

41-
type Reaction struct {
42-
Name string `json:"name"`
43-
Count int `json:"count"`
44-
Users []string `json:"users"`
45-
}
46-
4741
type Message struct {
48-
MsgID string `json:"msgID"`
49-
UserID string `json:"userID"`
50-
UserName string `json:"userUser"`
51-
RealName string `json:"realName"`
52-
Channel string `json:"channelID"`
53-
ThreadTs string `json:"ThreadTs"`
54-
Text string `json:"text"`
55-
Time string `json:"time"`
56-
Reactions []Reaction `json:"reactions,omitempty"`
57-
Cursor string `json:"cursor"`
42+
MsgID string `json:"msgID"`
43+
UserID string `json:"userID"`
44+
UserName string `json:"userUser"`
45+
RealName string `json:"realName"`
46+
Channel string `json:"channelID"`
47+
ThreadTs string `json:"ThreadTs"`
48+
Text string `json:"text"`
49+
Time string `json:"time"`
50+
Reactions string `json:"reactions,omitempty"`
51+
Cursor string `json:"cursor"`
5852
}
5953

6054
type User struct {
@@ -397,15 +391,12 @@ func (ch *ConversationsHandler) convertMessagesFromHistory(slackMessages []slack
397391

398392
msgText := msg.Text + text.AttachmentsTo2CSV(msg.Text, msg.Attachments)
399393

400-
// Convert reactions from slack.ItemReaction to local Reaction type
401-
var reactions []Reaction
394+
// Convert reactions to flat pipe-separated format: emoji:count|emoji:count
395+
var reactionParts []string
402396
for _, r := range msg.Reactions {
403-
reactions = append(reactions, Reaction{
404-
Name: r.Name,
405-
Count: r.Count,
406-
Users: r.Users,
407-
})
397+
reactionParts = append(reactionParts, fmt.Sprintf("%s:%d", r.Name, r.Count))
408398
}
399+
reactionsString := strings.Join(reactionParts, "|")
409400

410401
messages = append(messages, Message{
411402
MsgID: msg.Timestamp,
@@ -416,7 +407,7 @@ func (ch *ConversationsHandler) convertMessagesFromHistory(slackMessages []slack
416407
Channel: channel,
417408
ThreadTs: msg.ThreadTimestamp,
418409
Time: timestamp,
419-
Reactions: reactions,
410+
Reactions: reactionsString,
420411
})
421412
}
422413

@@ -466,7 +457,7 @@ func (ch *ConversationsHandler) convertMessagesFromSearch(slackMessages []slack.
466457
Channel: fmt.Sprintf("#%s", msg.Channel.Name),
467458
ThreadTs: threadTs,
468459
Time: timestamp,
469-
Reactions: nil, // Not available in search results
460+
Reactions: "", // Not available in search results
470461
})
471462
}
472463

0 commit comments

Comments
 (0)