Skip to content

Commit

Permalink
Merge branch 'replay-json-pages' into dev-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Feb 9, 2025
2 parents 7cfa417 + 9d1eb05 commit 11ddb68
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions backend/btrixcloud/colls.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
CollAccessType,
PageUrlCount,
PageIdTimestamp,
PageOut,
PaginatedPageUrlCountResponse,
UpdateCollHomeUrl,
User,
Expand All @@ -55,7 +54,7 @@
MIN_UPLOAD_PART_SIZE,
PublicCollOut,
)
from .utils import dt_now, slug_from_name, get_duplicate_key_error_field
from .utils import dt_now, slug_from_name, get_duplicate_key_error_field, get_origin

if TYPE_CHECKING:
from .orgs import OrgOps
Expand Down Expand Up @@ -340,6 +339,7 @@ async def get_collection_out(
org: Organization,
resources=False,
public_or_unlisted_only=False,
headers: Optional[dict] = None,
) -> CollOut:
"""Get CollOut by id"""
result = await self.get_collection_raw(coll_id, public_or_unlisted_only)
Expand All @@ -351,6 +351,9 @@ async def get_collection_out(
coll_id, is_seed=True, page_size=25
)
result["pages"] = pages
result["pagesQuery"] = (
get_origin(headers) + f"/api/orgs/{org.id}/collections/{coll_id}/pages"
)

thumbnail = result.get("thumbnail")
if thumbnail:
Expand Down Expand Up @@ -1053,22 +1056,29 @@ async def get_collection(
response_model=CollOut,
)
async def get_collection_replay(
coll_id: UUID, org: Organization = Depends(org_viewer_dep)
request: Request, coll_id: UUID, org: Organization = Depends(org_viewer_dep)
):
return await colls.get_collection_out(coll_id, org, resources=True)
return await colls.get_collection_out(
coll_id, org, resources=True, headers=dict(request.headers)
)

@app.get(
"/orgs/{oid}/collections/{coll_id}/public/replay.json",
tags=["collections"],
response_model=CollOut,
)
async def get_collection_public_replay(
request: Request,
response: Response,
coll_id: UUID,
org: Organization = Depends(org_public),
):
coll = await colls.get_collection_out(
coll_id, org, resources=True, public_or_unlisted_only=True
coll_id,
org,
resources=True,
public_or_unlisted_only=True,
headers=dict(request.headers),
)
response.headers["Access-Control-Allow-Origin"] = "*"
response.headers["Access-Control-Allow-Headers"] = "*"
Expand Down

0 comments on commit 11ddb68

Please sign in to comment.