diff --git a/app/models/post.rb b/app/models/post.rb index 31b994ba6..e098aa846 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -402,7 +402,7 @@ class Post < ApplicationRecord end def add_automatic_tags(tags) - tags -= %w[incredibly_absurdres absurdres highres lowres flash video ugoira animated_gif animated_png exif_rotation non-repeating_animation non-web_source wide_image tall_image sound] + tags -= %w[incredibly_absurdres absurdres highres lowres flash video ugoira animated_gif animated_png exif_rotation non-repeating_animation non-web_source wide_image tall_image] if tags.size >= 30 tags -= ["tagme"] @@ -472,6 +472,9 @@ class Post < ApplicationRecord tags << "exif_rotation" if media_asset.is_rotated? tags << "non-repeating_animation" if media_asset.is_non_repeating_animation? tags << "ai-generated" if media_asset.is_ai_generated? + + # Allow Flash files to be manually tagged as `sound`; other files are automatically tagged. + tags -= ["sound"] unless is_flash? tags << "sound" if media_asset.has_sound? tags diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 3a2fa57d0..448eb206f 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -1269,7 +1269,7 @@ class PostTest < ActiveSupport::TestCase @media_asset = MediaAsset.upload!("test/files/mp4/test-silent-audio.mp4") @post.update!(md5: @media_asset.md5) @post.reload.update!(tag_string: "sound") - assert_equal("animated tagme", @post.tag_string) + assert_equal("animated", @post.tag_string) end end @@ -1282,6 +1282,15 @@ class PostTest < ActiveSupport::TestCase end end + context "a Flash file with the sound tag" do + should "not automatically remove the sound tag" do + @post = create(:post, file_ext: "swf", media_asset: build(:media_asset, file_ext: "swf")) + @post.update!(tag_string: "sound") + + assert_equal("flash sound", @post.tag_string) + end + end + context "a post with a non-web source" do should "automatically add the non-web_source tag" do @post.update!(source: "this was once revealed to me in a dream")