Skip to content

Commit

Permalink
feat: 投稿したコンテンツのAIによる学習を軽減するオプションを追加
Browse files Browse the repository at this point in the history
Resolve #10819
  • Loading branch information
syuilo committed May 10, 2023
1 parent baa4585 commit ae5a72a
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
-->

## 13.x.x (unreleased)

### General
- 投稿したコンテンツのAIによる学習を軽減するオプションを追加

### Client
-

### Server
-

## 13.12.1

### Client
Expand Down
2 changes: 2 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,8 @@ thisChannelArchived: "このチャンネルはアーカイブされています
displayOfNote: "ノートの表示"
initialAccountSetting: "初期設定"
youFollowing: "フォロー中"
preventAiLarning: "AIによる学習を防止"
preventAiLarningDescription: "投稿したノート、添付した画像などのコンテンツを学習の対象にしないようAIに要求します。これはnoaiフラグをHTMLレスポンスに含めることによって実現されます。"

_initialAccountSetting:
accountCreated: "アカウントの作成が完了しました!"
Expand Down
11 changes: 11 additions & 0 deletions packages/backend/migration/1683682889948-prevent-ai-larning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class PreventAiLarning1683682889948 {
name = 'PreventAiLarning1683682889948'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_profile" ADD "preventAiLarning" boolean NOT NULL DEFAULT true`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "preventAiLarning"`);
}
}
1 change: 1 addition & 0 deletions packages/backend/src/core/entities/UserEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ export class UserEntityService implements OnModuleInit {
carefulBot: profile!.carefulBot,
autoAcceptFollowed: profile!.autoAcceptFollowed,
noCrawle: profile!.noCrawle,
preventAiLarning: profile!.preventAiLarning,
isExplorable: user.isExplorable,
isDeleted: user.isDeleted,
hideOnlineStatus: user.hideOnlineStatus,
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/models/entities/UserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ export class UserProfile {
})
public noCrawle: boolean;

@Column('boolean', {
default: true,
})
public preventAiLarning: boolean;

@Column('boolean', {
default: false,
})
Expand Down
6 changes: 5 additions & 1 deletion packages/backend/src/models/json-schema/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ export const packedMeDetailedOnlySchema = {
},
noCrawle: {
type: 'boolean',
nullable: true, optional: false,
nullable: false, optional: false,
},
preventAiLarning: {
type: 'boolean',
nullable: false, optional: false,
},
isExplorable: {
type: 'boolean',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
emailVerified: profile.emailVerified,
autoAcceptFollowed: profile.autoAcceptFollowed,
noCrawle: profile.noCrawle,
preventAiLarning: profile.preventAiLarning,
alwaysMarkNsfw: profile.alwaysMarkNsfw,
autoSensitive: profile.autoSensitive,
carefulBot: profile.carefulBot,
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/src/server/api/endpoints/i/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const meta = {
message: 'This feature is restricted by your role.',
code: 'RESTRICTED_BY_ROLE',
id: '8feff0ba-5ab5-585b-31f4-4df816663fad',
}
},
},

