proiect finalizat

This commit is contained in:
andrei-mihnea-cerbu
2024-01-13 12:59:19 +02:00
parent 54542da299
commit 67b7a241d7
53 changed files with 321 additions and 19 deletions
@@ -4,6 +4,10 @@ from .get_conversation import get_conversation
from .get_conversation_url import get_conversation_url
from app.models import Message
'''
The 'messages' packages contains the router configuration for the 'Messages' endpoints.
'''
router = APIRouter()
@@ -3,6 +3,15 @@ from database.queries.messages import find_conversation_db
async def get_conversation(conversation_url: str):
"""
Retrieves the full context of the conversation
Args:
conversation_url (str)
Returns:
HTTP Status
"""
conversation = find_conversation_db(conversation_url)
if conversation is None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Conversation not found")
@@ -4,6 +4,16 @@ from fastapi import HTTPException
async def get_conversation_url(id_user1: str, id_user2: str):
"""
Retrieves the conversation identifier
Args:
id_user1 (str)
id_user2 (str)
Returns:
(str) : conversation_url
"""
if get_user_by_id(id_user1) is None or get_user_by_id(id_user2) is None:
raise HTTPException(status_code=404, detail="Users not in the system.")
@@ -4,6 +4,15 @@ from database.queries.messages import send_message_db
async def send(message: Message):
"""
Stores message in MongoDB
Args:
message (Message)
Returns:
HTTP Status
"""
success = send_message_db(message)
if success: