about summary refs log tree commit diff
path: root/app/lib/activitypub/activity/create.rb
diff options
context:
space:
mode:
authorSpencer Alves <impiaaa@gmail.com>2018-05-31 21:33:16 -0700
committerSpencer Alves <impiaaa@gmail.com>2018-05-31 21:33:16 -0700
commit7d2e6429c27c5ddc8ef3d2366c44329092e07f77 (patch)
tree7cfd2035f69616a369b2f3762ce9cefe61c2bd22 /app/lib/activitypub/activity/create.rb
parentf2ff167c1a8df9b2521d33fcca15b8d5c67c50b1 (diff)
parente396fbfe3bf4d2a404e78e73cff1a609dd0a9bfb (diff)
Merge branch 'glitch' into thread-icon
Diffstat (limited to 'app/lib/activitypub/activity/create.rb')
-rw-r--r--app/lib/activitypub/activity/create.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index 8d17a4ebe..869749f1e 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -11,6 +11,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
       if lock.acquired?
         @status = find_existing_status
         process_status if @status.nil?
+      else
+        raise Mastodon::RaceConditionError
       end
     end
 
@@ -76,9 +78,12 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
     return if tag['name'].blank?
 
     hashtag = tag['name'].gsub(/\A#/, '').mb_chars.downcase
-    hashtag = Tag.where(name: hashtag).first_or_initialize(name: hashtag)
+    hashtag = Tag.where(name: hashtag).first_or_create(name: hashtag)
+
+    return if status.tags.include?(hashtag)
 
     status.tags << hashtag
+    TrendingTags.record_use!(hashtag, status.account, status.created_at)
   rescue ActiveRecord::RecordInvalid
     nil
   end