π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Conv
Manav Rathif96e7507bcc3
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsxindex 8e7b3e359e..e8f3ef2e7f 100644--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx@@ -55,11 +55,13 @@ import { type CollectionUser } from "ente-media/collection";import { PublicLinkCreated } from "ente-new/photos/components/share/PublicLinkCreated";import { avatarTextColor } from "ente-new/photos/services/avatar";import {+ createPublicURL,deleteShareURL,shareCollection,unshareCollection,updatePublicURL,- type PublicURLUpdatableAttributes,+ type CreatePublicURLAttributes,+ type UpdatePublicURLAttributes,} from "ente-new/photos/services/collection";import type { CollectionSummary } from "ente-new/photos/services/collection/ui";import { usePhotosAppContext } from "ente-new/photos/types/context";@@ -77,7 +79,6 @@ import React, {useState,} from "react";import { Trans } from "react-i18next";-import { createShareableURL } from "services/collectionService";import { z } from "zod/v4";type CollectionShareProps = ModalVisibilityProps & {@@ -1045,28 +1046,11 @@ const EnablePublicShareOptions: React.FC<EnablePublicShareOptionsProps> = ({const galleryContext = useContext(GalleryContext);const [sharableLinkError, setSharableLinkError] = useState(null);- const createSharableURLHelper = async () => {+ const handleCreateURL = async (attributes?: CreatePublicURLAttributes) => {try {setSharableLinkError(null);galleryContext.setBlockingLoad(true);- setPublicURL(await createShareableURL(collection));- onLinkCreated();- galleryContext.syncWithRemote(false, true);- } catch (e) {- const errorMessage = handleSharingErrors(e);- setSharableLinkError(errorMessage);- } finally {- galleryContext.setBlockingLoad(false);- }- };-- const createCollectPhotoShareableURLHelper = async () => {- try {- setSharableLinkError(null);- galleryContext.setBlockingLoad(true);- const publicURL = await createShareableURL(collection);- await updatePublicURL(collection.id, { enableCollect: true });- setPublicURL(publicURL);+ setPublicURL(await createPublicURL(collection.id, attributes));onLinkCreated();galleryContext.syncWithRemote(false, true);} catch (e) {@@ -1086,13 +1070,13 @@ const EnablePublicShareOptions: React.FC<EnablePublicShareOptionsProps> = ({<RowButtonlabel={t("create_public_link")}startIcon={<LinkIcon />}- onClick={createSharableURLHelper}+ onClick={handleCreateURL}/><RowButtonDivider /><RowButtonlabel={t("collect_photos")}startIcon={<DownloadSharpIcon />}- onClick={createCollectPhotoShareableURLHelper}+ onClick={() => handleCreateURL({ enableCollect: true })}/></RowButtonGroup>{sharableLinkError && (@@ -1214,7 +1198,7 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({};const handlePublicURLUpdate = async (- updates: PublicURLUpdatableAttributes,+ updates: UpdatePublicURLAttributes,) => {try {galleryContext.setBlockingLoad(true);@@ -1314,7 +1298,7 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({*/interface ManagePublicLinkSettingProps {publicURL: PublicURL;- onUpdate: (req: PublicURLUpdatableAttributes) => Promise<void>;+ onUpdate: (req: UpdatePublicURLAttributes) => Promise<void>;}/**diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.tsindex 5bfc935603..9eb28d8b72 100644--- a/web/apps/photos/src/services/collectionService.ts+++ b/web/apps/photos/src/services/collectionService.ts@@ -505,28 +505,6 @@ const renameCollection1 = async ();};-export const createShareableURL = async (collection: Collection) => {- try {- const token = getToken();- if (!token) {- return null;- }- const createPublicAccessTokenRequest: CreatePublicAccessTokenRequest = {- collectionID: collection.id,- };- const resp = await HTTPService.post(- await apiURL("/collections/share-url"),- createPublicAccessTokenRequest,- null,- { "X-Auth-Token": token },- );- return resp.data.result as PublicURL;- } catch (e) {- log.error("createShareableURL failed ", e);- throw e;- }-};-/*** Return the user's own favorites collection, if any.*/diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.tsindex 698cebb7f9..fe5ecb65bc 100644--- a/web/packages/new/photos/services/collection.ts+++ b/web/packages/new/photos/services/collection.ts@@ -558,7 +558,7 @@ export const unshareCollection = async (collectionID: number, email: string) =>* creating a link.*/-type CreatePublicLinkOpts = Pick<+export type CreatePublicURLAttributes = Pick<Partial<PublicURL>,"enableCollect" | "enableJoin" | "validTill" | "deviceLimit">;@@ -571,19 +571,19 @@ type CreatePublicLinkOpts = Pick<* @param collectionID The ID of the collection for which the public link should* be created.*- * @param opts Optional attributes to set when creating the public link.+ * @param attributes Optional attributes to set when creating the public link.** the . If true, then the link is created* with the {@link enableCollect} attribute*/export const createPublicURL = async (collectionID: number,- opts?: CreatePublicLinkOpts,-) => {+ attributes?: CreatePublicURLAttributes,+): Promise<PublicURL> => {const res = await fetch(await apiURL("/collections/share-url"), {method: "POST",headers: await authenticatedRequestHeaders(),- body: JSON.stringify({ collectionID, ...opts }),+ body: JSON.stringify({ collectionID, ...attributes }),});ensureOk(res);return z.object({ result: RemotePublicURL }).parse(await res.json()).result;@@ -593,7 +593,7 @@ export const createPublicURL = async (* The subset of public URL attributes that can be updated by the user after the* link has already been created.*/-export type PublicURLUpdatableAttributes = Omit<+export type UpdatePublicURLAttributes = Omit<Partial<PublicURL>,"url" | "enablePassword"> & { disablePassword?: boolean; passHash?: string };@@ -613,7 +613,7 @@ export type PublicURLUpdatableAttributes = Omit<*/export const updatePublicURL = async (collectionID: number,- updates: PublicURLUpdatableAttributes,+ updates: UpdatePublicURLAttributes,): Promise<PublicURL> => {const res = await fetch(await apiURL("/collections/share-url"), {method: "PUT",