diff options
author | meltland <[email protected]> | 2025-03-10 17:03:26 -0400 |
---|---|---|
committer | meltland <[email protected]> | 2025-03-10 17:03:26 -0400 |
commit | 64a2cbf19384761e909eb2def7f35f9f95f9bc07 (patch) | |
tree | dc65cecb68acd2c5d4050952c9045fc85af555c4 /db.py | |
parent | 8ace0c0e1cc333b275988cd3af39e39a111809a4 (diff) |
1.0.0a?
Diffstat (limited to 'db.py')
-rw-r--r-- | db.py | 32 |
1 files changed, 28 insertions, 4 deletions
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 |