From d0e479b5388f198e2d0569df6ba0996a6bea0490 Mon Sep 17 00:00:00 2001 From: Sho Hirose Date: Fri, 28 Oct 2022 00:50:47 +0900 Subject: [PATCH] add extractSlackReactionName method --- app/internal/domain/service/slack_mentioned.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/internal/domain/service/slack_mentioned.go b/app/internal/domain/service/slack_mentioned.go index b40ff3d..a54b9b7 100644 --- a/app/internal/domain/service/slack_mentioned.go +++ b/app/internal/domain/service/slack_mentioned.go @@ -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) @@ -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, "")