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

Commit

Permalink
Browse files Browse the repository at this point in the history
…erver into events-rewrite
  • Loading branch information
williamhorning committed Aug 15, 2024
2 parents 02efdae + 97f0ff2 commit 278af26
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
this branch is the subject of a major rewrite
22 changes: 22 additions & 0 deletions branding/server banner.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions python/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 @@ -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})
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions python/rest_api/v0/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion python/rest_api/v0/me.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("/")
Expand Down

0 comments on commit 278af26

Please sign in to comment.