DOC: Added *.db to the .gitignore to prevent any data from being shared.
FEAT: Updated code to start following GDPR compliance.
This commit is contained in:
33
gdpr.py
Normal file
33
gdpr.py
Normal file
@ -0,0 +1,33 @@
|
||||
import aiosqlite
|
||||
|
||||
|
||||
async def check_consent(user_id: int) -> bool:
|
||||
async with aiosqlite.connect("ariella.db") as db:
|
||||
cursor = await db.execute(
|
||||
"SELECT consent FROM user_consent WHERE user_id = ?",
|
||||
(user_id,)
|
||||
)
|
||||
row = await cursor.fetchone()
|
||||
return row and row[0] == 1
|
||||
|
||||
|
||||
async def give_consent(user_id: int):
|
||||
async with aiosqlite.connect("ariella.db") as db:
|
||||
await db.execute(
|
||||
"INSERT OR REPLACE INTO user_consent (user_id, consent) VALUES (?, ?)", # noqa: E501
|
||||
(user_id, 1)
|
||||
)
|
||||
await db.commit()
|
||||
|
||||
|
||||
async def revoke_consent(user_id: int):
|
||||
async with aiosqlite.connect("ariella.db") as db:
|
||||
await db.execute(
|
||||
"DELETE FROM user_consent WHERE user_id = ?",
|
||||
(user_id,)
|
||||
)
|
||||
await db.execute(
|
||||
"DELETE FROM user_notes WHERE user_id = ?",
|
||||
(user_id,)
|
||||
)
|
||||
await db.commit()
|
Reference in New Issue
Block a user