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
@@ -5,6 +5,16 @@ from datetime import datetime
def create_conversation_db(user1_id, user2_id):
"""
Creates the conversation identifier for two users.
Args:
user1_id (str): ID of first user.
user1_id (str): ID of second user.
Returns:
str: Conversation identifier/URL
"""
current_datetime = datetime.now().strftime("%Y%m%d%H%M%S")
unique_id = str(uuid.uuid4()).replace('-', '')
conversation_url = f"{current_datetime}_{unique_id}"
@@ -20,6 +30,15 @@ def create_conversation_db(user1_id, user2_id):
def find_conversation_db(conversation_url):
"""
Retrieves the conversation from MongoDB
Args:
conversation_url (str): conversation identifier
Returns:
dic: conversation
"""
collection = mongo_db_handler.get_collection()
query = {'name': conversation_url}
result_set = collection.find_one(query)