diff --git a/.env.example b/.env.example index 3386c93..9c74d34 100644 --- a/.env.example +++ b/.env.example @@ -19,4 +19,7 @@ GRPC_AUTH_ADDRESS="0.0.0.0:5000" GRPC_AUTH_TOKEN= GRPC_UPLOADS_ADDRESS= -GRPC_UPLOADS_TOKEN= \ No newline at end of file +GRPC_UPLOADS_TOKEN= + +CHAT_EMOJIS_LIMIT=250 +CHAT_STICKERS_LIMIT=50 \ No newline at end of file diff --git a/rest_api/v0/chats.py b/rest_api/v0/chats.py index ba21e2a..be1f795 100644 --- a/rest_api/v0/chats.py +++ b/rest_api/v0/chats.py @@ -2,7 +2,7 @@ from quart_schema import validate_querystring, validate_request from pydantic import BaseModel, Field from typing import Optional, Literal -import pymongo, uuid, time, re +import pymongo, uuid, time, re, os import security from database import db, get_total_pages @@ -648,12 +648,12 @@ async def create_chat_emote(chat_id: str, emote_type: Literal["emojis", "sticker if chat["type"] != 1 and chat["owner"] != request.user: abort(403) - # Make sure there's not too many emotes in the chat (100 for emojis, 25 for stickers) + # Make sure there's not too many emotes in the chat (250 for emojis, 50 for stickers) if emote_type == "emojis": - if db.chat_emojis.count_documents({"chat_id": chat_id}, limit=100) >= 100: + if db.chat_emojis.count_documents({"chat_id": chat_id}, limit=250) >= int(os.getenv("CHAT_EMOJIS_LIMIT", 250)): return {"error": True, "type": "tooManyEmojis"}, 403 elif emote_type == "stickers": - if db.chat_stickers.count_documents({"chat_id": chat_id}, limit=25) >= 25: + if db.chat_stickers.count_documents({"chat_id": chat_id}, limit=50) >= int(os.getenv("CHAT_STICKERS_LIMIT", 50)): return {"error": True, "type": "tooManyStickers"}, 403 # Claim file