From 9666fb17a7f76229c1ae04b001b5853180bd32d5 Mon Sep 17 00:00:00 2001 From: Florian Dewald Date: Thu, 30 Oct 2025 20:55:12 +0100 Subject: [PATCH] Make frontend use value stored in storageSettings to decide whether to return thumbnails for S3 images --- server/router/api/v1/workspace_service.go | 5 +---- web/src/store/workspace.ts | 1 + web/src/utils/attachment.ts | 7 ++++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/router/api/v1/workspace_service.go b/server/router/api/v1/workspace_service.go index 4dcca20a1..69e952797 100644 --- a/server/router/api/v1/workspace_service.go +++ b/server/router/api/v1/workspace_service.go @@ -70,12 +70,9 @@ func (s *APIV1Service) GetWorkspaceSetting(ctx context.Context, request *v1pb.Ge if err != nil { return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err) } - if user == nil { - return nil, status.Errorf(codes.PermissionDenied, "permission denied") - } // Host can see everything, regular users only see enable_s3_image_thumbnails. - if user.Role != store.RoleHost { + if user == nil || user.Role != store.RoleHost { // Convert and filter for non-host users. convertedSetting := convertWorkspaceStorageSettingFromStore(workspaceSetting.GetStorageSetting()) // Clear sensitive fields. diff --git a/web/src/store/workspace.ts b/web/src/store/workspace.ts index e53c3241b..8c7581fe2 100644 --- a/web/src/store/workspace.ts +++ b/web/src/store/workspace.ts @@ -247,6 +247,7 @@ export const initialWorkspaceStore = async (): Promise => { await Promise.all([ workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.GENERAL), workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.MEMO_RELATED), + workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.STORAGE), ]); // Apply settings to state diff --git a/web/src/utils/attachment.ts b/web/src/utils/attachment.ts index 088e04fe5..9b2e9d4fc 100644 --- a/web/src/utils/attachment.ts +++ b/web/src/utils/attachment.ts @@ -1,4 +1,6 @@ +import workspaceStore from "@/store/workspace"; import { Attachment } from "@/types/proto/api/v1/attachment_service"; +import { WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service"; export const getAttachmentUrl = (attachment: Attachment) => { if (attachment.externalLink) { @@ -10,7 +12,10 @@ export const getAttachmentUrl = (attachment: Attachment) => { export const getAttachmentThumbnailUrl = (attachment: Attachment) => { // Don't request thumbnails for S3 images if the setting is disabled - if (attachment.externalLink && !attachment.useThumbnailForS3Image) { + if ( + attachment.externalLink && + !(workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE).storageSetting?.enableS3ImageThumbnails ?? false) + ) { return getAttachmentUrl(attachment); }