limit subscription channels
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled

This commit is contained in:
Corban-Lee Jones 2024-10-29 16:49:50 +00:00
parent c7b62719a3
commit 8079cc4b42
2 changed files with 8 additions and 0 deletions

View File

@ -324,6 +324,13 @@ class SubscriptionSerializer(DynamicModelSerializer):
{"message_style": "Message style must belong to the specified server."}
)
# Prevent assigning more channels than permitted
channels = data.get("channels")
if len(channels) > settings.MAX_CHANNELS_PER_SUBSCRIPTION:
raise serializers.ValidationError(
{"channels": "Please select 5 channels or fewer."}
)
return data

View File

@ -285,3 +285,4 @@ REST_FRAMEWORK = {
MAX_SUBSCRIPTIONS_PER_SERVER = env("MAX_SUBSCRIPTIONS_PER_SERVER", default=15)
MAX_FILTERS_PER_SERVER = env("MAX_FILTERS_PER_SERVER", default=15)
MAX_MESSAGE_STYLES_PER_SERVER = env("MAX_MESSAGE_STYLES_PER_SERVER", default=15)
MAX_CHANNELS_PER_SUBSCRIPTION = env("MAX_CHANNELS_PER_SUBSCRIPTION", default=5)