Skip to content

Commit 5d67782

Browse files
committed
refactor: remove NSFW content settings from instance configuration
1 parent 96a91eb commit 5d67782

File tree

10 files changed

+11
-144
lines changed

10 files changed

+11
-144
lines changed

proto/api/v1/instance_service.proto

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ message InstanceSetting {
157157
bool enable_double_click_edit = 4;
158158
// reactions is the list of reactions.
159159
repeated string reactions = 7;
160-
// enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW).
161-
bool enable_blur_nsfw_content = 9;
162-
// nsfw_tags is the list of tags that mark content as NSFW for blurring.
163-
repeated string nsfw_tags = 10;
164160
}
165161
}
166162

proto/gen/api/v1/instance_service.pb.go

Lines changed: 4 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/openapi.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,14 +2210,6 @@ components:
22102210
items:
22112211
type: string
22122212
description: reactions is the list of reactions.
2213-
enableBlurNsfwContent:
2214-
type: boolean
2215-
description: enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW).
2216-
nsfwTags:
2217-
type: array
2218-
items:
2219-
type: string
2220-
description: nsfw_tags is the list of tags that mark content as NSFW for blurring.
22212213
description: Memo-related instance settings and policies.
22222214
InstanceSetting_StorageSetting:
22232215
type: object

proto/gen/store/instance_setting.pb.go

Lines changed: 3 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/store/instance_setting.proto

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,4 @@ message InstanceMemoRelatedSetting {
102102
bool enable_double_click_edit = 4;
103103
// reactions is the list of reactions.
104104
repeated string reactions = 7;
105-
// enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW).
106-
bool enable_blur_nsfw_content = 9;
107-
// nsfw_tags is the list of tags that mark content as NSFW for blurring.
108-
repeated string nsfw_tags = 10;
109105
}

server/router/api/v1/instance_service.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ func convertInstanceMemoRelatedSettingFromStore(setting *storepb.InstanceMemoRel
251251
ContentLengthLimit: setting.ContentLengthLimit,
252252
EnableDoubleClickEdit: setting.EnableDoubleClickEdit,
253253
Reactions: setting.Reactions,
254-
EnableBlurNsfwContent: setting.EnableBlurNsfwContent,
255-
NsfwTags: setting.NsfwTags,
256254
}
257255
}
258256

@@ -266,8 +264,6 @@ func convertInstanceMemoRelatedSettingToStore(setting *v1pb.InstanceSetting_Memo
266264
ContentLengthLimit: setting.ContentLengthLimit,
267265
EnableDoubleClickEdit: setting.EnableDoubleClickEdit,
268266
Reactions: setting.Reactions,
269-
EnableBlurNsfwContent: setting.EnableBlurNsfwContent,
270-
NsfwTags: setting.NsfwTags,
271267
}
272268
}
273269

store/instance_setting.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ const DefaultContentLengthLimit = 8 * 1024
143143
// DefaultReactions is the default reactions for memo related setting.
144144
var DefaultReactions = []string{"👍", "👎", "❤️", "🎉", "😄", "😕", "😢", "😡"}
145145

