mirror of
https://github.com/usememos/memos.git
synced 2025-12-17 22:28:52 +08:00
Make frontend use value stored in storageSettings to decide whether to return thumbnails for S3 images
This commit is contained in:
parent
2ed02b2340
commit
9666fb17a7
3 changed files with 8 additions and 5 deletions
|
|
@ -70,12 +70,9 @@ func (s *APIV1Service) GetWorkspaceSetting(ctx context.Context, request *v1pb.Ge
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
|
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.
|
// 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.
|
// Convert and filter for non-host users.
|
||||||
convertedSetting := convertWorkspaceStorageSettingFromStore(workspaceSetting.GetStorageSetting())
|
convertedSetting := convertWorkspaceStorageSettingFromStore(workspaceSetting.GetStorageSetting())
|
||||||
// Clear sensitive fields.
|
// Clear sensitive fields.
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,7 @@ export const initialWorkspaceStore = async (): Promise<void> => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.GENERAL),
|
workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.GENERAL),
|
||||||
workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.MEMO_RELATED),
|
workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.MEMO_RELATED),
|
||||||
|
workspaceStore.fetchWorkspaceSetting(WorkspaceSetting_Key.STORAGE),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Apply settings to state
|
// Apply settings to state
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
import workspaceStore from "@/store/workspace";
|
||||||
import { Attachment } from "@/types/proto/api/v1/attachment_service";
|
import { Attachment } from "@/types/proto/api/v1/attachment_service";
|
||||||
|
import { WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
|
||||||
|
|
||||||
export const getAttachmentUrl = (attachment: Attachment) => {
|
export const getAttachmentUrl = (attachment: Attachment) => {
|
||||||
if (attachment.externalLink) {
|
if (attachment.externalLink) {
|
||||||
|
|
@ -10,7 +12,10 @@ export const getAttachmentUrl = (attachment: Attachment) => {
|
||||||
|
|
||||||
export const getAttachmentThumbnailUrl = (attachment: Attachment) => {
|
export const getAttachmentThumbnailUrl = (attachment: Attachment) => {
|
||||||
// Don't request thumbnails for S3 images if the setting is disabled
|
// 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);
|
return getAttachmentUrl(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue