Initial Switch to V2. Completely Overhauled Backend, Frontend and General Structure.
This commit is contained in:
@@ -451,11 +451,17 @@ async def remove_user_from_device(
|
||||
data = device_doc.to_dict() or {}
|
||||
user_list = data.get("user_list", []) or []
|
||||
|
||||
# Remove any entry that resolves to this user_id
|
||||
new_list = [
|
||||
entry for entry in user_list
|
||||
if not (isinstance(entry, str) and entry.split("/")[-1] == user_id)
|
||||
]
|
||||
from google.cloud.firestore_v1 import DocumentReference as DocRef
|
||||
|
||||
def resolves_to(entry, uid: str) -> bool:
|
||||
if isinstance(entry, DocRef):
|
||||
return entry.id == uid
|
||||
if isinstance(entry, str):
|
||||
return entry.split("/")[-1] == uid
|
||||
return False
|
||||
|
||||
# Remove any entry that resolves to this user_id (handles both DocRef and string paths)
|
||||
new_list = [entry for entry in user_list if not resolves_to(entry, user_id)]
|
||||
device_ref.update({"user_list": new_list})
|
||||
|
||||
return {"status": "removed", "user_id": user_id}
|
||||
|
||||
Reference in New Issue
Block a user