From 4e16a059bf9cbe93d828b8952c0c1e61a48723f3 Mon Sep 17 00:00:00 2001 From: Tnix Date: Tue, 23 Jul 2024 00:03:04 +1200 Subject: [PATCH 1/7] fix!: return error in /me --- rest_api/me.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_api/me.py b/rest_api/me.py index c63e1f0..92a9bab 100644 --- a/rest_api/me.py +++ b/rest_api/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("/") From f72906d4db4484e1422b3e296252f72b8f61eb8f Mon Sep 17 00:00:00 2001 From: Tnix Date: Wed, 14 Aug 2024 17:35:20 +1200 Subject: [PATCH 2/7] feat: bump custom emoji limit to 250 and stickers limit to 50 --- rest_api/v0/chats.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest_api/v0/chats.py b/rest_api/v0/chats.py index 0b587ec..7800c5a 100644 --- a/rest_api/v0/chats.py +++ b/rest_api/v0/chats.py @@ -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) >= 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) >= 50: return {"error": True, "type": "tooManyStickers"}, 403 # Claim file From 40214c711bf80bba452645fa67eb89f52bd0ef8d Mon Sep 17 00:00:00 2001 From: Tnix Date: Wed, 14 Aug 2024 17:40:19 +1200 Subject: [PATCH 3/7] fix: limit home to first page when unauthed --- rest_api/v0/home.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest_api/v0/home.py b/rest_api/v0/home.py index 494d3e5..898697c 100644 --- a/rest_api/v0/home.py +++ b/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, From d59fd46e24895ec949d306b9328023e903f0ebac Mon Sep 17 00:00:00 2001 From: Tnix Date: Wed, 14 Aug 2024 17:43:15 +1200 Subject: [PATCH 4/7] fix not being able to toggle allow_pinning on chats --- rest_api/v0/chats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_api/v0/chats.py b/rest_api/v0/chats.py index 0b587ec..ba21e2a 100644 --- a/rest_api/v0/chats.py +++ b/rest_api/v0/chats.py @@ -203,7 +203,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}) From 44f7a03302a23ae1253710141ec229f706f3a58a Mon Sep 17 00:00:00 2001 From: Tnix Date: Wed, 14 Aug 2024 17:48:14 +1200 Subject: [PATCH 5/7] chore: make chat emojis and stickers limit environment variables --- .env.example | 5 ++++- rest_api/v0/chats.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) 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 7800c5a..01466ab 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 @@ -650,10 +650,10 @@ async def create_chat_emote(chat_id: str, emote_type: Literal["emojis", "sticker # 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=250) >= 250: + 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=50) >= 50: + 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 From aec3da0c17fdc6f5e89a8a39f461778fe3858db6 Mon Sep 17 00:00:00 2001 From: Tnix Date: Tue, 23 Jul 2024 00:03:04 +1200 Subject: [PATCH 6/7] fix!: return error in /me --- rest_api/v0/me.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_api/v0/me.py b/rest_api/v0/me.py index 6cc0023..b98ac62 100644 --- a/rest_api/v0/me.py +++ b/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("/") From 97f0ff27d44476c25fa11fb3301d9a61c9131c8d Mon Sep 17 00:00:00 2001 From: ShowierData9978 Date: Wed, 14 Aug 2024 20:29:45 -0500 Subject: [PATCH 7/7] add branding (#285) --- README.md | 60 ++++++++------------------------------ branding/server banner.svg | 22 ++++++++++++++ 2 files changed, 34 insertions(+), 48 deletions(-) create mode 100644 branding/server banner.svg diff --git a/README.md b/README.md index eff417a..a911287 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,20 @@ -# Meower-Server +![](https://raw.githubusercontent.com/meower-media/server/add-branding/branding/server%20banner.svg) +# Server Official source code of the Meower server, written in Python. Powered by CloudLink. -## NOTICE -This is the APIv0 Branch of Code! This API code will only be maintained up until when New Meower is released. - -APIv0 will be upgraded automatically to APIv1 when Beta 6 is released. The API can be found at https://api.meower.org/ - -## Installing Dependencies -* Run `pip3 install -r requirements.txt` in the downloaded and unzipped directory - -## Running the server - +## Running ```py -git clone https://github.com/meower-media-co/Meower-Server.git --recursive +git clone https://github.com/meower-media/server.git --recursive cd Meower-Server -python3 main.py -``` - -To connect to the server, change the IP settings of your client to connect to ws://127.0.0.1:3000/. - -### Rest API - -This Rest API is configured to use CF Argo Tunnels for getting client IPs, but otherwise everything will function. - -Currently supported functions of the API: - -* /home - Gets the current homepage index. -* /home?page=# - Lets you get a certain page # of the homepage. -* /home?autoget - Automatically fetches all posts currently present on the page. -* /ip - Gets the client's IP address and returns with plaintext. Only works if the server is communicating with a client over CF Argo Tunnels. -* /posts?id=(Post ID) - Gets a Post ID, use /home to get an index of posts. -* /status - Status for the Meower Server. -* /posts/(Chat ID) - Gets the specified chat ID's index. -* /reports - Gets the reports index (only accessable if a moderator or higher. -* /inbox - Gets the specified user's inbox. -* /search/home?q=(Query) - Searches home. -* /search/users?q=(Query) - Searches users. -* /users/(Username) - Gets the specified user's info. -* /users/(Username)/posts - Gets the specified user's posts. -* /statistics - Shows Meower's statistics (users, posts, and chats) -### Trust keys and access control +cd Meower-Server +pip install -r requirements.txt -In development, Meower is configured to use "meower" as a CloudLink Trust key. If you notice a forked server using this key, please request for it to be removed. This key is intended for development purposes only. +cp .env.example .env -Meower is configured to use CloudLink's Trusted Access feature, which implements the following security features: -1. IP blocker feature -2. Client kicking -3. Trust keys -4. Protection from maliciously modified clients +# edit env files -## Contributing to the source +python3 main.py +``` -1. Make a fork of the repo -2. Modify your source -3. Open a PR +## API docs +See [the autogenerated documentation](https://api.meower.org/docs) and the [Meower documentation](https://docs.meower.org) 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 @@ + + + + + + + + + + + + + + + + + + + + + +