proiect finalizat
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user