feat: isIndexable

This commit is contained in:
Mar0xy 2023-11-07 19:16:57 +01:00
parent 53f2089116
commit 9cd2759769
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
15 changed files with 48 additions and 4 deletions

View file

@ -745,6 +745,8 @@ thisIsExperimentalFeature: "This is an experimental feature. Its functionality i
developer: "Developer" developer: "Developer"
makeExplorable: "Make account visible in \"Explore\"" makeExplorable: "Make account visible in \"Explore\""
makeExplorableDescription: "If you turn this off, your account will not show up in the \"Explore\" section." makeExplorableDescription: "If you turn this off, your account will not show up in the \"Explore\" section."
makeIndexable: "Make public notes indexable"
makeIndexableDescription: "Allow note search to index your public notes."
showGapBetweenNotesInTimeline: "Show a gap between posts on the timeline" showGapBetweenNotesInTimeline: "Show a gap between posts on the timeline"
duplicate: "Duplicate" duplicate: "Duplicate"
left: "Left" left: "Left"

2
locales/index.d.ts vendored
View file

@ -748,6 +748,8 @@ export interface Locale {
"developer": string; "developer": string;
"makeExplorable": string; "makeExplorable": string;
"makeExplorableDescription": string; "makeExplorableDescription": string;
"makeIndexable": string;
"makeIndexableDescription": string;
"showGapBetweenNotesInTimeline": string; "showGapBetweenNotesInTimeline": string;
"duplicate": string; "duplicate": string;
"left": string; "left": string;

View file

@ -745,6 +745,8 @@ thisIsExperimentalFeature: "これは実験的な機能です。仕様が変更
developer: "開発者" developer: "開発者"
makeExplorable: "アカウントを見つけやすくする" makeExplorable: "アカウントを見つけやすくする"
makeExplorableDescription: "オフにすると、「みつける」にアカウントが載らなくなります。" makeExplorableDescription: "オフにすると、「みつける」にアカウントが載らなくなります。"
makeIndexable: "公開ノートをインデックス化"
makeIndexableDescription: "ノート検索で公開ノートにインデックスを付けられるようにする。"
showGapBetweenNotesInTimeline: "タイムラインのノートを離して表示" showGapBetweenNotesInTimeline: "タイムラインのノートを離して表示"
duplicate: "複製" duplicate: "複製"
left: "左" left: "左"

View file

@ -0,0 +1,11 @@
export class IsIndexable1699376974000 {
name = 'IsIndexable1699376974000'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "user" ADD "isIndexable" boolean NOT NULL DEFAULT true`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "isIndexable"`);
}
}

View file

@ -223,8 +223,7 @@ export class NoteCreateService implements OnApplicationShutdown {
username: MiUser['username']; username: MiUser['username'];
host: MiUser['host']; host: MiUser['host'];
isBot: MiUser['isBot']; isBot: MiUser['isBot'];
isCat: MiUser['isCat']; isIndexable: MiUser['isIndexable'];
speakAsCat: MiUser['speakAsCat'];
}, data: Option, silent = false): Promise<MiNote> { }, data: Option, silent = false): Promise<MiNote> {
// チャンネル外にリプライしたら対象のスコープに合わせる // チャンネル外にリプライしたら対象のスコープに合わせる
// (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで) // (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで)
@ -482,6 +481,7 @@ export class NoteCreateService implements OnApplicationShutdown {
username: MiUser['username']; username: MiUser['username'];
host: MiUser['host']; host: MiUser['host'];
isBot: MiUser['isBot']; isBot: MiUser['isBot'];
isIndexable: MiUser['isIndexable'];
}, data: Option, silent: boolean, tags: string[], mentionedUsers: MinimumUser[]) { }, data: Option, silent: boolean, tags: string[], mentionedUsers: MinimumUser[]) {
const meta = await this.metaService.fetch(); const meta = await this.metaService.fetch();
@ -712,7 +712,7 @@ export class NoteCreateService implements OnApplicationShutdown {
} }
// Register to search database // Register to search database
this.index(note); if (user.isIndexable) this.index(note);
} }
@bindThis @bindThis

View file

