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/README.md b/README.md index 85ade95..3c4b8f6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ +![](https://raw.githubusercontent.com/meower-media/server/add-branding/branding/server%20banner.svg) + # server the go stuff, in cmd/* and pkg/* has no security features, so be careful!!! -this branch is the subject of a major rewrite \ No newline at end of file +this branch is the subject of a major rewrite diff --git a/branding/server banner.svg b/branding/server banner.svg new file mode 100644 index 0000000..7c3a841 --- /dev/null +++ b/branding/server banner.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/rest_api/v0/chats.py b/python/rest_api/v0/chats.py index 2b2b4e0..c583914 100644 --- a/python/rest_api/v0/chats.py +++ b/python/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 @@ -205,7 +205,7 @@ async def update_chat(chat_id, data: ChatBody): if data.icon is None or chat["icon"] == data.icon: app.supporter.create_post(chat_id, "Server", f"@{request.user} changed the icon of the group chat.", chat_members=chat["members"]) if data.allow_pinning is not None: - chat["allow_pinning"] = data.allow_pinning + updated_vals["allow_pinning"] = data.allow_pinning # Update chat db.chats.update_one({"_id": chat_id}, {"$set": updated_vals}) @@ -650,12 +650,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 diff --git a/python/rest_api/v0/home.py b/python/rest_api/v0/home.py index 494d3e5..898697c 100644 --- a/python/rest_api/v0/home.py +++ b/python/rest_api/v0/home.py @@ -31,6 +31,8 @@ class Config: @home_bp.get("/") @validate_querystring(GetHomeQueryArgs) async def get_home_posts(query_args: GetHomeQueryArgs): + if not request.user: + query_args.page = 1 query = {"post_origin": "home", "isDeleted": False} return { "error": False, diff --git a/python/rest_api/v0/me.py b/python/rest_api/v0/me.py index 6cc0023..b98ac62 100644 --- a/python/rest_api/v0/me.py +++ b/python/rest_api/v0/me.py @@ -79,7 +79,7 @@ async def get_me(): db.usersv0.update_one({"_id": request.user}, {"$set": {"last_seen": int(time.time())}}) # Get and return account - return security.get_account(request.user, include_config=True), 200 + return {"error": False, **security.get_account(request.user, include_config=True)}, 200 @me_bp.delete("/")