Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSFWフラグの付いた画像と動画で年齢確認ダイアログを出す #245

Merged
merged 2 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_yojo.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Cherrypick 4.9.0
(Cherry-picked from https://github.com/1673beta/cherrypick/pull/73)
- Enhance: 絵文字のインポート時にリモートから取得した値で埋めた編集ダイアログを表示する
- Fix: メディアタイムラインの可視性を変更できない問題を修正 [#54](https://github.com/yojo-art/cherrypick/issues/54)
- Feat: NSFWフラグの付いた画像と動画で年齢確認ダイアログを出す [#245](https://github.com/yojo-art/cherrypick/pull/245)

### Server
-
Expand Down
10 changes: 10 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5489,6 +5489,16 @@ export interface Locale extends ILocale {
* マスコット画像のリンク
*/
"mascotImageUrl": string;
"_checkR18": {
/**
* 成人指定のメディアです
*/
"title": string;
/**
* あなたは18歳以上ですか?
*/
"description": string;
};
"_nsfwOpenBehavior": {
/**
* タップして開く
Expand Down
3 changes: 3 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,9 @@ _official_tag:
navbar: "公式タグ"
adminTopInfo: "優先度の値が小さいものが上に表示されます"
mascotImageUrl: "マスコット画像のリンク"
_checkR18:
title: "成人指定のメディアです"
description: "あなたは18歳以上ですか?"

_nsfwOpenBehavior:
click: "タップして開く"
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend/src/components/MkMediaImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { i18n } from '@/i18n.js';
import * as os from '@/os.js';
import { $i, iAmModerator } from '@/account.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { confirmR18 } from '@/scripts/check-r18.js';

const props = withDefaults(defineProps<{
image: Misskey.entities.DriveFile;
Expand Down Expand Up @@ -99,9 +100,10 @@ const clickToShowMessage = computed(() => defaultStore.state.nsfwOpenBehavior ==
: '',
);

function onClick(ev: MouseEvent) {
async function onClick(ev: MouseEvent) {
if (!props.controls) return;
if (!hide.value) return;
if (!await confirmR18()) return;
if (defaultStore.state.nsfwOpenBehavior === 'doubleClick') os.popup(MkRippleEffect, { x: ev.clientX, y: ev.clientY }, {}, 'end');
if (defaultStore.state.nsfwOpenBehavior === 'click') hide.value = false;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/components/MkMediaVideo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import hasAudio from '@/scripts/media-has-audio.js';
import MkMediaRange from '@/components/MkMediaRange.vue';
import { $i, iAmModerator } from '@/account.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { confirmR18 } from '@/scripts/check-r18.js';

const props = defineProps<{
video: Misskey.entities.DriveFile;
Expand Down Expand Up @@ -172,9 +173,9 @@ const clickToShowMessage = computed(() => defaultStore.state.nsfwOpenBehavior ==
: '',
);

function onClick(ev: MouseEvent) {
async function onClick(ev: MouseEvent) {
if (!hide.value) return;
else hide.value = false;
if (!await confirmR18()) return;
if (defaultStore.state.nsfwOpenBehavior === 'doubleClick') os.popup(MkRippleEffect, { x: ev.clientX, y: ev.clientY }, {}, 'end');
if (defaultStore.state.nsfwOpenBehavior === 'click') hide.value = false;
}
Expand Down
28 changes: 28 additions & 0 deletions packages/frontend/src/scripts/check-r18.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project, yojo-art team
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { i18n } from '@/i18n.js';
import * as os from '@/os.js';

export async function confirmR18() {
if (localStorage.getItem('checkR18') === 'true') {
//確認処理を済ませてる場合
return true;
} else {
const { canceled } = await os.confirm({
type: 'warning',
title: i18n.ts._checkR18.title,
text: i18n.ts._checkR18.description,
okText: i18n.ts.yes,
cancelText: i18n.ts.no,
});
if (canceled) {
//いいえ18歳未満です
return false;
}
//はい18禁コンテンツの閲覧を望みます
localStorage.setItem('checkR18', 'true');
return true;
}
}
4 changes: 4 additions & 0 deletions packages/frontend/src/scripts/import-emoji.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project, yojo-art team
* SPDX-License-Identifier: AGPL-3.0-only
*/
export async function importEmojiMeta(emoji, host:string) {
emoji.category = '取得失敗';
try {
Expand Down
Loading