From 4920229a3b6e1d7dde536bc9ff766542b05d935c Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 20 Aug 2021 12:26:56 +0200 Subject: Database updates (#144) * start moving some database stuff around * continue moving db stuff around * more fiddling * more updates * and some more * and yet more * i broke SOMETHING but what, it's a mystery * tidy up * vendor ttlcache * use ttlcache * fix up some tests * rename some stuff * little reminder * some more updates --- internal/util/statustools.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'internal/util/statustools.go') diff --git a/internal/util/statustools.go b/internal/util/statustools.go index ce5860c6d..4a89e60f6 100644 --- a/internal/util/statustools.go +++ b/internal/util/statustools.go @@ -34,7 +34,7 @@ func DeriveMentionsFromStatus(status string) []string { for _, m := range mentionFinderRegex.FindAllStringSubmatch(status, -1) { mentionedAccounts = append(mentionedAccounts, m[1]) } - return unique(mentionedAccounts) + return UniqueStrings(mentionedAccounts) } // DeriveHashtagsFromStatus takes a plaintext (ie., not html-formatted) status, @@ -46,7 +46,7 @@ func DeriveHashtagsFromStatus(status string) []string { for _, m := range HashtagFinderRegex.FindAllStringSubmatch(status, -1) { tags = append(tags, strings.TrimPrefix(m[1], "#")) } - return unique(tags) + return UniqueStrings(tags) } // DeriveEmojisFromStatus takes a plaintext (ie., not html-formatted) status, @@ -57,7 +57,7 @@ func DeriveEmojisFromStatus(status string) []string { for _, m := range emojiFinderRegex.FindAllStringSubmatch(status, -1) { emojis = append(emojis, m[1]) } - return unique(emojis) + return UniqueStrings(emojis) } // ExtractMentionParts extracts the username test_user and the domain example.org @@ -79,16 +79,3 @@ func ExtractMentionParts(mention string) (username, domain string, err error) { func IsMention(mention string) bool { return mentionNameRegex.MatchString(strings.ToLower(mention)) } - -// unique returns a deduplicated version of a given string slice. -func unique(s []string) []string { - keys := make(map[string]bool) - list := []string{} - for _, entry := range s { - if _, value := keys[entry]; !value { - keys[entry] = true - list = append(list, entry) - } - } - return list -} -- cgit v1.2.3