Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add join album feature for web

Anand Baburajan0dad9c0a2754
diff --git a/web/Dockerfile b/web/Dockerfile
index 05246aa30d..2378d92958 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -7,6 +7,7 @@ COPY . .
ENV NEXT_PUBLIC_ENTE_ENDPOINT=ENTE_API_ORIGIN_PLACEHOLDER
ENV NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=ENTE_ALBUMS_ORIGIN_PLACEHOLDER
+ENV NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT=ENTE_PHOTOS_ORIGIN_PLACEHOLDER
# `yarn install` is flaky on the GitHub arm64 runners otherwise.
RUN yarn config set network-timeout 900000 -g
@@ -71,12 +72,15 @@ EXPOSE 3006
ENV ENTE_API_ORIGIN=http://localhost:8080
ENV ENTE_ALBUMS_ORIGIN=https://localhost:3002
+ENV ENTE_PHOTOS_ORIGIN=https://localhost:3000
COPY <<EOF /docker-entrypoint.d/90-replace-ente-env.sh
find /out -name '*.js' |
xargs sed -i'' "s#ENTE_API_ORIGIN_PLACEHOLDER#\$ENTE_API_ORIGIN#g"
find /out/photos -name '*.js' |
xargs sed -i'' "s#ENTE_ALBUMS_ORIGIN_PLACEHOLDER#\$ENTE_ALBUMS_ORIGIN#g"
+find /out/photos -name '*.js' |
+ xargs sed -i'' "s#ENTE_PHOTOS_ORIGIN_PLACEHOLDER#\$ENTE_PHOTOS_ORIGIN#g"
EOF
RUN chmod +x /docker-entrypoint.d/90-replace-ente-env.sh
diff --git a/web/apps/photos/.env b/web/apps/photos/.env
index 43ee9e8db3..ff749bb0a6 100644
--- a/web/apps/photos/.env
+++ b/web/apps/photos/.env
@@ -39,7 +39,7 @@
# The Ente API endpoint
#
-# NEXT_PUBLIC_ENTE_ENDPOINT = http://localhost:3000
+# NEXT_PUBLIC_ENTE_ENDPOINT = http://localhost:8080
# The URL for the shared albums deployment
#
@@ -61,6 +61,14 @@
#
# NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT = http://localhost:3002
+# The URL for the photos app deployment
+#
+# The default is "https://web.ente.io", but this can be customized for local
+# development or self-hosting. For example, you can set this to
+# http://localhost:3000 when developing locally.
+#
+# NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT = http://localhost:3000
+
# The JSON which describes the expected results of our integration tests. See
# `upload.test.ts` for more details of the expected format.
#
diff --git a/web/apps/photos/.env.development b/web/apps/photos/.env.development
index 7f6b38ccfd..2dadb5366e 100644
--- a/web/apps/photos/.env.development
+++ b/web/apps/photos/.env.development
@@ -18,3 +18,8 @@
# - `yarn dev:albums` (the sidecar app, in this case, albums)
#NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT = http://localhost:3002
+
+# If you also want to customize the photos app origin (defaults to
+# https://web.ente.io), you can uncomment this:
+
+#NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT = http://localhost:3000
diff --git a/web/apps/photos/src/components/TripLayout/MobileNavBar.tsx b/web/apps/photos/src/components/TripLayout/MobileNavBar.tsx
index a92840aa4b..971b20a56d 100644
--- a/web/apps/photos/src/components/TripLayout/MobileNavBar.tsx
+++ b/web/apps/photos/src/components/TripLayout/MobileNavBar.tsx
@@ -4,15 +4,24 @@ import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
import ShareIcon from "@mui/icons-material/Share";
import { Box, Button, IconButton, styled } from "@mui/material";
import { EnteLogo } from "ente-base/components/EnteLogo";
+import { useIsTouchscreen } from "ente-base/components/utils/hooks";
+import type { PublicAlbumsCredentials } from "ente-base/http";
+import type { Collection } from "ente-media/collection";
import { Notification } from "ente-new/photos/components/Notification";
+import { useJoinAlbum } from "hooks/useJoinAlbum";
import { t } from "i18next";
import { useState } from "react";
+import { getSignUpOrInstallURL } from "utils/public-album";
interface MobileNavBarProps {
onAddPhotos?: () => void;
downloadAllFiles: () => void;
enableDownload?: boolean;
collectionTitle?: string;
+ publicCollection?: Collection;
+ accessToken?: string;
+ collectionKey?: string;
+ credentials?: React.RefObject<PublicAlbumsCredentials | undefined>;
}
export const MobileNavBar: React.FC<MobileNavBarProps> = ({
@@ -20,8 +29,21 @@ export const MobileNavBar: React.FC<MobileNavBarProps> = ({
downloadAllFiles,
enableDownload,
collectionTitle,
+ publicCollection,
+ accessToken,
+ collectionKey,
+ credentials,
}) => {
const [showCopiedMessage, setShowCopiedMessage] = useState(false);
+ const isTouchscreen = useIsTouchscreen();
+
+ const enableJoin = publicCollection?.publicURLs[0]?.enableJoin;
+ const { handleJoinAlbum } = useJoinAlbum({
+ publicCollection,
+ accessToken,
+ collectionKey,
+ credentials,
+ });
const handleShare = async () => {
if (typeof window !== "undefined") {
@@ -44,12 +66,22 @@ export const MobileNavBar: React.FC<MobileNavBarProps> = ({
}
};
- const handleSignUp = () => {
+ const handleSignUpOrInstall = () => {
if (typeof window !== "undefined") {
- window.open("https://ente.io", "_blank", "noopener");
+ window.open(
+ getSignUpOrInstallURL(isTouchscreen),
+ "_blank",
+ "noopener",
+ );
}
};
+ const buttonText = enableJoin
+ ? t("join_album")
+ : isTouchscreen
+ ? t("install")
+ : t("sign_up");
+
return (
<>
<MobileNavContainer>
@@ -78,9 +110,17 @@ export const MobileNavBar: React.FC<MobileNavBarProps> = ({
</MobileNavButton>
)}
- <MobileSignUpButton onClick={handleSignUp}>
- {t("install")}
- </MobileSignUpButton>
+ {(!onAddPhotos || enableJoin) && (
+ <MobileSignUpButton
+ onClick={
+ enableJoin
+ ? handleJoinAlbum
+ : handleSignUpOrInstall
+ }
+ >
+ {buttonText}
+ </MobileSignUpButton>
+ )}
</ButtonGroup>
</MobileNavContainer>
diff --git a/web/apps/photos/src/components/TripLayout/TopNavButtons.tsx b/web/apps/photos/src/components/TripLayout/TopNavButtons.tsx
index fd290ce41a..cd3d9e6f83 100644
--- a/web/apps/photos/src/components/TripLayout/TopNavButtons.tsx
+++ b/web/apps/photos/src/components/TripLayout/TopNavButtons.tsx
@@ -3,22 +3,44 @@ import CheckIcon from "@mui/icons-material/Check";
import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
import ShareIcon from "@mui/icons-material/Share";
import { Box, Button, IconButton, styled } from "@mui/material";
+import { useIsTouchscreen } from "ente-base/components/utils/hooks";
+import type { PublicAlbumsCredentials } from "ente-base/http";
+import type { Collection } from "ente-media/collection";
import { Notification } from "ente-new/photos/components/Notification";
+import { useJoinAlbum } from "hooks/useJoinAlbum";
import { t } from "i18next";
import { useState } from "react";
+import { getSignUpOrInstallURL } from "utils/public-album";
interface TopNavButtonsProps {
onAddPhotos?: () => void;
downloadAllFiles: () => void;
enableDownload?: boolean;
+ publicCollection?: Collection;
+ accessToken?: string;
+ collectionKey?: string;
+ credentials?: React.RefObject<PublicAlbumsCredentials | undefined>;
}
export const TopNavButtons: React.FC<TopNavButtonsProps> = ({
onAddPhotos,
downloadAllFiles,
enableDownload,
+ publicCollection,
+ accessToken,
+ collectionKey,
+ credentials,
}) => {
const [showCopiedMessage, setShowCopiedMessage] = useState(false);
+ const isTouchscreen = useIsTouchscreen();
+
+ const enableJoin = publicCollection?.publicURLs[0]?.enableJoin;
+ const { handleJoinAlbum } = useJoinAlbum({
+ publicCollection,
+ accessToken,
+ collectionKey,
+ credentials,
+ });
const handleShare = () => {
if (typeof window !== "undefined") {
@@ -28,12 +50,22 @@ export const TopNavButtons: React.FC<TopNavButtonsProps> = ({
}
};
- const handleSignUp = () => {
+ const handleSignUpOrInstall = () => {
if (typeof window !== "undefined") {
- window.open("https://ente.io", "_blank", "noopener");
+ window.open(
+ getSignUpOrInstallURL(isTouchscreen),
+ "_blank",
+ "noopener",
+ );
}
};
+ const buttonText = enableJoin
+ ? t("join_album")
+ : isTouchscreen
+ ? t("install")
+ : t("sign_up");
+
return (
<>
<ButtonContainer>
@@ -55,9 +87,15 @@ export const TopNavButtons: React.FC<TopNavButtonsProps> = ({
</NavButton>
)}
- <SignUpButton onClick={handleSignUp}>
- {t("sign_up")}
- </SignUpButton>
+ {(!onAddPhotos || enableJoin) && (
+ <SignUpButton
+ onClick={
+ enableJoin ? handleJoinAlbum : handleSignUpOrInstall
+ }
+ >
+ {buttonText}
+ </SignUpButton>
+ )}
</ButtonContainer>
<Notification
diff --git a/web/apps/photos/src/components/TripLayout/index.tsx b/web/apps/photos/src/components/TripLayout/index.tsx
index c265c81297..6cece0d676 100644
--- a/web/apps/photos/src/components/TripLayout/index.tsx
+++ b/web/apps/photos/src/components/TripLayout/index.tsx
@@ -1,5 +1,6 @@
import { Box, styled, useMediaQuery, useTheme } from "@mui/material";
import { DownloadStatusNotifications } from "components/DownloadStatusNotifications";
+import type { PublicAlbumsCredentials } from "ente-base/http";
import { useSaveGroups } from "ente-gallery/components/utils/save-groups";
import { FileViewer } from "ente-gallery/components/viewer/FileViewer";
import { downloadAndSaveCollectionFiles } from "ente-gallery/services/save";
@@ -39,6 +40,10 @@ interface TripLayoutProps {
onSetOpenFileViewer?: (open: boolean) => void;
onRemotePull?: () => Promise<void>;
onAddPhotos?: () => void; // Callback for add photos button
+ // Join album props
+ accessToken?: string;
+ collectionKey?: string;
+ credentials?: React.RefObject<PublicAlbumsCredentials | undefined>;
}
export const TripLayout: React.FC<TripLayoutProps> = ({
@@ -50,6 +55,9 @@ export const TripLayout: React.FC<TripLayoutProps> = ({
onSetOpenFileViewer,
onRemotePull,
onAddPhotos,
+ accessToken,
+ collectionKey,
+ credentials,
}) => {
// Extract collection info if available
const collectionTitle = collection?.name || albumTitle || "Trip";
@@ -265,12 +273,20 @@ export const TripLayout: React.FC<TripLayoutProps> = ({
downloadAllFiles={downloadAllFiles}
enableDownload={enableDownload}
collectionTitle={collectionTitle}
+ publicCollection={collection}
+ accessToken={accessToken}
+ collectionKey={collectionKey}
+ credentials={credentials}
/>
) : (
<TopNavButtons
onAddPhotos={onAddPhotos}
downloadAllFiles={downloadAllFiles}
enableDownload={enableDownload}
+ publicCollection={collection}
+ accessToken={accessToken}
+ collectionKey={collectionKey}
+ credentials={credentials}
/>
))}
{/* Mobile Layout */}
diff --git a/web/apps/photos/src/hooks/useJoinAlbum.ts b/web/apps/photos/src/hooks/useJoinAlbum.ts
new file mode 100644
index 0000000000..9d55ce7621
--- /dev/null
+++ b/web/apps/photos/src/hooks/useJoinAlbum.ts
@@ -0,0 +1,142 @@
+import { useIsTouchscreen } from "ente-base/components/utils/hooks";
+import type { PublicAlbumsCredentials } from "ente-base/http";
+import { albumsAppOrigin, photosAppOrigin } from "ente-base/origins";
+import type { Collection } from "ente-media/collection";
+
+export interface UseJoinAlbumProps {
+ /** Collection to join */
+ publicCollection?: Collection;
+ /** Access token for the public link */
+ accessToken?: string;
+ /** Collection key from URL (base64 encoded) */
+ collectionKey?: string;
+ /** Credentials ref for JWT token access */
+ credentials?: React.RefObject<PublicAlbumsCredentials | undefined>;
+}
+
+export interface UseJoinAlbumReturn {
+ /** Handler for join album action */
+ handleJoinAlbum: () => void;
+}
+
+/**
+ * Build the web app redirect URL for joining an album.
+ */
+const buildWebRedirectURL = (
+ accessToken: string,
+ currentHash: string,
+ jwtToken?: string,
+): string => {
+ const webAppURL = photosAppOrigin();
+ const jwtParam = jwtToken ? `&jwt=${encodeURIComponent(jwtToken)}` : "";
+ return `${webAppURL}/?joinAlbum=${accessToken}${jwtParam}#${currentHash}`;
+};
+
+/**
+ * Handle the fallback flow when the native app doesn't open.
+ * Redirects to web app with all join context in the URL.
+ */
+const handleWebFallback = (
+ accessToken: string,
+ currentHash: string,
+ jwtToken?: string,
+): void => {
+ // Redirect to web app with joinAlbum parameter
+ // The URL contains all necessary context (token, JWT, hash) which will be
+ // stored on web.ente.io after the domain transition
+ const redirectURL = buildWebRedirectURL(accessToken, currentHash, jwtToken);
+ window.location.href = redirectURL;
+};
+
+/**
+ * Attempt to open the native app via deep link, with fallback to web.
+ * Returns a cleanup function to clear the timeout if needed.
+ */
+const tryDeepLinkWithFallback = (
+ deepLinkURL: string,
+ fallbackFn: () => void | Promise<void>,
+ timeoutMs = 4000,
+): (() => void) => {
+ let appOpened = false;
+
+ // Track visibility changes - app opening will hide the page
+ const onVisibilityChange = () => {
+ if (document.visibilityState === "hidden") {
+ appOpened = true;
+ }
+ };
+
+ // Track page hide - more reliable on some Android browsers
+ const onPageHide = () => {
+ appOpened = true;
+ };
+
+ document.addEventListener("visibilitychange", onVisibilityChange);
+ window.addEventListener("pagehide", onPageHide);
+
+ // Try to open the app using the deep link
+ // Use assign() instead of href for better compatibility with iOS Safari/PWAs
+ window.location.assign(deepLinkURL);
+
+ // Set a timeout to check if the app opened
+ const timeoutId = setTimeout(() => {
+ if (!appOpened) {
+ void fallbackFn();
+ }
+ cleanup();
+ }, timeoutMs);
+
+ const cleanup = () => {
+ clearTimeout(timeoutId);
+ document.removeEventListener("visibilitychange", onVisibilityChange);
+ window.removeEventListener("pagehide", onPageHide);
+ };
+
+ // Return cleanup function
+ return cleanup;
+};
+
+/**
+ * Custom hook that provides join album logic and handlers.
+ * Components can use this hook and apply their own button styling.
+ */
+export const useJoinAlbum = ({
+ publicCollection,
+ accessToken,
+ collectionKey,
+ credentials,
+}: UseJoinAlbumProps): UseJoinAlbumReturn => {
+ const isTouchscreen = useIsTouchscreen();
+
+ const handleJoinAlbum = () => {
+ if (!publicCollection || !accessToken || !collectionKey) {
+ return;
+ }
+
+ // Get the original hash directly from the current URL
+ const currentHash = window.location.hash.slice(1);
+ const jwtToken = credentials?.current?.accessTokenJWT;
+
+ // Create fallback function for mobile deep linking
+ const fallbackToWeb = () => {
+ handleWebFallback(accessToken, currentHash, jwtToken);
+ };
+
+ // Check if on mobile and try deep link first
+ if (isTouchscreen) {
+ // Extract hostname from albumsAppOrigin for deep linking
+ const albumsHost = new URL(albumsAppOrigin()).host;
+
+ // For all mobile devices, use custom scheme with action=join parameter
+ // Format: ente://HOST/?action=join&t=TOKEN#HASH
+ const deepLinkURL = `ente://${albumsHost}/?action=join&t=${encodeURIComponent(accessToken)}#${currentHash}`;
+
+ tryDeepLinkWithFallback(deepLinkURL, fallbackToWeb);
+ } else {
+ // Desktop: use the standard web flow directly
+ handleWebFallback(accessToken, currentHash, jwtToken);
+ }
+ };
+
+ return { handleJoinAlbum };
+};
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index d5711fa1be..7de61b0505 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -3,9 +3,20 @@
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable @typescript-eslint/no-floating-promises */
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
+import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
+import CloseIcon from "@mui/icons-material/Close";
import FileUploadOutlinedIcon from "@mui/icons-material/FileUploadOutlined";
import MenuIcon from "@mui/icons-material/Menu";
-import { IconButton, Link, Stack, Typography } from "@mui/material";
+import {
+ Box,
+ DialogTitle,
+ IconButton,
+ Link,
+ Paper,
+ Snackbar,
+ Stack,
+ Typography,
+} from "@mui/material";
import type { AddToAlbumPhase } from "components/AlbumAddedNotification";
import { AlbumAddedNotification } from "components/AlbumAddedNotification";
import { AuthenticateUser } from "components/AuthenticateUser";
@@ -30,6 +41,7 @@ import { SingleInputDialog } from "ente-base/components/SingleInputDialog";
import { CenteredRow } from "ente-base/components/containers";
import { TranslucentLoadingOverlay } from "ente-base/components/loaders";
import type { ButtonishProps } from "ente-base/components/mui";
+import { FilledIconButton } from "ente-base/components/mui";
import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
import { errorDialogAttributes } from "ente-base/components/utils/dialog";
import { useIsSmallWidth } from "ente-base/components/utils/hooks";
@@ -48,6 +60,10 @@ import { useSaveGroups } from "ente-gallery/components/utils/save-groups";
import { type Collection } from "ente-media/collection";
import { type EnteFile } from "ente-media/file";
import { type ItemVisibility } from "ente-media/file-metadata";
+import {
+ hasPendingAlbumToJoin,
+ processPendingAlbumJoin,
+} from "ente-new/albums/services/join-album";
import {
CollectionSelector,
type CollectionSelectorAttributes,
@@ -167,6 +183,10 @@ const Page: React.FC = () => {
[],
);
const [isFileViewerOpen, setIsFileViewerOpen] = useState(false);
+ const [albumJoinedToast, setAlbumJoinedToast] = useState<{
+ open: boolean;
+ albumId?: number;
+ }>({ open: false });
/**
* Tracks a pending file addition operation.
@@ -358,9 +378,35 @@ const Page: React.FC = () => {
trashItems: await savedTrashItems(),
});
- // Fetch data from remote.
+ // Check for pending album join BEFORE fetching data
+ let joinedAlbumId: number | null = null;
+
+ if (hasPendingAlbumToJoin()) {
+ try {
+ const joinedCollectionId = await processPendingAlbumJoin();
+ if (joinedCollectionId) {
+ joinedAlbumId = joinedCollectionId;
+ }
+ } catch (error) {
+ log.error("Failed to join album", error);
+ showMiniDialog({
+ title: t("error"),
+ message:
+ t("album_join_failed") +
+ ": " +
+ (error as Error).message,
+ });
+ }
+ }
+
+ // Fetch data from remote (this will include the newly joined album if any)
await remotePull();
+ // Now that data is loaded, show the toast if we joined an album
+ if (joinedAlbumId) {
+ setAlbumJoinedToast({ open: true, albumId: joinedAlbumId });
+ }
+
// Clear the first load message if needed.
setIsFirstLoad(false);
@@ -1333,6 +1379,51 @@ const Page: React.FC = () => {
}}
onSubmit={handleAlbumNameSubmit}
/>
+ <Snackbar
+ open={albumJoinedToast.open}
+ anchorOrigin={{ horizontal: "right", vertical: "bottom" }}
+ >
+ <Paper sx={{ width: "min(360px, 100svw)" }}>
+ <DialogTitle>
+ <Stack
+ direction="row"
+ sx={{
+ justifyContent: "space-between",
+ alignItems: "center",
+ }}
+ >
+ <Box>
+ <Typography variant="h3">
+ {t("joined_album")}
+ </Typography>
+ </Box>
+ <Stack direction="row" sx={{ gap: 1 }}>
+ <FilledIconButton
+ onClick={() => {
+ if (albumJoinedToast.albumId) {
+ dispatch({
+ type: "showCollectionSummary",
+ collectionSummaryID:
+ albumJoinedToast.albumId,
+ });
+ }
+ setAlbumJoinedToast({ open: false });
+ }}
+ >
+ <ArrowForwardIcon />
+ </FilledIconButton>
+ <FilledIconButton
+ onClick={() =>
+ setAlbumJoinedToast({ open: false })
+ }
+ >
+ <CloseIcon />
+ </FilledIconButton>
+ </Stack>
+ </Stack>
+ </DialogTitle>
+ </Paper>
+ </Snackbar>
<AlbumAddedNotification
open={addToAlbumProgress.open}
onClose={() =>
diff --git a/web/apps/photos/src/pages/index.tsx b/web/apps/photos/src/pages/index.tsx
index cc8f5ae9d2..3c7700b376 100644
--- a/web/apps/photos/src/pages/index.tsx
+++ b/web/apps/photos/src/pages/index.tsx
@@ -7,6 +7,7 @@ import { EnteLogo } from "ente-base/components/EnteLogo";
import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";
import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
import { useBaseContext } from "ente-base/context";
+import log from "ente-base/log";
import {
albumsAppOrigin,
customAPIHost,
@@ -18,6 +19,10 @@ import {
} from "ente-base/session";
import { savedAuthToken } from "ente-base/token";
import { canAccessIndexedDB } from "ente-gallery/services/files-db";
+import {
+ JOIN_ALBUM_CONTEXT_KEY,
+ type JoinAlbumContext,
+} from "ente-new/albums/services/join-album";
import { DevSettings } from "ente-new/photos/components/DevSettings";
import { t } from "i18next";
import { useRouter } from "next/router";
@@ -42,6 +47,54 @@ const Page: React.FC = () => {
void (async () => {
refreshHost();
const currentURL = new URL(window.location.href);
+
+ // Store join album context immediately if present in URL
+ // This ensures it survives the authentication flow
+ const joinAlbumParam = currentURL.searchParams.get("joinAlbum");
+ if (joinAlbumParam && joinAlbumParam !== "true") {
+ try {
+ // Format: joinAlbum?=accessToken&jwt=<jwtToken>#collectionKeyHash
+ const accessToken = joinAlbumParam;
+ const collectionKeyHash = currentURL.hash.slice(1);
+ const jwtFromURL = currentURL.searchParams.get("jwt");
+
+ if (accessToken && collectionKeyHash) {
+ // Import the necessary functions to convert the collection key
+ const { extractCollectionKeyFromShareURL } =
+ await import("ente-gallery/services/share");
+
+ // Convert the hash to base64 for API calls
+ const tempURL = new URL(window.location.href);
+ tempURL.hash = collectionKeyHash;
+ const collectionKey =
+ await extractCollectionKeyFromShareURL(tempURL);
+
+ // Create context from URL parameters
+ const context: JoinAlbumContext = {
+ accessToken,
+ collectionKey,
+ collectionKeyHash,
+ collectionID: 0,
+ ...(jwtFromURL && { accessTokenJWT: jwtFromURL }),
+ };
+
+ localStorage.setItem(
+ JOIN_ALBUM_CONTEXT_KEY,
+ JSON.stringify(context),
+ );
+ }
+ } catch (error) {
+ log.error(
+ "Failed to store join album context from URL",
+ error,
+ );
+ showMiniDialog({
+ title: t("error"),
+ message: t("generic_error_retry"),
+ });
+ }
+ }
+
const albumsURL = new URL(albumsAppOrigin());
currentURL.pathname = router.pathname;
if (
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index bccb2f8db9..3964552b36 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -50,6 +50,7 @@ import {
useIsTouchscreen,
} from "ente-base/components/utils/hooks";
import { useBaseContext } from "ente-base/context";
+import { isDevBuild } from "ente-base/env";
import {
isHTTP401Error,
isHTTPErrorWithStatus,
@@ -59,6 +60,7 @@ import log from "ente-base/log";
import {
albumsAppOrigin,
isCustomAlbumsAppOrigin,
+ photosAppOrigin,
shouldOnlyServeAlbumsApp,
} from "ente-base/origins";
import { FullScreenDropZone } from "ente-gallery/components/FullScreenDropZone";
@@ -79,6 +81,7 @@ import { type EnteFile } from "ente-media/file";
import {
removePublicCollectionAccessTokenJWT,
removePublicCollectionByKey,
+ savedLastPublicCollectionReferralCode,
savedPublicCollectionAccessTokenJWT,
savedPublicCollectionByKey,
savedPublicCollectionFiles,
@@ -96,6 +99,7 @@ import {
} from "ente-new/photos/components/gallery/ListHeader";
import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";
import { usePhotosAppContext } from "ente-new/photos/types/context";
+import { useJoinAlbum } from "hooks/useJoinAlbum";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -103,6 +107,7 @@ import { type FileWithPath } from "react-dropzone";
import { Trans } from "react-i18next";
import { uploadManager } from "services/upload-manager";
import { getSelectedFiles, type SelectedState } from "utils/file";
+import { getSignUpOrInstallURL } from "utils/public-album";
export default function PublicCollectionGallery() {
const { showMiniDialog, onGenericError } = useBaseContext();
@@ -114,6 +119,7 @@ export default function PublicCollectionGallery() {
const [publicFiles, setPublicFiles] = useState<EnteFile[] | undefined>(
undefined,
);
+ const [referralCode, setReferralCode] = useState<string>("");
const [errorMessage, setErrorMessage] = useState<string>("");
const [loading, setLoading] = useState(true);
const [isPasswordProtected, setIsPasswordProtected] = useState(false);
@@ -140,6 +146,32 @@ export default function PublicCollectionGallery() {
const router = useRouter();
+ // Handle action=join parameter: redirect to web.ente.io for authentication
+ // This MUST run before any other logic to ensure proper redirect on desktop/mobile-without-app
+ // On mobile with app installed, App Links/Universal Links will open the app before this code runs
+ useEffect(() => {
+ const params = new URLSearchParams(window.location.search);
+ const action = params.get("action");
+
+ if (action === "join") {
+ const t = params.get("t");
+ const jwt = params.get("jwt");
+ const hash = window.location.hash;
+
+ if (!t) {
+ return;
+ }
+
+ // Build the web app URL for authentication
+ const webAppURL = photosAppOrigin();
+
+ const jwtParam = jwt ? `&jwt=${encodeURIComponent(jwt)}` : "";
+ const redirectURL = `${webAppURL}/?joinAlbum=${t}${jwtParam}${hash}`;
+
+ window.location.href = redirectURL;
+ }
+ }, []);
+
const showPublicLinkExpiredMessage = () =>
showMiniDialog({
title: t("link_expired"),
@@ -226,6 +258,9 @@ export default function PublicCollectionGallery() {
return;
}
+ setReferralCode(
+ (await savedLastPublicCollectionReferralCode()) ?? "",
+ );
setPublicCollection(collection);
setIsPasswordProtected(
!!collection.publicURLs[0]?.passwordEnabled,
@@ -270,15 +305,15 @@ export default function PublicCollectionGallery() {
showLoadingBar();
setLoading(true);
try {
- const { collection } = await pullCollection(
- accessToken,
- collectionKey.current!,
- );
+ const { collection, referralCode: userReferralCode } =
+ await pullCollection(accessToken, collectionKey.current!);
if (checkAndRedirectForTripAlbum(collection)) {
return;
}
+ setReferralCode(userReferralCode);
+
setPublicCollection(collection);
const isPasswordProtected =
!!collection.publicURLs[0]?.passwordEnabled;
@@ -437,6 +472,8 @@ export default function PublicCollectionGallery() {
: undefined;
}, [publicCollection]);
+ const shouldShowReferralBanner = isDevBuild || !isCustomAlbumsAppOrigin;
+
const closeUploadTypeSelectorView = () => {
setUploadTypeSelectorView(false);
};
@@ -462,13 +499,16 @@ export default function PublicCollectionGallery() {
);
const fileListFooter = useMemo<FileListHeaderOrFooter>(() => {
- const props = { onAddPhotos };
+ const props = {
+ referralCode: shouldShowReferralBanner ? referralCode : undefined,
+ onAddPhotos,
+ };
return {
component: <FileListFooter {...props} />,
height: fileListFooterHeightForProps(props),
extendToInlineEdges: true,
};
- }, [onAddPhotos]);
+ }, [referralCode, onAddPhotos, shouldShowReferralBanner]);
if (loading && (!publicFiles || !credentials.current)) {
return <LoadingIndicator />;
@@ -522,6 +562,9 @@ export default function PublicCollectionGallery() {
collection={publicCollection}
onAddPhotos={onAddPhotos}
enableDownload={downloadEnabled}
+ accessToken={credentials.current.accessToken}
+ collectionKey={collectionKey.current}
+ credentials={credentials}
/>
) : (
<>
@@ -543,11 +586,31 @@ export default function PublicCollectionGallery() {
<EnteLogoLink href="https://ente.io">
<EnteLogo height={15} />
</EnteLogoLink>
- {onAddPhotos ? (
- <AddPhotosButton onClick={onAddPhotos} />
- ) : (
- <GoToEnte />
- )}
+ <Stack direction="row" spacing={2}>
+ {onAddPhotos && (
+ <AddPhotosButton
+ onClick={onAddPhotos}
+ />
+ )}
+ {!onAddPhotos ||
+ publicCollection?.publicURLs[0]
+ ?.enableJoin ? (
+ <PrimaryActionButton
+ enableJoin={
+ publicCollection?.publicURLs[0]
+ ?.enableJoin
+ }
+ publicCollection={publicCollection}
+ accessToken={
+ credentials.current.accessToken
+ }
+ collectionKey={
+ collectionKey.current
+ }
+ credentials={credentials}
+ />
+ ) : null}
+ </Stack>
</SpacedRow>
)}
</NavbarBase>
@@ -643,12 +706,44 @@ const AddMorePhotosButton: React.FC<ButtonishProps> = ({ onClick }) => {
);
};
-const GoToEnte: React.FC = () => {
- // Touchscreen devices are overwhemingly likely to be Android or iOS.
+interface PrimaryActionButtonProps {
+ /** If true, shows "Join Album" button instead of "Sign Up" */
+ enableJoin?: boolean;
+ /** Collection to join (required if enableJoin is true) */
+ publicCollection?: Collection;
+ /** Access token for the public link */
+ accessToken?: string;
+ /** Collection key from URL (base64 encoded) */
+ collectionKey?: string;
+ /** Credentials ref for JWT token access */
+ credentials?: React.RefObject<PublicAlbumsCredentials | undefined>;
+}
+
+const PrimaryActionButton: React.FC<PrimaryActionButtonProps> = ({
+ enableJoin,
+ publicCollection,
+ accessToken,
+ collectionKey,
+ credentials,
+}) => {
const isTouchscreen = useIsTouchscreen();
+ const { handleJoinAlbum } = useJoinAlbum({
+ publicCollection,
+ accessToken,
+ collectionKey,
+ credentials,
+ });
+
+ if (enableJoin) {
+ return (
+ <Button color="accent" onClick={handleJoinAlbum}>
+ {t("join_album")}
+ </Button>
+ );
+ }
return (
- <Button color="accent" href="https://ente.io">
+ <Button color="accent" href={getSignUpOrInstallURL(isTouchscreen)}>
{isTouchscreen ? t("install") : t("sign_up")}
</Button>
);
@@ -739,14 +834,17 @@ const FileListHeader: React.FC<FileListHeaderProps> = ({
};
interface FileListFooterProps {
+ referralCode?: string;
onAddPhotos?: () => void;
}
/**
* The dynamic (prop-dependent) height of {@link FileListFooter}.
*/
-const fileListFooterHeightForProps = ({ onAddPhotos }: FileListFooterProps) =>
- (onAddPhotos ? 104 : 0) + 75;
+const fileListFooterHeightForProps = ({
+ referralCode,
+ onAddPhotos,
+}: FileListFooterProps) => (onAddPhotos ? 104 : 0) + (referralCode ? 113 : 75);
/**
* A footer shown after the listing of files.
@@ -755,7 +853,10 @@ const fileListFooterHeightForProps = ({ onAddPhotos }: FileListFooterProps) =>
* props, calculated using {@link fileListFooterHeightForProps}.
*/
-const FileListFooter: React.FC<FileListFooterProps> = ({ onAddPhotos }) => (
+const FileListFooter: React.FC<FileListFooterProps> = ({
+ referralCode,
+ onAddPhotos,
+}) => (
<Stack sx={{ flex: 1, alignSelf: "flex-end" }}>
{onAddPhotos && (
<CenteredFill>
@@ -791,5 +892,22 @@ const FileListFooter: React.FC<FileListFooterProps> = ({ onAddPhotos }) => (
/>
</Typography>
</Link>
+ {referralCode && (
+ <Typography
+ sx={{
+ mt: "6px",
+ mb: 0,
+ padding: "8px",
+ bgcolor: "accent.main",
+ color: "accent.contrastText",
+ textAlign: "center",
+ }}
+ >
+ <Trans
+ i18nKey={"sharing_referral_code"}
+ values={{ referralCode }}
+ />
+ </Typography>
+ )}
</Stack>
);
diff --git a/web/apps/photos/src/utils/public-album.ts b/web/apps/photos/src/utils/public-album.ts
new file mode 100644
index 0000000000..7cd852766d
--- /dev/null
+++ b/web/apps/photos/src/utils/public-album.ts
@@ -0,0 +1,25 @@
+import { photosAppOrigin } from "ente-base/origins";
+
+/**
+ * Get the appropriate URL for sign up or install based on platform.
+ */
+export const getSignUpOrInstallURL = (isTouchscreen: boolean): string => {
+ if (isTouchscreen) {
+ // For mobile devices, redirect to app stores
+ const userAgent = navigator.userAgent || "";
+ const isIOS =
+ userAgent.includes("iPad") ||
+ userAgent.includes("iPhone") ||
+ userAgent.includes("iPod");
+ const isAndroid = userAgent.includes("Android");
+
+ if (isIOS) {
+ return "https://apps.apple.com/app/id1542026904";
+ } else if (isAndroid) {
+ return "https://play.google.com/store/apps/details?id=io.ente.photos";
+ }
+ // For other touchscreen devices, fall back to web
+ }
+ // For desktop or other platforms, redirect to photos app
+ return photosAppOrigin();
+};
diff --git a/web/packages/accounts/components/LoginContents.tsx b/web/packages/accounts/components/LoginContents.tsx
index c0188890d9..b6dbacfa70 100644
--- a/web/packages/accounts/components/LoginContents.tsx
+++ b/web/packages/accounts/components/LoginContents.tsx
@@ -10,10 +10,11 @@ import { LinkButton } from "ente-base/components/LinkButton";
import { LoadingButton } from "ente-base/components/mui/LoadingButton";
import { isMuseumHTTPError } from "ente-base/http";
import log from "ente-base/log";
+import { JOIN_ALBUM_CONTEXT_KEY } from "ente-new/albums/services/join-album";
import { useFormik } from "formik";
import { t } from "i18next";
import { useRouter } from "next/router";
-import React, { useCallback } from "react";
+import React, { useCallback, useEffect, useState } from "react";
import { z } from "zod";
import { AccountsPageTitleWithCaption } from "./LoginComponents";
@@ -39,6 +40,13 @@ export const LoginContents: React.FC<LoginContentsProps> = ({
host,
}) => {
const router = useRouter();
+ const [isJoinAlbumContext, setIsJoinAlbumContext] = useState(false);
+
+ useEffect(() => {
+ // Check if we're in a join album context
+ const joinAlbumContext = localStorage.getItem(JOIN_ALBUM_CONTEXT_KEY);
+ setIsJoinAlbumContext(!!joinAlbumContext);
+ }, []);
const loginUser = useCallback(
async (email: string, setFieldError: (message: string) => void) => {
@@ -94,7 +102,7 @@ export const LoginContents: React.FC<LoginContentsProps> = ({
return (
<>
<AccountsPageTitleWithCaption>
- {t("login")}
+ {isJoinAlbumContext ? t("login_to_join_album") : t("login")}
</AccountsPageTitleWithCaption>
<form onSubmit={formik.handleSubmit}>
<TextField
diff --git a/web/packages/accounts/components/SignUpContents.tsx b/web/packages/accounts/components/SignUpContents.tsx
index 022adfb1e7..fdc25be929 100644
--- a/web/packages/accounts/components/SignUpContents.tsx
+++ b/web/packages/accounts/components/SignUpContents.tsx
@@ -35,10 +35,11 @@ import { deriveKeyInsufficientMemoryErrorMessage } from "ente-base/crypto/types"
import { isMuseumHTTPError } from "ente-base/http";
import log from "ente-base/log";
import { saveMasterKeyInSessionAndSafeStore } from "ente-base/session";
+import { JOIN_ALBUM_CONTEXT_KEY } from "ente-new/albums/services/join-album";
import { useFormik } from "formik";
import { t } from "i18next";
import type { NextRouter } from "next/router";
-import React, { useCallback, useState } from "react";
+import React, { useCallback, useEffect, useState } from "react";
import { Trans } from "react-i18next";
import { z } from "zod";
import { PasswordStrengthHint } from "./PasswordStrength";
@@ -67,6 +68,13 @@ export const SignUpContents: React.FC<SignUpContentsProps> = ({
host,
}) => {
const [showPassword, setShowPassword] = useState(false);
+ const [isJoinAlbumContext, setIsJoinAlbumContext] = useState(false);
+
+ useEffect(() => {
+ // Check if we're in a join album context
+ const joinAlbumContext = localStorage.getItem(JOIN_ALBUM_CONTEXT_KEY);
+ setIsJoinAlbumContext(!!joinAlbumContext);
+ }, []);
const handleToggleShowHidePassword = useCallback(
() => setShowPassword((show) => !show),
@@ -316,7 +324,9 @@ export const SignUpContents: React.FC<SignUpContentsProps> = ({
return (
<>
- <AccountsPageTitle>{t("sign_up")}</AccountsPageTitle>
+ <AccountsPageTitle>
+ {isJoinAlbumContext ? t("signup_to_join_album") : t("sign_up")}
+ </AccountsPageTitle>
{form}
<Divider sx={{ mt: 1 }} />
<AccountsPageFooter>
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index 60ce9e6000..506e186b3c 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -6,7 +6,9 @@
"intro_slide_3_title": "Available<br/>everywhere",
"intro_slide_3": "Android, iOS, Web, Desktop",
"login": "Login",
+ "login_to_join_album": "Login to join album",
"sign_up": "Signup",
+ "signup_to_join_album": "Signup to join album",
"new_to_ente": "New to Ente",
"existing_user": "Existing user",
"enter_email": "Enter email address",
@@ -47,6 +49,9 @@
"create_albums": "Create albums",
"album_name": "Album name",
"album_created": "Album created",
+ "join_album": "Join album",
+ "joined_album": "Joined album",
+ "album_join_failed": "Failed to join album",
"close": "Close",
"yes": "Yes",
"no": "No",
@@ -587,8 +592,6 @@
"oldest_first": "Oldest first",
"pin_album": "Pin album",
"unpin_album": "Unpin album",
- "pin_person": "Pin person",
- "unpin_person": "Unpin person",
"unpreviewable_file_message": "This file could not be previewed",
"download_complete": "Download complete",
"downloading_album": "Downloading {{name}}",
diff --git a/web/packages/base/origins.ts b/web/packages/base/origins.ts
index cff4f18ae7..b8efcafb21 100644
--- a/web/packages/base/origins.ts
+++ b/web/packages/base/origins.ts
@@ -120,3 +120,13 @@ export const isCustomShareAppOrigin =
*/
export const shareAppOrigin = (): string =>
process.env.NEXT_PUBLIC_ENTE_SHARE_ENDPOINT ?? "https://share.ente.io";
+
+/**
+ * Return the origin that serves the photos app.
+ *
+ * Defaults to our production instance, "https://web.ente.io", but can be
+ * overridden by setting the `NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT` environment
+ * variable.
+ */
+export const photosAppOrigin = (): string =>
+ process.env.NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT ?? "https://web.ente.io";
diff --git a/web/packages/new/albums/services/join-album.ts b/web/packages/new/albums/services/join-album.ts
new file mode 100644
index 0000000000..e93b49101e
--- /dev/null
+++ b/web/packages/new/albums/services/join-album.ts
@@ -0,0 +1,224 @@
+import { savedKeyAttributes } from "ente-accounts/services/accounts-db";
+import { ensureLocalUser } from "ente-accounts/services/user";
+import { boxSeal } from "ente-base/crypto";
+import { authenticatedRequestHeaders } from "ente-base/http";
+import log from "ente-base/log";
+import { apiURL } from "ente-base/origins";
+import type { Collection } from "ente-media/collection";
+
+/**
+ * Service for handling the join album flow for public collections.
+ * This manages the process of joining a public album, including:
+ * - Storing album context before authentication
+ * - Auto-joining after authentication
+ * - Cleaning up stored context
+ */
+
+export const JOIN_ALBUM_CONTEXT_KEY = "ente_join_album_context";
+
+export interface JoinAlbumContext {
+ accessToken: string;
+ collectionKey: string; // Base64 encoded collection key for API calls
+ collectionKeyHash: string; // Original hash value from URL (base58 or hex)
+ collectionID: number;
+ accessTokenJWT?: string; // JWT token for password-protected albums
+}
+
+/**
+ * Store the album context before redirecting to auth.
+ * This preserves the album information across the authentication flow.
+ */
+export const storeJoinAlbumContext = async (
+ accessToken: string,
+ collectionKey: string,
+ collectionKeyHash: string,
+ collection: Collection,
+) => {
+ // Import the function to get saved JWT token for password-protected albums
+ const { savedPublicCollectionAccessTokenJWT } = await import(
+ "./public-albums-fdb"
+ );
+
+ // Get the JWT token if this is a password-protected album
+ const accessTokenJWT =
+ await savedPublicCollectionAccessTokenJWT(accessToken);
+
+ const context: JoinAlbumContext = {
+ accessToken,
+ collectionKey,
+ collectionKeyHash,
+ collectionID: collection.id,
+ };
+
+ // Add JWT token if present
+ if (accessTokenJWT) {
+ context.accessTokenJWT = accessTokenJWT;
+ }
+
+ const serializedContext = JSON.stringify(context);
+
+ localStorage.setItem(JOIN_ALBUM_CONTEXT_KEY, serializedContext);
+};
+
+/**
+ * Retrieve stored album context after authentication.
+ * Checks localStorage for the stored context.
+ */
+export const getJoinAlbumContext = (): JoinAlbumContext | null => {
+ const stored = localStorage.getItem(JOIN_ALBUM_CONTEXT_KEY);
+ if (!stored) {
+ return null;
+ }
+
+ try {
+ const context = JSON.parse(stored) as JoinAlbumContext;
+ return context;
+ } catch {
+ return null;
+ }
+};
+
+/**
+ * Clear the stored album context after successful join or timeout.
+ */
+export const clearJoinAlbumContext = () => {
+ localStorage.removeItem(JOIN_ALBUM_CONTEXT_KEY);
+};
+
+/**
+ * Check if there's a pending album to join.
+ */
+export const hasPendingAlbumToJoin = (): boolean => {
+ return getJoinAlbumContext() !== null;
+};
+
+/**
+ * Join a public album by sending the encrypted collection key to the server.
+ * This adds the album to the user's collection.
+ */
+export const joinPublicAlbum = async (
+ accessToken: string,
+ collectionID: number,
+ encryptedKey: string,
+ accessTokenJWT?: string,
+): Promise<void> => {
+ const authHeaders = await authenticatedRequestHeaders();
+ const url = await apiURL("/collections/join-link");
+
+ const headers = {
+ "Content-Type": "application/json",
+ ...authHeaders,
+ "X-Auth-Access-Token": accessToken,
+ ...(accessTokenJWT && { "X-Auth-Access-Token-JWT": accessTokenJWT }), // Include JWT for password-protected albums
+ };
+
+ const response = await fetch(url, {
+ method: "POST",
+ headers,
+ body: JSON.stringify({ collectionID, encryptedKey }),
+ });
+
+ if (!response.ok) {
+ log.error("Album join API failed", {
+ collectionID,
+ status: response.status,
+ });
+ let errorMessage = `Failed to join album (status: ${response.status})`;
+ try {
+ const errorData = (await response.json()) as {
+ message?: string;
+ code?: string;
+ };
+ errorMessage = errorData.message ?? errorMessage;
+ } catch {
+ // Ignore parse error, use default message
+ }
+ throw new Error(errorMessage);
+ }
+};
+
+/**
+ * Process the pending album join after authentication.
+ * This should be called after successful sign-in/sign-up.
+ *
+ * @returns The collection ID if an album was successfully joined, null otherwise
+ */
+export const processPendingAlbumJoin = async (): Promise<number | null> => {
+ const context = getJoinAlbumContext();
+
+ if (!context) {
+ return null;
+ }
+
+ try {
+ // If collectionID is 0 (placeholder), we need to fetch the actual collection first
+ let collectionID = context.collectionID;
+ let collection: Collection | undefined;
+ if (collectionID === 0) {
+ // Import the pullCollection function dynamically from the correct module
+ const { pullCollection } = await import("./public-collection");
+ const result = await pullCollection(
+ context.accessToken,
+ context.collectionKey,
+ );
+ collection = result.collection;
+ collectionID = collection.id;
+
+ // Update the context with the actual collection ID
+ const updatedContext = { ...context, collectionID };
+ localStorage.setItem(
+ JOIN_ALBUM_CONTEXT_KEY,
+ JSON.stringify(updatedContext),
+ );
+ } else {
+ // Fetch the collection to check ownership
+ const { pullCollection } = await import("./public-collection");
+ const result = await pullCollection(
+ context.accessToken,
+ context.collectionKey,
+ );
+ collection = result.collection;
+ }
+
+ // Check if the user is the owner of the album
+ const currentUser = ensureLocalUser();
+ if (collection.owner.id === currentUser.id) {
+ clearJoinAlbumContext();
+ return null;
+ }
+
+ // Get user's key attributes from local storage
+ const keyAttributes = savedKeyAttributes();
+ if (!keyAttributes) {
+ throw new Error(
+ "Key attributes not found. Please try logging in again.",
+ );
+ }
+
+ const publicKey = keyAttributes.publicKey;
+
+ // Encrypt the collection key with user's public key
+ // The collection key is already base64 encoded, and boxSeal expects base64
+ const encryptedKey = await boxSeal(context.collectionKey, publicKey);
+
+ // Join the album (include JWT token if present for password-protected albums)
+ await joinPublicAlbum(
+ context.accessToken,
+ collectionID,
+ encryptedKey,
+ context.accessTokenJWT,
+ );
+
+ // Clear the context after successful join
+ // Note: If any error occurs above, this won't execute and context will be preserved for retry
+ clearJoinAlbumContext();
+
+ return collectionID;
+ } catch (error) {
+ log.error("Failed to process pending album join", {
+ collectionID: context.collectionID,
+ error,
+ });
+ throw error;
+ }
+};