From 5f28d702f8cf2db56935f0496064ce28e9dfa281 Mon Sep 17 00:00:00 2001 From: Rob Date: Wed, 29 Nov 2023 01:52:04 +0900 Subject: [PATCH] Make max_media_attachments configurable by admin (#669) --- api/views/instance.py | 4 ++-- core/models/config.py | 1 + users/views/admin/settings.py | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/views/instance.py b/api/views/instance.py index 87e9c96..3253a82 100644 --- a/api/views/instance.py +++ b/api/views/instance.py @@ -41,7 +41,7 @@ def instance_info_v1(request): "accounts": {}, "statuses": { "max_characters": Config.system.post_length, - "max_media_attachments": 4, + "max_media_attachments": Config.system.max_media_attachments, "characters_reserved_per_url": 23, }, "media_attachments": { @@ -102,7 +102,7 @@ def instance_info_v2(request) -> dict: "accounts": {"max_featured_tags": 0}, "statuses": { "max_characters": Config.system.post_length, - "max_media_attachments": 4, + "max_media_attachments": Config.system.max_media_attachments, "characters_reserved_per_url": 23, }, "media_attachments": { diff --git a/core/models/config.py b/core/models/config.py index 5dbff44..98bfaab 100644 --- a/core/models/config.py +++ b/core/models/config.py @@ -214,6 +214,7 @@ class Config(models.Model): content_warning_text: str = "Content Warning" post_length: int = 500 + max_media_attachments: int = 4 post_minimum_interval: int = 3 # seconds identity_min_length: int = 2 identity_max_per_user: int = 5 diff --git a/users/views/admin/settings.py b/users/views/admin/settings.py index ba00963..5eb436f 100644 --- a/users/views/admin/settings.py +++ b/users/views/admin/settings.py @@ -38,6 +38,10 @@ class BasicSettings(AdminSettingsPage): "title": "Maximum Post Length", "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": { "title": "Minimum Posting Interval", "help_text": "The minimum number of seconds a user must wait between posts", @@ -129,6 +133,7 @@ class BasicSettings(AdminSettingsPage): ], "Posts": [ "post_length", + "max_media_attachments", "post_minimum_interval", "content_warning_text", "hashtag_unreviewed_are_public",