Skip to content

Commit

Permalink
indexable (#2484)
Browse files Browse the repository at this point in the history
* indexable

* toot:indexable
  • Loading branch information
mei23 authored and fs5m8 committed Nov 28, 2023
1 parent 00f1864 commit fd0b903
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ common/views/components/profile-editor.vue:
auto-accept-followed: "Automatically approve follows from the people you follow"
avoid-search-index: "Avoid search engine index"
is-explorable: "Make account visible in \"Explore\""
isIndexable: "Allow post search"
advanced: "Other"
privacy: "Privacy"
save: "Save"
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ common/views/components/profile-editor.vue:
auto-accept-followed: "フォローしているユーザーからのフォローを自動承認する"
avoid-search-index: "検索エンジンによるインデックスを拒否する"
is-explorable: "アカウントを見つけやすくする"
isIndexable: "投稿検索を許可する"
advanced: "その他"
privacy: "プライバシー"
save: "保存"
Expand Down
16 changes: 16 additions & 0 deletions migration/1695595746908-isIndexable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class isIndexable1695595746908 implements MigrationInterface {
name = 'isIndexable1695595746908'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user" ADD "isIndexable" boolean NOT NULL DEFAULT true`);
await queryRunner.query(`COMMENT ON COLUMN "user"."isIndexable" IS 'Search indexable.'`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`COMMENT ON COLUMN "user"."isIndexable" IS 'Search indexable.'`);
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "isIndexable"`);
}

}
4 changes: 4 additions & 0 deletions src/client/app/common/views/components/settings/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<ui-switch v-model="autoAcceptFollowed" :disabled="!isLocked && !carefulBot && !carefulRemote" @change="save(false)">{{ $t('auto-accept-followed') }}</ui-switch>
<ui-switch v-model="avoidSearchIndex" @change="save(false)">{{ $t('avoid-search-index') }}</ui-switch>
<ui-switch v-model="isExplorable" @change="save(false)">{{ $t('is-explorable') }}</ui-switch>
<ui-switch v-model="isIndexable" @change="save(false)">{{ $t('isIndexable') }}</ui-switch>
</div>
</section>

Expand Down Expand Up @@ -188,6 +189,7 @@ export default Vue.extend({
autoAcceptFollowed: false,
avoidSearchIndex: false,
isExplorable: false,
isIndexable: true,
saving: false,
avatarUploading: false,
bannerUploading: false,
Expand Down Expand Up @@ -232,6 +234,7 @@ export default Vue.extend({
this.autoAcceptFollowed = this.$store.state.i.autoAcceptFollowed;
this.avoidSearchIndex = this.$store.state.i.avoidSearchIndex;
this.isExplorable = this.$store.state.i.isExplorable;
this.isIndexable = this.$store.state.i.isIndexable;
this.fieldName0 = this.$store.state.i.fields[0] ? this.$store.state.i.fields[0].name : null;
this.fieldValue0 = this.$store.state.i.fields[0] ? this.$store.state.i.fields[0].value : null;
Expand Down Expand Up @@ -315,6 +318,7 @@ export default Vue.extend({
autoAcceptFollowed: !!this.autoAcceptFollowed,
avoidSearchIndex: !!this.avoidSearchIndex,
isExplorable: !!this.isExplorable,
isIndexable: !!this.isIndexable,
}).then(i => {
this.saving = false;
this.$store.state.i.avatarId = i.avatarId;
Expand Down
5 changes: 5 additions & 0 deletions src/models/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ export class User {
})
public isExplorable: boolean;

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

constructor(data: Partial<User>) {
if (data == null) return;

Expand Down
1 change: 1 addition & 0 deletions src/models/repositories/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export class UserRepository extends Repository<User> {
carefulBot: profile!.carefulBot,
carefulRemote: profile!.carefulRemote,
autoAcceptFollowed: profile!.autoAcceptFollowed,
isIndexable: user.isIndexable,
isDeleted: user.isDeleted,
isExplorable: user.isExplorable,
hasUnreadMessagingMessage: this.getHasUnreadMessagingMessage(user.id),
Expand Down
2 changes: 2 additions & 0 deletions src/remote/activitypub/models/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
name: person.name ? truncate(person.name, MAX_NAME_LENGTH) : person.name,
isLocked: !!person.manuallyApprovesFollowers,
isExplorable: !!person.discoverable,
isIndexable: !(person.indexable === false),
username: person.preferredUsername,
usernameLower: person.preferredUsername!.toLowerCase(),
host,
Expand Down Expand Up @@ -345,6 +346,7 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint
isCat: (person as any).isCat === true,
isLocked: !!person.manuallyApprovesFollowers,
isExplorable: !!person.discoverable,
isIndexable: !(person.indexable === false),
movedToUserId: movedTo?.id || null,
} as Partial<User>;

Expand Down
1 change: 1 addition & 0 deletions src/remote/activitypub/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const renderActivity = (x: any): IActivity | null => {
Emoji: 'toot:Emoji',
featured: 'toot:featured',
discoverable: 'toot:discoverable',
indexable: 'toot:indexable',
// schema
schema: 'http://schema.org#',
PropertyValue: 'schema:PropertyValue',
Expand Down
1 change: 1 addition & 0 deletions src/remote/activitypub/renderer/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export async function renderPerson(user: ILocalUser) {
tag,
manuallyApprovesFollowers: user.isLocked,
discoverable: !!user.isExplorable,
indexable: user.isIndexable,
publicKey: renderKey(user, keypair, `#main-key`),
isCat: user.isCat,
attachment: attachment.length ? attachment : undefined,
Expand Down
1 change: 1 addition & 0 deletions src/remote/activitypub/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export interface IActor extends IObject {
preferredUsername?: string;
manuallyApprovesFollowers?: boolean;
discoverable?: boolean;
indexable?: boolean;
inbox: string;
sharedInbox?: string; // 後方互換性のため
publicKey?: {
Expand Down
8 changes: 8 additions & 0 deletions src/server/api/endpoints/i/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ export const meta = {
}
},

isIndexable: {
validator: $.optional.bool,
desc: {
'ja-JP': '投稿検索を許可する'
}
},

isBot: {
validator: $.optional.bool,
desc: {
Expand Down Expand Up @@ -218,6 +225,7 @@ export default define(meta, async (ps, user, app) => {
if (typeof ps.autoAcceptFollowed == 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
if (typeof ps.avoidSearchIndex == 'boolean') updates.avoidSearchIndex = ps.avoidSearchIndex;
if (typeof ps.isExplorable == 'boolean') updates.isExplorable = ps.isExplorable;
if (typeof ps.isIndexable == 'boolean') updates.isIndexable = ps.isIndexable;
if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat;
if (typeof ps.autoWatch == 'boolean') profileUpdates.autoWatch = ps.autoWatch;
if (typeof ps.alwaysMarkNsfw == 'boolean') profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw;
Expand Down

0 comments on commit fd0b903

Please sign in to comment.