server/posts/upload: edit default flag behavior
The 'loop' flag will be auto-selected by default on video posts if the flags parameter is undefined when creating a new post.
This commit is contained in:
parent
c60ec22b92
commit
65202189e1
2 changed files with 8 additions and 8 deletions
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue