From 64a2cbf19384761e909eb2def7f35f9f95f9bc07 Mon Sep 17 00:00:00 2001 From: meltland Date: Mon, 10 Mar 2025 17:03:26 -0400 Subject: 1.0.0a? --- db.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'db.py') diff --git a/db.py b/db.py index 6750e47..bcbf9e2 100644 --- a/db.py +++ b/db.py @@ -119,12 +119,29 @@ class posts: i["replies"][incr]["author"] = data return posts - def get_by_id(post_id): + def get_by_id(post_id, supply_author=False): post = postsd.find_one({"_id": post_id}) if not post: return "notExists" - else: - return post + if supply_author: + data = acc.get(post["author"]) + if type(data) != dict: + data = {} + else: + del data["secure"] + del data["profile"] + post["author"] = data + incr = -1 + for j in post["replies"]: + incr += 1 + data = acc.get(j["author"]) + if type(data) != dict: + data = {} + else: + del data["secure"] + del data["profile"] + post["replies"][incr]["author"] = data + return post def add(data): try: @@ -136,4 +153,11 @@ class posts: class inbox: def get_recent(amount=75): posts = list(inboxd.find().sort("created", -1).limit(amount)) - return posts \ No newline at end of file + return posts + + def add(data): + try: + inboxd.insert_one(data) + except Exception as e: + return "fail" + return True \ No newline at end of file -- cgit 1.4.1-2-gfad0