Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Remove uploads gRPC & fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
tnix100 committed Nov 5, 2024
1 parent b163006 commit ae2fc3d
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 563 deletions.
6 changes: 0 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@ INTERNAL_API_TOKEN="" # used for authenticating internal API requests (gives ac
CAPTCHA_SITEKEY=
CAPTCHA_SECRET=

GRPC_AUTH_ADDRESS="0.0.0.0:5000"
GRPC_AUTH_TOKEN=

GRPC_UPLOADS_ADDRESS=
GRPC_UPLOADS_TOKEN=

CHAT_EMOJIS_LIMIT=250
CHAT_STICKERS_LIMIT=50
28 changes: 26 additions & 2 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from utils import log

CURRENT_DB_VERSION = 9
CURRENT_DB_VERSION = 10

# Create Redis connection
log("Connecting to Redis...")
Expand Down Expand Up @@ -174,7 +174,21 @@

# Create post reactions index
try:
db.post_reactions.create_index([("_id.post_id", 1), ("_id.emoji", 1)])
db.post_reactions.create_index([("_id.post_id", pymongo.ASCENDING), ("_id.emoji", pymongo.ASCENDING)])
except: pass

# Create files indexes
try:
db.files.create_index([("hash", pymongo.ASCENDING)], name="hash")
except: pass
try:
db.files.create_index([("uploaded_by", pymongo.ASCENDING)], name="uploaded_by")
except: pass
try:
db.files.create_index([
("claimed", pymongo.ASCENDING),
("uploaded_by", pymongo.ASCENDING)
], name="unclaimed", partialFilterExpression={"claimed": False})
except: pass


Expand Down Expand Up @@ -306,6 +320,16 @@ def get_total_pages(collection: str, query: dict, page_size: int = 25) -> int:
"mfa_recovery_code": user["mfa_recovery_code"][:10]
}})

# Post attachments
log("[Migrator] Converting post attachments")
updates = []
for post in db.posts.find({"attachments.id": {"$exists": True}}):
updates.append(pymongo.UpdateOne(
{"_id": post["_id"]},
{"$set": {"attachments": [attachment["id"] for attachment in post["attachments"]]}}
))
db.posts.bulk_write(updates)

db.config.update_one({"_id": "migration"}, {"$set": {"database": CURRENT_DB_VERSION}})
log(f"[Migrator] Finished Migrating DB to version {CURRENT_DB_VERSION}")

Expand Down
31 changes: 0 additions & 31 deletions grpc_auth/auth_service_pb2.py

This file was deleted.

19 changes: 0 additions & 19 deletions grpc_auth/auth_service_pb2.pyi

This file was deleted.

102 changes: 0 additions & 102 deletions grpc_auth/auth_service_pb2_grpc.py

This file was deleted.

47 changes: 0 additions & 47 deletions grpc_auth/service.py

This file was deleted.

6 changes: 0 additions & 6 deletions grpc_uploads/client.py

This file was deleted.

36 changes: 0 additions & 36 deletions grpc_uploads/uploads_service_pb2.py

This file was deleted.

42 changes: 0 additions & 42 deletions grpc_uploads/uploads_service_pb2.pyi

This file was deleted.

Loading

0 comments on commit ae2fc3d

Please sign in to comment.