Fixed the consent so now it requires it all the time

This commit is contained in:
Dan
2024-05-05 12:38:44 -04:00
parent f0da9a3241
commit 4ab30887d9
3 changed files with 32 additions and 26 deletions

View File

@@ -22,17 +22,12 @@ class ConsentView(View):
await interaction.response.edit_message(content="You have declined data storage. You cannot use this bot without consenting.", view=None)
self.stop()
async def check_user_consent(user_id):
"""Check if the user has given consent to data storage, default to True."""
"""Check if the user has given consent to data storage. Assume no consent if no record exists."""
async with aiosqlite.connect(DATABASE) as db:
cursor = await db.execute("SELECT consent_given FROM user_consents WHERE user_id = ?", (user_id,))
result = await cursor.fetchone()
if result is None:
# Assume consent given if no record exists
return True
return result[0]
return result[0] if result else False # Return False if no record exists, prompting consent dialogue
async def store_user_consent(user_id):
"""Store the user's consent to data storage."""