denver-code / denscord Goto Github PK
View Code? Open in Web Editor NEWTiny Discord Clone using FastAPI and MongoDB [Backend]
Tiny Discord Clone using FastAPI and MongoDB [Backend]
Make a quick check if list of IDs could be represented as a list of ObjectID's
Test:
def test_bulk_search_one_valid(client):
test_signup(client)
token1 = client.post(
"/api/public/authorisation/signin",
json={
"email": "[email protected]",
"password": "testpassword",
}).json().get("token", "")
user1 = client.get("/api/private/profile", headers={"Authorisation":token1}).json()
del user1["email"]
response = client.post("/api/public/profile/bulk",
json={
"users": [
user1["id"],
"11111891a5d13e63599968cc1"
]
}
)
assert response.status_code == 200
assert response.json() == [
user1
]
{
"id": "649096890230315b02ed76da",
"message": "h e l p",
"author_avatar": "https://cdn.discordapp.com/embed/avatars/0.png",
"author_username": "denver-code",
"created_at": "2023-06-19T17:56:48.316000"
},
field "created_at" are not changing
Username should be without spaces, special characters, unique, limit in 15 chars length
add First and Last names and nickname which could be with spaces but without special chars
Route: /api/private/guild/647e1fd3efe1f85852a360ef
Detailed Error Log:
denscord_server_1 | INFO: 192.168.1.130:51279 - "GET /api/private/guild/647e1fd3efe1f85852a360ef HTTP/1.1" 500 Internal Server Error
denscord_server_1 | ERROR: Exception in ASGI application
denscord_server_1 | Traceback (most recent call last):
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 428, in run_asgi
denscord_server_1 | result = await app( # type: ignore[func-returns-value]
denscord_server_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
denscord_server_1 | return await self.app(scope, receive, send)
denscord_server_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/fastapi/applications.py", line 276, in __call__
denscord_server_1 | await super().__call__(scope, receive, send)
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
denscord_server_1 | await self.middleware_stack(scope, receive, send)
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
denscord_server_1 | raise exc
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
denscord_server_1 | await self.app(scope, receive, _send)
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__
denscord_server_1 | await self.app(scope, receive, send)
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
denscord_server_1 | raise exc
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
denscord_server_1 | await self.app(scope, receive, sender)
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
denscord_server_1 | raise e
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
denscord_server_1 | await self.app(scope, receive, send)
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
denscord_server_1 | await route.handle(scope, receive, send)
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
denscord_server_1 | await self.app(scope, receive, send)
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
denscord_server_1 | response = await func(request)
denscord_server_1 | ^^^^^^^^^^^^^^^^^^^
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/fastapi/routing.py", line 237, in app
denscord_server_1 | raw_response = await run_endpoint_function(
denscord_server_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
denscord_server_1 | File "/opt/.cache/virtualenvs/denscord-9TtSrW0h-py3.11/lib/python3.11/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
denscord_server_1 | return await dependant.call(**values)
denscord_server_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
denscord_server_1 | File "/app/api/private/guild/guild.py", line 58, in get_guild
denscord_server_1 | guild = GuildOut(**guild).dict()
denscord_server_1 | ^^^^^^^^^^^^^^^^^
denscord_server_1 | File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
denscord_server_1 | pydantic.error_wrappers.ValidationError: 1 validation error for GuildOut
denscord_server_1 | members_count
Sometimes generated salt are contains "./$" and other symbols which are cause problems when using em in URL.
So there are 2 variants how we can fix it:
Instead of parsing every user separately(new request for each user) make the route able to get list from body, and return list of users.
Or when getMembers of guild return members themselves.
Add invite sub route to url path as in future will be added more social interactions features.
/api/private/social/ -> /api/private/social/invite
File to edit:
api/private/guild/message.py
Function delete_message
What has to be done:
tests/routes/test_channel.py
Make length limit for guild names, channel names, usernames.
When creating new channel - check if channel with same name already exist, if yes - add "-1" at the end.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.