Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #281 from meower-media/tnix-bump-emoji-limit
Browse files Browse the repository at this point in the history
feat: bump custom emoji limit to 250 and stickers limit to 50
  • Loading branch information
tnix100 authored Aug 14, 2024
2 parents 4122ca4 + 44f7a03 commit 8c3fc47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ GRPC_AUTH_ADDRESS="0.0.0.0:5000"
GRPC_AUTH_TOKEN=

GRPC_UPLOADS_ADDRESS=
GRPC_UPLOADS_TOKEN=
GRPC_UPLOADS_TOKEN=

CHAT_EMOJIS_LIMIT=250
CHAT_STICKERS_LIMIT=50
8 changes: 4 additions & 4 deletions rest_api/v0/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8c3fc47

Please sign in to comment.