Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
fix(cloud): address domain and retired storage review feedback
Timothy Yinbc33cd576f92
diff --git a/apps/cloud/app/components/CloudSitePublication.vue b/apps/cloud/app/components/CloudSitePublication.vueindex 24f003b3..291bca50 100644--- a/apps/cloud/app/components/CloudSitePublication.vue+++ b/apps/cloud/app/components/CloudSitePublication.vue@@ -17,9 +17,11 @@ const { data, status, error, refresh } = useFetch<{legacyHostname?: string | null}}>(`/api/sites/${context.value?.siteId}/settings`)-const { data: domainOverview } = useFetch<DomainOverview>(- `/api/sites/${context.value?.siteId}/domains`,-)+const {+ data: domainOverview,+ error: domainError,+ refresh: refreshDomains,+} = useFetch<DomainOverview>(`/api/sites/${context.value?.siteId}/domains`)const customHost = computed(() => {if (!domainOverview.value?.enabled || !domainOverview.value.routingReady)return undefined@@ -27,7 +29,7 @@ const customHost = computed(() => {domainOverview.value?.domains.filter((d) => d.status === 'active' && !d.holdReason && !d.cleanupPending,) ?? []- return (eligible.find((d) => d.primary) ?? eligible[0])?.hostname+ return eligible.find((d) => d.primary)?.hostname})const host = computed(() =>@@ -118,6 +120,17 @@ async function unpublish() {>{{ $t('cloud.domains.routingPending') }}</p>+ <CloudAlert+ v-if="domainError"+ tone="error"+ >{{ $t('cloud.domains.loadFailed')+ }}<CloudButton+ size="sm"+ variant="secondary"+ @click="refreshDomains()"+ >{{ $t('cloud.messages.retry') }}</CloudButton+ ></CloudAlert+ ><div class="cf-site-address-block"><divv-if="address"diff --git a/apps/cloud/app/components/CloudStorageSettings.vue b/apps/cloud/app/components/CloudStorageSettings.vueindex 052fa471..dd0066c3 100644--- a/apps/cloud/app/components/CloudStorageSettings.vue+++ b/apps/cloud/app/components/CloudStorageSettings.vue@@ -18,6 +18,11 @@ const {const quota = useCloudQuota(useEntryContext().value?.workspaceId)const { t } = useI18n()const removal = ref<string | null>(null)+const rotationId = ref('')+watch(rotationId, () => {+ rotation.accessKeyId = ''+ rotation.secretAccessKey = ''+})async function selectStorage(id: string) {const saved = await action(() =>@@ -95,7 +100,7 @@ const byosAdmission = computed(() => quota.gate('byos'))</div><divclass="cf-storage-option-actions"- v-if="admin && !connection.retired"+ v-if="admin"><CloudButtonsize="sm"@@ -106,12 +111,21 @@ const byosAdmission = computed(() => quota.gate('byos'))connection.uploads_enabled === 0 ||(!connection.pool_id && !allowance?.byosLimits.byos)"+ v-if="!connection.retired"@click="selectStorage(connection.id)">{{ $t('cloud.storageManager.use') }}</CloudButton><CloudButtonv-if="!connection.pool_id"size="sm"+ variant="secondary"+ :disabled="busy"+ @click="rotationId = connection.id"+ >{{ $t('cloud.messages.rotateStorageCredentials') }}</CloudButton+ >+ <CloudButton+ v-if="!connection.pool_id && !connection.retired"+ size="sm"variant="ghost":disabled="busy"@click="removal = connection.id"@@ -149,17 +163,17 @@ const byosAdmission = computed(() => quota.gate('byos'))></UModal><details- v-if="- admin &&- connectionId &&- !connections.find((c) => c.id === connectionId)?.pool_id- "+ v-if="admin && rotationId"+ openclass="cf-storage-details"><summary>{{ $t('cloud.messages.rotateStorageCredentials') }}</summary>+ <p class="cf-field-hint">+ {{ connections.find((c) => c.id === rotationId)?.config.bucket }}+ </p><formclass="cf-storage-grid"- @submit.prevent="rotateStorage"+ @submit.prevent="rotateStorage(rotationId)"><label>{{ $t('cloud.messages.newAccessKeyId')diff --git a/apps/cloud/app/composables/useCloudSiteMedia.ts b/apps/cloud/app/composables/useCloudSiteMedia.tsindex d0879b09..40b1dd0d 100644--- a/apps/cloud/app/composables/useCloudSiteMedia.ts+++ b/apps/cloud/app/composables/useCloudSiteMedia.ts@@ -224,8 +224,10 @@ export function useCloudMediaWorkspace(props: {storage.secretAccessKey = ''}, t('cloud.messages.storageConnectedAndVerified'))}- async function rotateStorage() {- const selected = connections.value.find((c) => c.id === connectionId.value)+ async function rotateStorage(targetId?: string) {+ const selected = connections.value.find(+ (c) => c.id === (targetId ?? connectionId.value),+ )if (!selected) returnawait action(async () => {await api(base.value + '/storage/' + selected.id + '/rotate', {diff --git a/apps/cloud/i18n/locales/en.json b/apps/cloud/i18n/locales/en.jsonindex 7099d631..6be621ba 100644--- a/apps/cloud/i18n/locales/en.json+++ b/apps/cloud/i18n/locales/en.json@@ -474,7 +474,7 @@"refresh": "Refresh","saved": "Domain settings updated.","failed": "The domain operation failed. Refresh and try again.",- "loadFailed": "Domain settings could not be loaded.",+ "loadFailed": "Could not load domain settings. Retry to confirm the primary address.","defaultHelp": "Your default address remains available when a custom domain is paused or removed.","defaultConflict": "This default address is reserved or conflicts with another binding. Choose a new site address.","changeAddress": "Change site address",diff --git a/apps/cloud/i18n/locales/zh-Hans.json b/apps/cloud/i18n/locales/zh-Hans.jsonindex 24470031..612fc94f 100644--- a/apps/cloud/i18n/locales/zh-Hans.json+++ b/apps/cloud/i18n/locales/zh-Hans.json@@ -474,7 +474,7 @@"refresh": "刷新","saved": "域名设置已更新。","failed": "域名操作失败,请刷新后重试。",- "loadFailed": "无法加载域名设置。",+ "loadFailed": "无法加载域名设置,请重试以确认主地址。","defaultHelp": "自定义域名暂停或移除后,默认地址仍然可用。","defaultConflict": "此默认地址已被保留或存在绑定冲突,请选择新的站点地址。","changeAddress": "更改站点地址",diff --git a/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts b/apps/cloud/server/api/sites/[siteId]/media/[...operation].tsindex 898a9874..be86dd79 100644--- a/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts+++ b/apps/cloud/server/api/sites/[siteId]/media/[...operation].ts@@ -131,7 +131,7 @@ export default definePlatformHandler(async (event) => {statusCode: 403,statusMessage: 'Your plan does not include custom storage',})- if ((await vault.list()).length >= 20)+ if ((await vault.list()).filter((c) => c.retired !== 1).length >= 20)throw createError({ statusCode: 429 })const config = {endpoint: text(body.endpoint, 512),@@ -163,11 +163,7 @@ export default definePlatformHandler(async (event) => {) {const old = await vault.get(ID(id))if (!old) throw createError({ statusCode: 404 })- if (- 'poolId' in old ||- !(await workspaceEntitlements(raw, site.workspaceId, 'byos')).limits.byos- )- throw createError({ statusCode: 403 })+ if ('poolId' in old) throw createError({ statusCode: 403 })const credentials = {accessKeyId: text(body.accessKeyId, 256),secretAccessKey: text(body.secretAccessKey, 256),diff --git a/packages/platform/src/storage-vault.ts b/packages/platform/src/storage-vault.tsindex 20ee5539..d86c7285 100644--- a/packages/platform/src/storage-vault.ts+++ b/packages/platform/src/storage-vault.ts@@ -80,13 +80,14 @@ export function createStorageVault(async list() {const result = (await db.prepare(- 'SELECT c.id,c.current_revision,c.healthy,c.checked_at,c.pool_id,c.retired,CASE WHEN c.retired=1 THEN 0 WHEN c.pool_id IS NULL THEN 1 ELSE COALESCE(p.enabled,0) END AS uploads_enabled,v.public_json FROM cloud_storage_connections c JOIN cloud_storage_versions v ON v.site_id=c.site_id AND v.connection_id=c.id AND v.revision=c.current_revision LEFT JOIN platform_storage_pools p ON p.id=c.pool_id WHERE c.site_id=? ORDER BY c.id LIMIT 20',+ 'SELECT c.id,c.current_revision,c.healthy,c.checked_at,c.pool_id,c.retired,CASE WHEN c.retired=1 THEN 0 WHEN c.pool_id IS NULL THEN 1 ELSE COALESCE(p.enabled,0) END AS uploads_enabled,v.public_json FROM cloud_storage_connections c JOIN cloud_storage_versions v ON v.site_id=c.site_id AND v.connection_id=c.id AND v.revision=c.current_revision LEFT JOIN platform_storage_pools p ON p.id=c.pool_id WHERE c.site_id=? ORDER BY c.retired,c.id',).bind(siteId)) as unknown as { all<T>(): Promise<{ results: T[] }> }return (await result.all<{id: stringpool_id: string | null+ retired: numberuploads_enabled: numbercurrent_revision: numberhealthy: number@@ -161,7 +162,7 @@ export function createStorageVault(const results = await db.batch([db.prepare(- 'INSERT INTO cloud_storage_connections(site_id,id,current_revision,healthy,checked_at) SELECT ?,?,1,1,? WHERE (SELECT COUNT(*) FROM cloud_storage_connections WHERE site_id=?)<20',+ 'INSERT INTO cloud_storage_connections(site_id,id,current_revision,healthy,checked_at) SELECT ?,?,1,1,? WHERE (SELECT COUNT(*) FROM cloud_storage_connections WHERE site_id=? AND retired=0)<20',).bind(siteId, id, now, siteId),dbdiff --git a/tests/cloud-storage.test.ts b/tests/cloud-storage.test.tsindex 94339813..fd13890c 100644--- a/tests/cloud-storage.test.ts+++ b/tests/cloud-storage.test.ts@@ -245,6 +245,34 @@ test('Credential vault authenticates Site/revision, keeps old objects usable and.run(),/storage_connection_unavailable/,)+ await vault.create(+ 'replacement',+ publicConfig,+ { accessKeyId, secretAccessKey },+ 4,+ )+ assert.equal((await vault.list()).length, 21)+ assert.equal(+ (await vault.list()).filter((c) => c.uploads_enabled !== 0).length,+ 20,+ )+ assert.equal(+ await vault.rotate(+ 'storage',+ 2,+ { accessKeyId, secretAccessKey: 'replacement-read-secret' },+ 5,+ ),+ true,+ )+ assert.equal(+ (await vault.list()).find((c) => c.id === 'storage')?.uploads_enabled,+ 0,+ )+ assert.equal(+ (await vault.get('storage', 1))?.credentials.secretAccessKey,+ secretAccessKey,+ )} finally {await mf.dispose()}