@ -224,6 +224,7 @@ export class NoteEditService implements OnApplicationShutdown {
username: MiUser['username']; username: MiUser['username'];
host: MiUser['host']; host: MiUser['host'];
isBot: MiUser['isBot']; isBot: MiUser['isBot'];
isIndexable: MiUser['isIndexable'];
}, editid: MiNote['id'], data: Option, silent = false): Promise<MiNote> { }, editid: MiNote['id'], data: Option, silent = false): Promise<MiNote> {
if (!editid) { if (!editid) {
throw new Error('fail'); throw new Error('fail');
@ -498,6 +499,7 @@ export class NoteEditService implements OnApplicationShutdown {
username: MiUser['username']; username: MiUser['username'];
host: MiUser['host']; host: MiUser['host'];
isBot: MiUser['isBot']; isBot: MiUser['isBot'];
isIndexable: MiUser['isIndexable'];
}, data: Option, silent: boolean, tags: string[], mentionedUsers: MinimumUser[]) { }, data: Option, silent: boolean, tags: string[], mentionedUsers: MinimumUser[]) {
// Register host // Register host
if (this.userEntityService.isRemoteUser(user)) { if (this.userEntityService.isRemoteUser(user)) {
@ -686,7 +688,7 @@ export class NoteEditService implements OnApplicationShutdown {
} }
// Register to search database // Register to search database
this.index(note); if (user.isIndexable) this.index(note);
} }
@bindThis @bindThis

View file

@ -506,6 +506,7 @@ export class ApRendererService {
discoverable: user.isExplorable, discoverable: user.isExplorable,
publicKey: this.renderKey(user, keypair, '#main-key'), publicKey: this.renderKey(user, keypair, '#main-key'),
isCat: user.isCat, isCat: user.isCat,
isIndexable: user.isIndexable,
speakAsCat: user.speakAsCat, speakAsCat: user.speakAsCat,
attachment: attachment.length ? attachment : undefined, attachment: attachment.length ? attachment : undefined,
}; };

View file

@ -310,6 +310,7 @@ export class ApPersonService implements OnModuleInit {
backgroundId: null, backgroundId: null,
lastFetchedAt: new Date(), lastFetchedAt: new Date(),
name: truncate(person.name, nameLength), name: truncate(person.name, nameLength),
isIndexable: person.isIndexable ?? true,
isLocked: person.manuallyApprovesFollowers, isLocked: person.manuallyApprovesFollowers,
movedToUri: person.movedTo, movedToUri: person.movedTo,
movedAt: person.movedTo ? new Date() : null, movedAt: person.movedTo ? new Date() : null,
@ -476,6 +477,7 @@ export class ApPersonService implements OnModuleInit {
isBot: getApType(object) === 'Service' || getApType(object) === 'Application', isBot: getApType(object) === 'Service' || getApType(object) === 'Application',
isCat: (person as any).isCat === true, isCat: (person as any).isCat === true,
speakAsCat: (person as any).speakAsCat != null ? (person as any).speakAsCat === true : (person as any).isCat === true, speakAsCat: (person as any).speakAsCat != null ? (person as any).speakAsCat === true : (person as any).isCat === true,
isIndexable: person.isIndexable ?? true,
isLocked: person.manuallyApprovesFollowers, isLocked: person.manuallyApprovesFollowers,
movedToUri: person.movedTo ?? null, movedToUri: person.movedTo ?? null,
alsoKnownAs: person.alsoKnownAs ?? null, alsoKnownAs: person.alsoKnownAs ?? null,

View file

@ -184,6 +184,7 @@ export interface IActor extends IObject {
}; };
'vcard:bday'?: string; 'vcard:bday'?: string;
'vcard:Address'?: string; 'vcard:Address'?: string;
isIndexable?: boolean;
listenbrainz?: string; listenbrainz?: string;
backgroundUrl?: string; backgroundUrl?: string;
} }

View file

@ -399,6 +399,7 @@ export class UserEntityService implements OnModuleInit {
}))) : [], }))) : [],
isBot: user.isBot, isBot: user.isBot,
isCat: user.isCat, isCat: user.isCat,
isIndexable: user.isIndexable,
isSilenced: user.isSilenced || this.roleService.getUserPolicies(user.id).then(r => !r.canPublicNote), isSilenced: user.isSilenced || this.roleService.getUserPolicies(user.id).then(r => !r.canPublicNote),
speakAsCat: user.speakAsCat ?? false, speakAsCat: user.speakAsCat ?? false,
approved: user.approved, approved: user.approved,

View file

