def record_space_blogs()

in chat-client/main.py [0:0]


def record_space_blogs(space_id, category):
    try:
        subscriptions_ref = DB.collection("space_blog_subscriptions")
        category_doc_ref = subscriptions_ref.document(category)
        category_doc = category_doc_ref.get()
        if category_doc.exists:
            spaces_subscribed = category_doc.to_dict().get("spaces_subscribed", [])
            if space_id not in spaces_subscribed:
                spaces_subscribed.append(space_id)
                category_doc_ref.update({"spaces_subscribed": spaces_subscribed})
        else:
            category_doc_ref.set(
                {"category": category, "spaces_subscribed": [space_id]}
            )

    except Exception as e:
        print(f"Error recording subscription: {e}", exc_info=True)