Skip to content

Commit 9552709

Browse files
authored
Merge pull request #91 from koladev32/master
feat: add reactions payload to messages
2 parents f1c886a + 80f6bd1 commit 9552709

File tree

1 file changed

+34
-25
lines changed

1 file changed

+34
-25
lines changed

pkg/handler/conversations.go

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ var validFilterKeys = map[string]struct{}{
3939
}
4040

4141
type Message struct {
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-
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"`
5152
}
5253

5354
type User struct {
@@ -390,15 +391,22 @@ func (ch *ConversationsHandler) convertMessagesFromHistory(slackMessages []slack
390391

391392
msgText := msg.Text + text.AttachmentsTo2CSV(msg.Text, msg.Attachments)
392393

394+
var reactionParts []string
395+
for _, r := range msg.Reactions {
396+
reactionParts = append(reactionParts, fmt.Sprintf("%s:%d", r.Name, r.Count))
397+
}
398+
reactionsString := strings.Join(reactionParts, "|")
399+
393400
messages = append(messages, Message{
394-
MsgID: msg.Timestamp,
395-
UserID: msg.User,
396-
UserName: userName,
397-
RealName: realName,
398-
Text: text.ProcessText(msgText),
399-
Channel: channel,
400-
ThreadTs: msg.ThreadTimestamp,
401-
Time: timestamp,
401+
MsgID: msg.Timestamp,
402+
UserID: msg.User,
403+
UserName: userName,
404+
RealName: realName,
405+
Text: text.ProcessText(msgText),
406+
Channel: channel,
407+
ThreadTs: msg.ThreadTimestamp,
408+
Time: timestamp,
409+
Reactions: reactionsString,
402410
})
403411
}
404412

@@ -438,14 +446,15 @@ func (ch *ConversationsHandler) convertMessagesFromSearch(slackMessages []slack.
438446
msgText := msg.Text + text.AttachmentsTo2CSV(msg.Text, msg.Attachments)
439447

440448
messages = append(messages, Message{
441-
MsgID: msg.Timestamp,
442-
UserID: msg.User,
443-
UserName: userName,
444-
RealName: realName,
445-
Text: text.ProcessText(msgText),
446-
Channel: fmt.Sprintf("#%s", msg.Channel.Name),
447-
ThreadTs: threadTs,
448-
Time: timestamp,
449+
MsgID: msg.Timestamp,
450+
UserID: msg.User,
451+
UserName: userName,
452+
RealName: realName,
453+
Text: text.ProcessText(msgText),
454+
Channel: fmt.Sprintf("#%s", msg.Channel.Name),
455+
ThreadTs: threadTs,
456+
Time: timestamp,
457+
Reactions: "",
449458
})
450459
}
451460

0 commit comments

Comments
 (0)