Skip to content

Commit

Permalink
add extractSlackReactionName method
Browse files Browse the repository at this point in the history
  • Loading branch information
sho0126hiro committed Oct 27, 2022
1 parent 3e84483 commit d0e479b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/internal/domain/service/slack_mentioned.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (s *slackMentionedService) Parse(message string) *model.MentionParseResult
if s.isSlackReaction(reaction) {
return &model.MentionParseResult{
Message: message,
Reaction: strings.ReplaceAll(s.removeSkinTone(reaction), ":", ""),
Reaction: s.extractSlackReactionName(s.removeSkinTone(reaction)),
}
}
// invalid argument (not emoji)
Expand All @@ -65,6 +65,10 @@ func (s *slackMentionedService) isSlackReaction(reaction string) bool {
return strings.HasPrefix(reaction, ":") && strings.HasSuffix(reaction, ":")
}

func (s *slackMentionedService) extractSlackReactionName(reaction string) string {
return strings.ReplaceAll(reaction, ":", "")
}

func (s *slackMentionedService) removeSkinTone(reaction string) string {
for _, st := range types.ReactionSkinTones {
reaction = strings.ReplaceAll(reaction, st, "")
Expand Down

0 comments on commit d0e479b

Please sign in to comment.