@ -188,6 +188,12 @@ export class MiUser {
}) })
public isSilenced: boolean; public isSilenced: boolean;
@Column('boolean', {
default: true,
comment: 'Whether the User\'s notes get indexed.',
})
public isIndexable: boolean;
@Column('boolean', { @Column('boolean', {
default: false, default: false,
comment: 'Whether the User is locked.', comment: 'Whether the User is locked.',

View file

@ -79,6 +79,10 @@ export const packedUserLiteSchema = {
type: 'boolean', type: 'boolean',
nullable: false, optional: false, nullable: false, optional: false,
}, },
isIndexable: {
type: 'boolean',
nullable: false, optional: false,
},
isBot: { isBot: {
type: 'boolean', type: 'boolean',
nullable: false, optional: true, nullable: false, optional: true,

View file

@ -177,6 +177,7 @@ export const paramDef = {
autoAcceptFollowed: { type: 'boolean' }, autoAcceptFollowed: { type: 'boolean' },
noCrawle: { type: 'boolean' }, noCrawle: { type: 'boolean' },
preventAiLearning: { type: 'boolean' }, preventAiLearning: { type: 'boolean' },
isIndexable: { type: 'boolean' },
isBot: { type: 'boolean' }, isBot: { type: 'boolean' },
isCat: { type: 'boolean' }, isCat: { type: 'boolean' },
speakAsCat: { type: 'boolean' }, speakAsCat: { type: 'boolean' },
@ -278,6 +279,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (typeof ps.isExplorable === 'boolean') updates.isExplorable = ps.isExplorable; if (typeof ps.isExplorable === 'boolean') updates.isExplorable = ps.isExplorable;
if (typeof ps.hideOnlineStatus === 'boolean') updates.hideOnlineStatus = ps.hideOnlineStatus; if (typeof ps.hideOnlineStatus === 'boolean') updates.hideOnlineStatus = ps.hideOnlineStatus;
if (typeof ps.publicReactions === 'boolean') profileUpdates.publicReactions = ps.publicReactions; if (typeof ps.publicReactions === 'boolean') profileUpdates.publicReactions = ps.publicReactions;
if (typeof ps.isIndexable === 'boolean') updates.isIndexable = ps.isIndexable;
if (typeof ps.isBot === 'boolean') updates.isBot = ps.isBot; if (typeof ps.isBot === 'boolean') updates.isBot = ps.isBot;
if (typeof ps.carefulBot === 'boolean') profileUpdates.carefulBot = ps.carefulBot; if (typeof ps.carefulBot === 'boolean') profileUpdates.carefulBot = ps.carefulBot;
if (typeof ps.autoAcceptFollowed === 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed; if (typeof ps.autoAcceptFollowed === 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;

View file

@ -33,6 +33,10 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.preventAiLearning }}<span class="_beta">{{ i18n.ts.beta }}</span> {{ i18n.ts.preventAiLearning }}<span class="_beta">{{ i18n.ts.beta }}</span>
<template #caption>{{ i18n.ts.preventAiLearningDescription }}</template> <template #caption>{{ i18n.ts.preventAiLearningDescription }}</template>
</MkSwitch> </MkSwitch>
<MkSwitch v-model="isIndexable" @update:modelValue="save()">
{{ i18n.ts.makeIndexable }}
<template #caption>{{ i18n.ts.makeIndexableDescription }}</template>
</MkSwitch>
<MkSwitch v-model="isExplorable" @update:modelValue="save()"> <MkSwitch v-model="isExplorable" @update:modelValue="save()">
{{ i18n.ts.makeExplorable }} {{ i18n.ts.makeExplorable }}
<template #caption>{{ i18n.ts.makeExplorableDescription }}</template> <template #caption>{{ i18n.ts.makeExplorableDescription }}</template>
@ -82,6 +86,7 @@ let autoAcceptFollowed = $ref($i.autoAcceptFollowed);
let noCrawle = $ref($i.noCrawle); let noCrawle = $ref($i.noCrawle);
let preventAiLearning = $ref($i.preventAiLearning); let preventAiLearning = $ref($i.preventAiLearning);
let isExplorable = $ref($i.isExplorable); let isExplorable = $ref($i.isExplorable);
let isIndexable = $ref($i.isIndexable);
let hideOnlineStatus = $ref($i.hideOnlineStatus); let hideOnlineStatus = $ref($i.hideOnlineStatus);
let publicReactions = $ref($i.publicReactions); let publicReactions = $ref($i.publicReactions);
let ffVisibility = $ref($i.ffVisibility); let ffVisibility = $ref($i.ffVisibility);
@ -98,6 +103,7 @@ function save() {
noCrawle: !!noCrawle, noCrawle: !!noCrawle,
preventAiLearning: !!preventAiLearning, preventAiLearning: !!preventAiLearning,
isExplorable: !!isExplorable, isExplorable: !!isExplorable,
isIndexable: !!isIndexable,
hideOnlineStatus: !!hideOnlineStatus, hideOnlineStatus: !!hideOnlineStatus,
publicReactions: !!publicReactions, publicReactions: !!publicReactions,
ffVisibility: ffVisibility, ffVisibility: ffVisibility,

View file

@ -37,6 +37,7 @@ export type UserLite = {
}; };
isCat?: boolean; isCat?: boolean;
isBot?: boolean; isBot?: boolean;
isIndexable?: boolean;
}; };
export type UserDetailed = UserLite & { export type UserDetailed = UserLite & {
@ -65,6 +66,7 @@ export type UserDetailed = UserLite & {
speakAsCat: boolean; speakAsCat: boolean;
isFollowed: boolean; isFollowed: boolean;
isFollowing: boolean; isFollowing: boolean;
isIndexable: boolean;
isLocked: boolean; isLocked: boolean;
isModerator: boolean; isModerator: boolean;
isMuted: boolean; isMuted: boolean;