diff options
| author | ReAnzu <github@reanzu.com> | 2018-03-08 00:47:58 -0600 |
|---|---|---|
| committer | rr- <rr-@sakuya.pl> | 2018-03-08 07:48:45 +0100 |
| commit | 12ec43f09887ca1682c6d02557336f3f45c7ba30 (patch) | |
| tree | e61519c4a7e1ee90621f7ec51879e3f2629867cc /server/szurubooru/api/post_api.py | |
| parent | 4ff8be6a2f0f2156a42790bcb56dee6f53acea92 (diff) | |
server/posts: auto convert GIFs to WEBMs/MP4s
- Default setting is false for both conversions, as this will require
additional resources of the server, but is bandwidth friendly for
viewers
- WEBM conversion is slow, but better quality than MP4 conversion with
a typically smaller file size
- Tags are copied over from the original upload
- Snapshots are generated for the new auto posts
Diffstat (limited to 'server/szurubooru/api/post_api.py')
| -rw-r--r-- | server/szurubooru/api/post_api.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/server/szurubooru/api/post_api.py b/server/szurubooru/api/post_api.py index 27f10c1..aaa7437 100644 --- a/server/szurubooru/api/post_api.py +++ b/server/szurubooru/api/post_api.py @@ -1,4 +1,4 @@ -from typing import Optional, Dict +from typing import Optional, Dict, List from datetime import datetime from szurubooru import db, model, errors, rest, search from szurubooru.func import ( @@ -69,13 +69,26 @@ def create_post( posts.update_post_thumbnail(post, ctx.get_file('thumbnail')) ctx.session.add(post) ctx.session.flush() - snapshots.create(post, None if anonymous else ctx.user) - for tag in new_tags: - snapshots.create(tag, None if anonymous else ctx.user) + create_snapshots_for_post(post, new_tags, None if anonymous else ctx.user) + alternate_format_posts = posts.generate_alternate_formats(post, content) + for alternate_post, alternate_post_new_tags in alternate_format_posts: + create_snapshots_for_post( + alternate_post, + alternate_post_new_tags, + None if anonymous else ctx.user) ctx.session.commit() return _serialize_post(ctx, post) +def create_snapshots_for_post( + post: model.Post, + new_tags: List[model.Tag], + user: Optional[model.User]): + snapshots.create(post, user) + for tag in new_tags: + snapshots.create(tag, user) + + @rest.routes.get('/post/(?P<post_id>[^/]+)/?') def get_post(ctx: rest.Context, params: Dict[str, str]) -> rest.Response: auth.verify_privilege(ctx.user, 'posts:view') |