Make max_media_attachments configurable by admin (#669)

This commit is contained in:
Rob 2023-11-29 01:52:04 +09:00 committed by GitHub
parent ac7fef4b28
commit 5f28d702f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -41,7 +41,7 @@ def instance_info_v1(request):
"accounts": {}, "accounts": {},
"statuses": { "statuses": {
"max_characters": Config.system.post_length, "max_characters": Config.system.post_length,
"max_media_attachments": 4, "max_media_attachments": Config.system.max_media_attachments,
"characters_reserved_per_url": 23, "characters_reserved_per_url": 23,
}, },
"media_attachments": { "media_attachments": {
@ -102,7 +102,7 @@ def instance_info_v2(request) -> dict:
"accounts": {"max_featured_tags": 0}, "accounts": {"max_featured_tags": 0},
"statuses": { "statuses": {
"max_characters": Config.system.post_length, "max_characters": Config.system.post_length,
"max_media_attachments": 4, "max_media_attachments": Config.system.max_media_attachments,
"characters_reserved_per_url": 23, "characters_reserved_per_url": 23,
}, },
"media_attachments": { "media_attachments": {

View file

@ -214,6 +214,7 @@ class Config(models.Model):
content_warning_text: str = "Content Warning" content_warning_text: str = "Content Warning"
post_length: int = 500 post_length: int = 500
max_media_attachments: int = 4
post_minimum_interval: int = 3 # seconds post_minimum_interval: int = 3 # seconds
identity_min_length: int = 2 identity_min_length: int = 2
identity_max_per_user: int = 5 identity_max_per_user: int = 5

View file

@ -38,6 +38,10 @@ class BasicSettings(AdminSettingsPage):
"title": "Maximum Post Length", "title": "Maximum Post Length",
"help_text": "The maximum number of characters allowed per post", "help_text": "The maximum number of characters allowed per post",
}, },
"max_media_attachments": {
"title": "Maximum Media Attachments",
"help_text": "The maximum number of media attachments allowed per post.\nA value other than 4 may be unsupported by clients.",
},
"post_minimum_interval": { "post_minimum_interval": {
"title": "Minimum Posting Interval", "title": "Minimum Posting Interval",
"help_text": "The minimum number of seconds a user must wait between posts", "help_text": "The minimum number of seconds a user must wait between posts",
@ -129,6 +133,7 @@ class BasicSettings(AdminSettingsPage):
], ],
"Posts": [ "Posts": [
"post_length", "post_length",
"max_media_attachments",
"post_minimum_interval", "post_minimum_interval",
"content_warning_text", "content_warning_text",
"hashtag_unreviewed_are_public", "hashtag_unreviewed_are_public",