]> cat aescling's git repositories - mastodon.git/commitdiff
Fix custom emoji category creation silently erroring out on duplicate category (...
authorThibG <thib@sitedethib.com>
Wed, 18 Dec 2019 15:56:59 +0000 (16:56 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 18 Dec 2019 15:56:59 +0000 (16:56 +0100)
Instead, just re-use the existing category if any.

Fixes #12608

app/models/form/custom_emoji_batch.rb

index 076e8c9e39aebd7b620c473cc11d6d0af7b93e04..6b7ea5355dd1dcbd6c14fc0f77a7e02761a1acca 100644 (file)
@@ -40,7 +40,7 @@ class Form::CustomEmojiBatch
       if category_id.present?
         CustomEmojiCategory.find(category_id)
       elsif category_name.present?
-        CustomEmojiCategory.create!(name: category_name)
+        CustomEmojiCategory.find_or_create_by!(name: category_name)
       end
     end