diff --git a/database.py b/database.py index b8e6cf9..7b85f73 100644 --- a/database.py +++ b/database.py @@ -51,10 +51,12 @@ ("quote", pymongo.TEXT) ], name="search", partialFilterExpression={"pswd": {"$type": "string"}}) except: pass +""" try: db.usersv0.create_index([ ("delete_after", pymongo.ASCENDING) ], name="scheduled_deletions", partialFilterExpression={"delete_after": {"$type": "number"}}) except: pass +""" # Create authenticators indexes try: db.authenticators.create_index([("user", pymongo.ASCENDING)], name="user") @@ -68,17 +70,20 @@ try: db.relationships.create_index([("_id.from", pymongo.ASCENDING)], name="from") except: pass -# Create netinfo indexes +""" try: db.netinfo.create_index([("last_refreshed", pymongo.ASCENDING)], name="last_refreshed") except: pass +""" # Create netlog indexes try: db.netlog.create_index([("_id.ip", pymongo.ASCENDING)], name="ip") except: pass try: db.netlog.create_index([("_id.user", pymongo.ASCENDING)], name="user") except: pass +""" try: db.netlog.create_index([("last_used", pymongo.ASCENDING)], name="last_used") except: pass +""" # Create posts indexes try: @@ -100,13 +105,13 @@ ("p", pymongo.TEXT) ], name="search", partialFilterExpression={"post_origin": "home", "isDeleted": False}) except: pass - +""" try: db.posts.create_index([ ("deleted_at", pymongo.ASCENDING) ], name="scheduled_purges", partialFilterExpression={"isDeleted": True, "mod_deleted": False}) except: pass - +""" try: db.posts.create_index([ ("post_origin", pymongo.ASCENDING), @@ -115,6 +120,7 @@ ], name="pinned_posts", partialFilterExpression={"pinned": True}) except: pass +""" # Create post revisions indexes try: db.post_revisions.create_index([ @@ -127,6 +133,7 @@ ("time", pymongo.ASCENDING) ], name="scheduled_purges") except: pass +""" # Create chats indexes try: @@ -165,6 +172,7 @@ ], name="all_reports") except: pass +""" # Create audit log indexes try: db.audit_log.create_index([ @@ -172,6 +180,7 @@ ("type", pymongo.ASCENDING) ], name="scheduled_purges") except: pass +""" # Create post reactions index try: diff --git a/main.py b/main.py index f95f2d4..0fed2f0 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ from cloudlink import CloudlinkServer from supporter import Supporter -from security import background_tasks_loop +#from security import background_tasks_loop from rest_api import app as rest_api @@ -23,7 +23,7 @@ cl.supporter = supporter # Start background tasks loop - Thread(target=background_tasks_loop, daemon=True).start() + #Thread(target=background_tasks_loop, daemon=True).start() # Initialise REST API rest_api.cl = cl diff --git a/rest_api/v0/me.py b/rest_api/v0/me.py index 6338b26..10f66f8 100644 --- a/rest_api/v0/me.py +++ b/rest_api/v0/me.py @@ -93,17 +93,20 @@ async def delete_account(data: DeleteAccountBody): if not security.check_password_hash(data.password, account["pswd"]): security.ratelimit(f"login:u:{request.user}", 5, 60) return {"error": True, "type": "invalidCredentials"}, 401 - + # Schedule account for deletion db.usersv0.update_one({"_id": request.user}, {"$set": { "tokens": [], - "delete_after": int(time.time())+604800 # 7 days + "delete_after": int(time.time()) }}) # Disconnect clients for client in app.cl.usernames.get(request.user, []): client.kick() + # Delete account + security.delete_account(request.user) + return {"error": False}, 200 diff --git a/rest_api/v0/posts.py b/rest_api/v0/posts.py index 09ca648..10c372f 100644 --- a/rest_api/v0/posts.py +++ b/rest_api/v0/posts.py @@ -118,6 +118,7 @@ async def update_post(query_args: PostIdQueryArgs, data: PostBody): abort(400) # Add revision + """ db.post_revisions.insert_one({ "_id": str(uuid.uuid4()), "post_id": post["_id"], @@ -125,6 +126,7 @@ async def update_post(query_args: PostIdQueryArgs, data: PostBody): "new_content": data.content, "time": int(time.time()) }) + """ # Update post post["edited_at"] = int(time.time())