146-
// DefaultNsfwTags is the default tags that mark content as NSFW for blurring.
147-
var DefaultNsfwTags = []string{"nsfw"}
148-
149146
func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.InstanceMemoRelatedSetting, error) {
150147
instanceSetting, err := s.GetInstanceSetting(ctx, &FindInstanceSetting{
151148
Name: storepb.InstanceSettingKey_MEMO_RELATED.String(),
@@ -164,9 +161,6 @@ func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.Ins
164161
if len(instanceMemoRelatedSetting.Reactions) == 0 {
165162
instanceMemoRelatedSetting.Reactions = append(instanceMemoRelatedSetting.Reactions, DefaultReactions...)
166163
}
167-
if len(instanceMemoRelatedSetting.NsfwTags) == 0 {
168-
instanceMemoRelatedSetting.NsfwTags = append(instanceMemoRelatedSetting.NsfwTags, DefaultNsfwTags...)
169-
}
170164
s.instanceSettingCache.Set(ctx, storepb.InstanceSettingKey_MEMO_RELATED.String(), &storepb.InstanceSetting{
171165
Key: storepb.InstanceSettingKey_MEMO_RELATED,
172166
Value: &storepb.InstanceSetting_MemoRelatedSetting{MemoRelatedSetting: instanceMemoRelatedSetting},

web/src/components/MemoView/hooks/useNsfwContent.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useState } from "react";
2-
import { useInstance } from "@/contexts/InstanceContext";
32
import type { Memo } from "@/types/proto/api/v1/memo_service_pb";
43

54
export interface UseNsfwContentReturn {
@@ -10,14 +9,12 @@ export interface UseNsfwContentReturn {
109

1110
export const useNsfwContent = (memo: Memo, initialShowNsfw?: boolean): UseNsfwContentReturn => {
1211
const [showNSFWContent, setShowNSFWContent] = useState(initialShowNsfw ?? false);
13-
const { memoRelatedSetting } = useInstance();
1412

15-
const nsfw =
16-
memoRelatedSetting.enableBlurNsfwContent &&
17-
memo.tags?.some((tag) => memoRelatedSetting.nsfwTags.some((nsfwTag) => tag === nsfwTag || tag.startsWith(`${nsfwTag}/`)));
13+
// Always blur content tagged with NSFW
14+
const nsfw = memo.tags?.includes("NSFW") ?? false;
1815

1916
return {
20-
nsfw: nsfw ?? false,
17+
nsfw,
2118
showNSFWContent,
2219
toggleNsfwVisibility: () => setShowNSFWContent((prev) => !prev),
2320
};

web/src/components/Settings/MemoRelatedSettings.tsx

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const MemoRelatedSettings = () => {
2525
const { memoRelatedSetting: originalSetting, updateSetting, fetchSetting } = useInstance();
2626
const [memoRelatedSetting, setMemoRelatedSetting] = useState<InstanceSetting_MemoRelatedSetting>(originalSetting);
2727
const [editingReaction, setEditingReaction] = useState<string>("");
28-
const [editingNsfwTag, setEditingNsfwTag] = useState<string>("");
2928

3029
const updatePartialSetting = (partial: Partial<InstanceSetting_MemoRelatedSetting>) => {
3130
const newInstanceMemoRelatedSetting = create(InstanceSetting_MemoRelatedSettingSchema, {
@@ -44,15 +43,6 @@ const MemoRelatedSettings = () => {
4443
setEditingReaction("");
4544
};
4645

47-
const upsertNsfwTags = () => {
48-
if (!editingNsfwTag) {
49-
return;
50-
}
51-
52-
updatePartialSetting({ nsfwTags: uniq([...memoRelatedSetting.nsfwTags, editingNsfwTag.trim()]) });
53-
setEditingNsfwTag("");
54-
};
55-
5646
const handleUpdateSetting = async () => {
5747
if (memoRelatedSetting.reactions.length === 0) {
5848
toast.error("Reactions must not be empty.");
@@ -140,44 +130,6 @@ const MemoRelatedSettings = () => {
140130
</div>
141131
</SettingGroup>
142132

143-
<SettingGroup showSeparator>
144-
<SettingRow label={t("setting.memo-related-settings.enable-blur-nsfw-content")}>
145-
<Switch
146-
checked={memoRelatedSetting.enableBlurNsfwContent}
147-
onCheckedChange={(checked) => updatePartialSetting({ enableBlurNsfwContent: checked })}
148-
/>
149-
</SettingRow>
150-
151-
<div className="w-full flex flex-col gap-2">
152-
<span className="text-sm text-muted-foreground">NSFW Tags</span>
153-
<div className="w-full flex flex-row flex-wrap gap-2">
154-
{memoRelatedSetting.nsfwTags.map((nsfwTag) => (
155-
<Badge key={nsfwTag} variant="outline" className="flex items-center gap-1.5 h-8 px-3">
156-
{nsfwTag}
157-
<span
158-
className="cursor-pointer text-muted-foreground hover:text-destructive"
159-
onClick={() => updatePartialSetting({ nsfwTags: memoRelatedSetting.nsfwTags.filter((r) => r !== nsfwTag) })}
160-
>
161-
<X className="w-3.5 h-3.5" />
162-
</span>
163-
</Badge>
164-
))}
165-
<div className="flex items-center gap-1.5">
166-
<Input
167-
className="w-32 h-8"
168-
placeholder={t("common.input")}
169-
value={editingNsfwTag}
170-
onChange={(event) => setEditingNsfwTag(event.target.value.trim())}
171-
onKeyDown={(e) => e.key === "Enter" && upsertNsfwTags()}
172-
/>
173-
<Button variant="ghost" size="sm" onClick={upsertNsfwTags} className="h-8 w-8 p-0">
174-
<CheckIcon className="w-4 h-4" />
175-
</Button>
176-
</div>
177-
</div>
178-
</div>
179-
</SettingGroup>
180-
181133
<div className="w-full flex justify-end">
182134
<Button disabled={isEqual(memoRelatedSetting, originalSetting)} onClick={handleUpdateSetting}>
183135
{t("common.save")}

0 commit comments

Comments
 (0)