diff --git a/server/szurubooru/api/post_api.py b/server/szurubooru/api/post_api.py index 84094845..09aea90a 100644 --- a/server/szurubooru/api/post_api.py +++ b/server/szurubooru/api/post_api.py @@ -54,7 +54,9 @@ def create_post( source = ctx.get_param_as_string('contentUrl', default='') relations = ctx.get_param_as_int_list('relations', default=[]) notes = ctx.get_param_as_list('notes', default=[]) - flags = ctx.get_param_as_string_list('flags', default=[]) + flags = ctx.get_param_as_string_list( + 'flags', + default=posts.get_default_flags(content)) post, new_tags = posts.create_post( content, tag_names, None if anonymous else ctx.user) @@ -65,7 +67,6 @@ def create_post( posts.update_post_relations(post, relations) posts.update_post_notes(post, notes) posts.update_post_flags(post, flags) - posts.test_sound(post, content) if ctx.has_file('thumbnail'): posts.update_post_thumbnail(post, ctx.get_file('thumbnail')) ctx.session.add(post) diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py index 0f2cb51c..f0224b40 100644 --- a/server/szurubooru/func/posts.py +++ b/server/szurubooru/func/posts.py @@ -467,15 +467,14 @@ def generate_alternate_formats(post: model.Post, content: bytes) \ return new_posts -def test_sound(post: model.Post, content: bytes) -> None: - assert post +def get_default_flags(content: bytes) -> List[str]: assert content + ret = [] if mime.is_video(mime.get_mime_type(content)): + ret.append(model.Post.FLAG_LOOP) if images.Image(content).check_for_sound(): - flags = post.flags - if model.Post.FLAG_SOUND not in flags: - flags.append(model.Post.FLAG_SOUND) - update_post_flags(post, flags) + ret.append(model.Post.FLAG_SOUND) + return ret def purge_post_signature(post: model.Post) -> None: