diff --git a/proto/api/v1/instance_service.proto b/proto/api/v1/instance_service.proto index 418f4e1ce..ebe9ed2f1 100644 --- a/proto/api/v1/instance_service.proto +++ b/proto/api/v1/instance_service.proto @@ -157,10 +157,6 @@ message InstanceSetting { bool enable_double_click_edit = 4; // reactions is the list of reactions. repeated string reactions = 7; - // enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). - bool enable_blur_nsfw_content = 9; - // nsfw_tags is the list of tags that mark content as NSFW for blurring. - repeated string nsfw_tags = 10; } } diff --git a/proto/gen/api/v1/instance_service.pb.go b/proto/gen/api/v1/instance_service.pb.go index 0ce69d55b..c98eb3b88 100644 --- a/proto/gen/api/v1/instance_service.pb.go +++ b/proto/gen/api/v1/instance_service.pb.go @@ -654,11 +654,7 @@ type InstanceSetting_MemoRelatedSetting struct { // enable_double_click_edit enables editing on double click. EnableDoubleClickEdit bool `protobuf:"varint,4,opt,name=enable_double_click_edit,json=enableDoubleClickEdit,proto3" json:"enable_double_click_edit,omitempty"` // reactions is the list of reactions. - Reactions []string `protobuf:"bytes,7,rep,name=reactions,proto3" json:"reactions,omitempty"` - // enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). - EnableBlurNsfwContent bool `protobuf:"varint,9,opt,name=enable_blur_nsfw_content,json=enableBlurNsfwContent,proto3" json:"enable_blur_nsfw_content,omitempty"` - // nsfw_tags is the list of tags that mark content as NSFW for blurring. - NsfwTags []string `protobuf:"bytes,10,rep,name=nsfw_tags,json=nsfwTags,proto3" json:"nsfw_tags,omitempty"` + Reactions []string `protobuf:"bytes,7,rep,name=reactions,proto3" json:"reactions,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -728,20 +724,6 @@ func (x *InstanceSetting_MemoRelatedSetting) GetReactions() []string { return nil } -func (x *InstanceSetting_MemoRelatedSetting) GetEnableBlurNsfwContent() bool { - if x != nil { - return x.EnableBlurNsfwContent - } - return false -} - -func (x *InstanceSetting_MemoRelatedSetting) GetNsfwTags() []string { - if x != nil { - return x.NsfwTags - } - return nil -} - // Custom profile configuration for instance branding. type InstanceSetting_GeneralSetting_CustomProfile struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -899,7 +881,7 @@ const file_api_v1_instance_service_proto_rawDesc = "" + "\aversion\x18\x02 \x01(\tR\aversion\x12\x12\n" + "\x04mode\x18\x03 \x01(\tR\x04mode\x12!\n" + "\finstance_url\x18\x06 \x01(\tR\vinstanceUrl\"\x1b\n" + - "\x19GetInstanceProfileRequest\"\xef\x0f\n" + + "\x19GetInstanceProfileRequest\"\x99\x0f\n" + "\x0fInstanceSetting\x12\x17\n" + "\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12W\n" + "\x0fgeneral_setting\x18\x02 \x01(\v2,.memos.api.v1.InstanceSetting.GeneralSettingH\x00R\x0egeneralSetting\x12W\n" + @@ -934,16 +916,13 @@ const file_api_v1_instance_service_proto_rawDesc = "" + "\x18STORAGE_TYPE_UNSPECIFIED\x10\x00\x12\f\n" + "\bDATABASE\x10\x01\x12\t\n" + "\x05LOCAL\x10\x02\x12\x06\n" + - "\x02S3\x10\x03\x1a\xea\x02\n" + + "\x02S3\x10\x03\x1a\x94\x02\n" + "\x12MemoRelatedSetting\x12<\n" + "\x1adisallow_public_visibility\x18\x01 \x01(\bR\x18disallowPublicVisibility\x127\n" + "\x18display_with_update_time\x18\x02 \x01(\bR\x15displayWithUpdateTime\x120\n" + "\x14content_length_limit\x18\x03 \x01(\x05R\x12contentLengthLimit\x127\n" + "\x18enable_double_click_edit\x18\x04 \x01(\bR\x15enableDoubleClickEdit\x12\x1c\n" + - "\treactions\x18\a \x03(\tR\treactions\x127\n" + - "\x18enable_blur_nsfw_content\x18\t \x01(\bR\x15enableBlurNsfwContent\x12\x1b\n" + - "\tnsfw_tags\x18\n" + - " \x03(\tR\bnsfwTags\"F\n" + + "\treactions\x18\a \x03(\tR\treactions\"F\n" + "\x03Key\x12\x13\n" + "\x0fKEY_UNSPECIFIED\x10\x00\x12\v\n" + "\aGENERAL\x10\x01\x12\v\n" + diff --git a/proto/gen/openapi.yaml b/proto/gen/openapi.yaml index f4746dbd5..5f7d3fa38 100644 --- a/proto/gen/openapi.yaml +++ b/proto/gen/openapi.yaml @@ -2210,14 +2210,6 @@ components: items: type: string description: reactions is the list of reactions. - enableBlurNsfwContent: - type: boolean - description: enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). - nsfwTags: - type: array - items: - type: string - description: nsfw_tags is the list of tags that mark content as NSFW for blurring. description: Memo-related instance settings and policies. InstanceSetting_StorageSetting: type: object diff --git a/proto/gen/store/instance_setting.pb.go b/proto/gen/store/instance_setting.pb.go index d5dd3571b..d368e626d 100644 --- a/proto/gen/store/instance_setting.pb.go +++ b/proto/gen/store/instance_setting.pb.go @@ -650,11 +650,7 @@ type InstanceMemoRelatedSetting struct { // enable_double_click_edit enables editing on double click. EnableDoubleClickEdit bool `protobuf:"varint,4,opt,name=enable_double_click_edit,json=enableDoubleClickEdit,proto3" json:"enable_double_click_edit,omitempty"` // reactions is the list of reactions. - Reactions []string `protobuf:"bytes,7,rep,name=reactions,proto3" json:"reactions,omitempty"` - // enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). - EnableBlurNsfwContent bool `protobuf:"varint,9,opt,name=enable_blur_nsfw_content,json=enableBlurNsfwContent,proto3" json:"enable_blur_nsfw_content,omitempty"` - // nsfw_tags is the list of tags that mark content as NSFW for blurring. - NsfwTags []string `protobuf:"bytes,10,rep,name=nsfw_tags,json=nsfwTags,proto3" json:"nsfw_tags,omitempty"` + Reactions []string `protobuf:"bytes,7,rep,name=reactions,proto3" json:"reactions,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -724,20 +720,6 @@ func (x *InstanceMemoRelatedSetting) GetReactions() []string { return nil } -func (x *InstanceMemoRelatedSetting) GetEnableBlurNsfwContent() bool { - if x != nil { - return x.EnableBlurNsfwContent - } - return false -} - -func (x *InstanceMemoRelatedSetting) GetNsfwTags() []string { - if x != nil { - return x.NsfwTags - } - return nil -} - var File_store_instance_setting_proto protoreflect.FileDescriptor const file_store_instance_setting_proto_rawDesc = "" + @@ -783,16 +765,13 @@ const file_store_instance_setting_proto_rawDesc = "" + "\bendpoint\x18\x03 \x01(\tR\bendpoint\x12\x16\n" + "\x06region\x18\x04 \x01(\tR\x06region\x12\x16\n" + "\x06bucket\x18\x05 \x01(\tR\x06bucket\x12$\n" + - "\x0euse_path_style\x18\x06 \x01(\bR\fusePathStyle\"\xf2\x02\n" + + "\x0euse_path_style\x18\x06 \x01(\bR\fusePathStyle\"\x9c\x02\n" + "\x1aInstanceMemoRelatedSetting\x12<\n" + "\x1adisallow_public_visibility\x18\x01 \x01(\bR\x18disallowPublicVisibility\x127\n" + "\x18display_with_update_time\x18\x02 \x01(\bR\x15displayWithUpdateTime\x120\n" + "\x14content_length_limit\x18\x03 \x01(\x05R\x12contentLengthLimit\x127\n" + "\x18enable_double_click_edit\x18\x04 \x01(\bR\x15enableDoubleClickEdit\x12\x1c\n" + - "\treactions\x18\a \x03(\tR\treactions\x127\n" + - "\x18enable_blur_nsfw_content\x18\t \x01(\bR\x15enableBlurNsfwContent\x12\x1b\n" + - "\tnsfw_tags\x18\n" + - " \x03(\tR\bnsfwTags*q\n" + + "\treactions\x18\a \x03(\tR\treactions*q\n" + "\x12InstanceSettingKey\x12$\n" + " INSTANCE_SETTING_KEY_UNSPECIFIED\x10\x00\x12\t\n" + "\x05BASIC\x10\x01\x12\v\n" + diff --git a/proto/store/instance_setting.proto b/proto/store/instance_setting.proto index 6314731c7..fcfcbdd60 100644 --- a/proto/store/instance_setting.proto +++ b/proto/store/instance_setting.proto @@ -102,8 +102,4 @@ message InstanceMemoRelatedSetting { bool enable_double_click_edit = 4; // reactions is the list of reactions. repeated string reactions = 7; - // enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). - bool enable_blur_nsfw_content = 9; - // nsfw_tags is the list of tags that mark content as NSFW for blurring. - repeated string nsfw_tags = 10; } diff --git a/server/router/api/v1/instance_service.go b/server/router/api/v1/instance_service.go index 8636cbfd9..82830112e 100644 --- a/server/router/api/v1/instance_service.go +++ b/server/router/api/v1/instance_service.go @@ -251,8 +251,6 @@ func convertInstanceMemoRelatedSettingFromStore(setting *storepb.InstanceMemoRel ContentLengthLimit: setting.ContentLengthLimit, EnableDoubleClickEdit: setting.EnableDoubleClickEdit, Reactions: setting.Reactions, - EnableBlurNsfwContent: setting.EnableBlurNsfwContent, - NsfwTags: setting.NsfwTags, } } @@ -266,8 +264,6 @@ func convertInstanceMemoRelatedSettingToStore(setting *v1pb.InstanceSetting_Memo ContentLengthLimit: setting.ContentLengthLimit, EnableDoubleClickEdit: setting.EnableDoubleClickEdit, Reactions: setting.Reactions, - EnableBlurNsfwContent: setting.EnableBlurNsfwContent, - NsfwTags: setting.NsfwTags, } } diff --git a/store/instance_setting.go b/store/instance_setting.go index e57901a30..d64508159 100644 --- a/store/instance_setting.go +++ b/store/instance_setting.go @@ -143,9 +143,6 @@ const DefaultContentLengthLimit = 8 * 1024 // DefaultReactions is the default reactions for memo related setting. var DefaultReactions = []string{"👍", "👎", "❤️", "🎉", "😄", "😕", "😢", "😡"} -// DefaultNsfwTags is the default tags that mark content as NSFW for blurring. -var DefaultNsfwTags = []string{"nsfw"} - func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.InstanceMemoRelatedSetting, error) { instanceSetting, err := s.GetInstanceSetting(ctx, &FindInstanceSetting{ Name: storepb.InstanceSettingKey_MEMO_RELATED.String(), @@ -164,9 +161,6 @@ func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.Ins if len(instanceMemoRelatedSetting.Reactions) == 0 { instanceMemoRelatedSetting.Reactions = append(instanceMemoRelatedSetting.Reactions, DefaultReactions...) } - if len(instanceMemoRelatedSetting.NsfwTags) == 0 { - instanceMemoRelatedSetting.NsfwTags = append(instanceMemoRelatedSetting.NsfwTags, DefaultNsfwTags...) - } s.instanceSettingCache.Set(ctx, storepb.InstanceSettingKey_MEMO_RELATED.String(), &storepb.InstanceSetting{ Key: storepb.InstanceSettingKey_MEMO_RELATED, Value: &storepb.InstanceSetting_MemoRelatedSetting{MemoRelatedSetting: instanceMemoRelatedSetting}, diff --git a/web/src/components/MemoView/hooks/useNsfwContent.ts b/web/src/components/MemoView/hooks/useNsfwContent.ts index 2984c3def..dcdec618f 100644 --- a/web/src/components/MemoView/hooks/useNsfwContent.ts +++ b/web/src/components/MemoView/hooks/useNsfwContent.ts @@ -1,5 +1,4 @@ import { useState } from "react"; -import { useInstance } from "@/contexts/InstanceContext"; import type { Memo } from "@/types/proto/api/v1/memo_service_pb"; export interface UseNsfwContentReturn { @@ -10,14 +9,12 @@ export interface UseNsfwContentReturn { export const useNsfwContent = (memo: Memo, initialShowNsfw?: boolean): UseNsfwContentReturn => { const [showNSFWContent, setShowNSFWContent] = useState(initialShowNsfw ?? false); - const { memoRelatedSetting } = useInstance(); - const nsfw = - memoRelatedSetting.enableBlurNsfwContent && - memo.tags?.some((tag) => memoRelatedSetting.nsfwTags.some((nsfwTag) => tag === nsfwTag || tag.startsWith(`${nsfwTag}/`))); + // Always blur content tagged with NSFW + const nsfw = memo.tags?.includes("NSFW") ?? false; return { - nsfw: nsfw ?? false, + nsfw, showNSFWContent, toggleNsfwVisibility: () => setShowNSFWContent((prev) => !prev), }; diff --git a/web/src/components/Settings/MemoRelatedSettings.tsx b/web/src/components/Settings/MemoRelatedSettings.tsx index 199112c1c..d46ce652f 100644 --- a/web/src/components/Settings/MemoRelatedSettings.tsx +++ b/web/src/components/Settings/MemoRelatedSettings.tsx @@ -25,7 +25,6 @@ const MemoRelatedSettings = () => { const { memoRelatedSetting: originalSetting, updateSetting, fetchSetting } = useInstance(); const [memoRelatedSetting, setMemoRelatedSetting] = useState(originalSetting); const [editingReaction, setEditingReaction] = useState(""); - const [editingNsfwTag, setEditingNsfwTag] = useState(""); const updatePartialSetting = (partial: Partial) => { const newInstanceMemoRelatedSetting = create(InstanceSetting_MemoRelatedSettingSchema, { @@ -44,15 +43,6 @@ const MemoRelatedSettings = () => { setEditingReaction(""); }; - const upsertNsfwTags = () => { - if (!editingNsfwTag) { - return; - } - - updatePartialSetting({ nsfwTags: uniq([...memoRelatedSetting.nsfwTags, editingNsfwTag.trim()]) }); - setEditingNsfwTag(""); - }; - const handleUpdateSetting = async () => { if (memoRelatedSetting.reactions.length === 0) { toast.error("Reactions must not be empty."); @@ -140,44 +130,6 @@ const MemoRelatedSettings = () => { - - - updatePartialSetting({ enableBlurNsfwContent: checked })} - /> - - -
- NSFW Tags -
- {memoRelatedSetting.nsfwTags.map((nsfwTag) => ( - - {nsfwTag} - updatePartialSetting({ nsfwTags: memoRelatedSetting.nsfwTags.filter((r) => r !== nsfwTag) })} - > - - - - ))} -
- setEditingNsfwTag(event.target.value.trim())} - onKeyDown={(e) => e.key === "Enter" && upsertNsfwTags()} - /> - -
-
-
-
-