res: {
Expand Down Expand Up @@ -138,6 +138,7 @@ export const paramDef = {
carefulBot: { type: 'boolean' },
autoAcceptFollowed: { type: 'boolean' },
noCrawle: { type: 'boolean' },
preventAiLarning: { type: 'boolean' },
isBot: { type: 'boolean' },
isCat: { type: 'boolean' },
showTimelineReplies: { type: 'boolean' },
Expand Down Expand Up @@ -242,6 +243,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (typeof ps.carefulBot === 'boolean') profileUpdates.carefulBot = ps.carefulBot;
if (typeof ps.autoAcceptFollowed === 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
if (typeof ps.noCrawle === 'boolean') profileUpdates.noCrawle = ps.noCrawle;
if (typeof ps.preventAiLarning === 'boolean') profileUpdates.preventAiLarning = ps.preventAiLarning;
if (typeof ps.isCat === 'boolean') updates.isCat = ps.isCat;
if (typeof ps.injectFeaturedNote === 'boolean') profileUpdates.injectFeaturedNote = ps.injectFeaturedNote;
if (typeof ps.receiveAnnouncementEmail === 'boolean') profileUpdates.receiveAnnouncementEmail = ps.receiveAnnouncementEmail;
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/web/views/clip.pug
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ block og
block meta
if profile.noCrawle
meta(name='robots' content='noindex')
if profile.preventAiLarning
meta(name='robots' content='noai')

meta(name='misskey:user-username' content=user.username)
meta(name='misskey:user-id' content=user.id)
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/web/views/flash.pug
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ block og
block meta
if profile.noCrawle
meta(name='robots' content='noindex')
if profile.preventAiLarning
meta(name='robots' content='noai')

meta(name='misskey:user-username' content=user.username)
meta(name='misskey:user-id' content=user.id)
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/web/views/gallery-post.pug
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ block og
block meta
if user.host || profile.noCrawle
meta(name='robots' content='noindex')
if profile.preventAiLarning
meta(name='robots' content='noai')

meta(name='misskey:user-username' content=user.username)
meta(name='misskey:user-id' content=user.id)
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/web/views/note.pug
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ block og
block meta
if user.host || isRenote || profile.noCrawle
meta(name='robots' content='noindex')
if profile.preventAiLarning
meta(name='robots' content='noai')

meta(name='misskey:user-username' content=user.username)
meta(name='misskey:user-id' content=user.id)
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/web/views/page.pug
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ block og
block meta
if profile.noCrawle
meta(name='robots' content='noindex')
if profile.preventAiLarning
meta(name='robots' content='noai')

meta(name='misskey:user-username' content=user.username)
meta(name='misskey:user-id' content=user.id)
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/web/views/user.pug
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ block og
block meta
if user.host || profile.noCrawle
meta(name='robots' content='noindex')
if profile.preventAiLarning
meta(name='robots' content='noai')

meta(name='misskey:user-username' content=user.username)
meta(name='misskey:user-id' content=user.id)
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/test/e2e/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ describe('ユーザー', () => {
carefulBot: user.carefulBot,
autoAcceptFollowed: user.autoAcceptFollowed,
noCrawle: user.noCrawle,
preventAiLarning: user.preventAiLarning,
isExplorable: user.isExplorable,
isDeleted: user.isDeleted,
hideOnlineStatus: user.hideOnlineStatus,
Expand Down Expand Up @@ -390,6 +391,7 @@ describe('ユーザー', () => {
assert.strictEqual(response.carefulBot, false);
assert.strictEqual(response.autoAcceptFollowed, true);
assert.strictEqual(response.noCrawle, false);
assert.strictEqual(response.preventAiLarning, true);
assert.strictEqual(response.isExplorable, true);
assert.strictEqual(response.isDeleted, false);
assert.strictEqual(response.hideOnlineStatus, false);
Expand Down Expand Up @@ -462,6 +464,8 @@ describe('ユーザー', () => {
{ parameters: (): object => ({ autoAcceptFollowed: false }) },
{ parameters: (): object => ({ noCrawle: true }) },
{ parameters: (): object => ({ noCrawle: false }) },
{ parameters: (): object => ({ preventAiLarning: false }) },
{ parameters: (): object => ({ preventAiLarning: true }) },
{ parameters: (): object => ({ isBot: true }) },
{ parameters: (): object => ({ isBot: false }) },
{ parameters: (): object => ({ isCat: true }) },
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/pages/settings/privacy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
{{ i18n.ts.noCrawle }}
<template #caption>{{ i18n.ts.noCrawleDescription }}</template>
</MkSwitch>
<MkSwitch v-model="preventAiLarning" @update:model-value="save()">
{{ i18n.ts.preventAiLarning }}<span class="_beta">{{ i18n.ts.beta }}</span>
<template #caption>{{ i18n.ts.preventAiLarningDescription }}</template>
</MkSwitch>
<MkSwitch v-model="isExplorable" @update:model-value="save()">
{{ i18n.ts.makeExplorable }}
<template #caption>{{ i18n.ts.makeExplorableDescription }}</template>
Expand Down Expand Up @@ -71,6 +75,7 @@ import { definePageMetadata } from '@/scripts/page-metadata';
let isLocked = $ref($i.isLocked);
let autoAcceptFollowed = $ref($i.autoAcceptFollowed);
let noCrawle = $ref($i.noCrawle);
let preventAiLarning = $ref($i.preventAiLarning);
let isExplorable = $ref($i.isExplorable);
let hideOnlineStatus = $ref($i.hideOnlineStatus);
let publicReactions = $ref($i.publicReactions);
Expand All @@ -86,6 +91,7 @@ function save() {
isLocked: !!isLocked,
autoAcceptFollowed: !!autoAcceptFollowed,
noCrawle: !!noCrawle,
preventAiLarning: !!preventAiLarning,
isExplorable: !!isExplorable,
hideOnlineStatus: !!hideOnlineStatus,
publicReactions: !!publicReactions,
Expand Down

0 comments on commit ae5a72a

Please sign in to comment.