diff --git a/API.md b/API.md index f4a1f61..79c67ab 100644 --- a/API.md +++ b/API.md @@ -1440,7 +1440,7 @@ experience. "name": <name>, "color": <color>, "usages": <usages> - "default": <is_default> + "default": <is-default> } ``` @@ -1449,7 +1449,7 @@ experience. - `<name>`: the category name. - `<color>`: the category color. - `<usages>`: how many tags is the given category used with. -- `<is_default>`: whether the tag category is the default one. +- `<is-default>`: whether the tag category is the default one. ## Detailed tag category **Description** @@ -1560,7 +1560,8 @@ One file together with its metadata posted to the site. "featureCount": <feature-count>, "lastFeatureTime": <last-feature-time>, "favoritedBy": <favorited-by>, - "hasCustomThumbnail": <has-custom-thumbnail> + "hasCustomThumbnail": <has-custom-thumbnail>, + "mimeType": <mime-type> } ``` @@ -1610,6 +1611,8 @@ One file together with its metadata posted to the site. RFC 3339. - `<favorited-by>`: list of users, serialized as [user resources](#user). - `<has-custom-thumbnail>`: whether the post uses custom thumbnail. +- `<mime-type>`: subsidiary to `<type>`, used to tell exact content format; + useful for `<video>` tags for instance. ## Detailed post **Description** diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py index 7dce0e9..f7015f4 100644 --- a/server/szurubooru/func/posts.py +++ b/server/szurubooru/func/posts.py @@ -89,6 +89,7 @@ def serialize_post(post, authenticated_user): 'favoritedBy': [users.serialize_user(rel.user, authenticated_user) \ for rel in post.favorited_by], 'hasCustomThumbnail': files.has(get_post_thumbnail_backup_path(post)), + 'mimeType': post.mime_type, } if authenticated_user: diff --git a/server/szurubooru/tests/func/test_posts.py b/server/szurubooru/tests/func/test_posts.py index f24c1f6..e032586 100644 --- a/server/szurubooru/tests/func/test_posts.py +++ b/server/szurubooru/tests/func/test_posts.py @@ -64,7 +64,8 @@ def test_serialize_note(): def test_serialize_empty_post(): assert posts.serialize_post(None, None) is None -def test_serialize_post(post_factory, user_factory, tag_factory): +def test_serialize_post(post_factory, user_factory, tag_factory, config_injector): + config_injector({'data_url': 'http://example.com/'}) with unittest.mock.patch('szurubooru.func.users.serialize_user'), \ unittest.mock.patch('szurubooru.func.posts.files.has', return_value=True): users.serialize_user.side_effect = lambda user, auth_user: user.name @@ -142,6 +143,7 @@ def test_serialize_post(post_factory, user_factory, tag_factory): 'lastFeatureTime': datetime.datetime(1999, 1, 1), 'favoritedBy': ['fav1'], 'hasCustomThumbnail': True, + 'mimeType': 'image/jpeg', } def test_serialize_post_with_details(post_factory, comment_factory, user_factory):