Make frontend use value stored in storageSettings to decide whether to return thumbnails for S3 images

pull/5185/head
Florian Dewald 4 days ago
parent 2ed02b2340
commit 9666fb17a7

@ -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.

@ -247,6 +247,7 @@ export const initialWorkspaceStore = async (): Promise<void> => {
await Promise.all([
workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.GENERAL),
workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.MEMO_RELATED),
workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.STORAGE),
]);
// Apply settings to state

@ -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);
}

Loading…
Cancel
Save