about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-07-28 05:59:51 +0200
committerGitHub <noreply@github.com>2019-07-28 05:59:51 +0200
commitf371b32137ccd7e74ca29d25af2072fb79654b15 (patch)
treed9ba19f1caab5674a5b4f828b39c938564aa142c /app/lib
parent4cc29eb5ad106c267ff16c9f49f145bc34d1aae0 (diff)
Change hashtags to preserve first-used casing (#11416)
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/activitypub/activity/create.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index 56c24680a..000b77df5 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -148,12 +148,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
   def process_hashtag(tag)
     return if tag['name'].blank?
 
-    hashtag = tag['name'].gsub(/\A#/, '').mb_chars.downcase
-    hashtag = Tag.where(name: hashtag).first_or_create!(name: hashtag)
-
-    return if @tags.include?(hashtag)
-
-    @tags << hashtag
+    Tag.find_or_create_by_names(tag['name']) do |hashtag|
+      @tags << hashtag unless @tags.include?(hashtag)
+    end
   rescue ActiveRecord::RecordInvalid
     nil
   end