summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-12-11 21:16:20 +0900
committerGitHub <noreply@github.com>2020-12-11 21:16:20 +0900
commit69c3c4e3dc71c722f9d85c4d2d6a112b6ce85296 (patch)
tree276f2dfa111772f8a2be5c5cabea2a4085d0c6a3 /src
parentMerge pull request #6960 from syuilo/dependabot/npm_and_yarn/ws-7.4.1 (diff)
downloadsharkey-69c3c4e3dc71c722f9d85c4d2d6a112b6ce85296.tar.gz
sharkey-69c3c4e3dc71c722f9d85c4d2d6a112b6ce85296.tar.bz2
sharkey-69c3c4e3dc71c722f9d85c4d2d6a112b6ce85296.zip
Resolve #6806 (#6935)
* :v: * :v: * Update privacy.vue
Diffstat (limited to 'src')
-rw-r--r--src/client/pages/settings/privacy.vue7
-rw-r--r--src/models/entities/user.ts7
-rw-r--r--src/models/repositories/user.ts1
-rw-r--r--src/remote/activitypub/models/person.ts2
-rw-r--r--src/remote/activitypub/renderer/index.ts1
-rw-r--r--src/remote/activitypub/renderer/person.ts1
-rw-r--r--src/remote/activitypub/type.ts1
-rw-r--r--src/server/api/endpoints/i/update.ts5
-rw-r--r--src/server/api/endpoints/users.ts9
-rw-r--r--src/server/api/endpoints/users/recommendation.ts1
-rw-r--r--src/services/create-system-user.ts1
11 files changed, 32 insertions, 4 deletions
diff --git a/src/client/pages/settings/privacy.vue b/src/client/pages/settings/privacy.vue
index 09db077502..d5242a5f51 100644
--- a/src/client/pages/settings/privacy.vue
+++ b/src/client/pages/settings/privacy.vue
@@ -9,6 +9,10 @@
{{ $t('noCrawle') }}
<template #desc>{{ $t('noCrawleDescription') }}</template>
</FormSwitch>
+ <FormSwitch v-model:value="isExplorable" @update:value="save()">
+ {{ $t('makeExplorable') }}
+ <template #desc>{{ $t('makeExplorableDescription') }}</template>
+ </FormSwitch>
<FormSwitch v-model:value="rememberNoteVisibility" @update:value="save()">{{ $t('rememberNoteVisibility') }}</FormSwitch>
<FormGroup v-if="!rememberNoteVisibility">
<template #label>{{ $t('defaultNoteVisibility') }}</template>
@@ -51,6 +55,7 @@ export default defineComponent({
isLocked: false,
autoAcceptFollowed: false,
noCrawle: false,
+ isExplorable: false,
}
},
@@ -75,6 +80,7 @@ export default defineComponent({
this.isLocked = this.$store.state.i.isLocked;
this.autoAcceptFollowed = this.$store.state.i.autoAcceptFollowed;
this.noCrawle = this.$store.state.i.noCrawle;
+ this.isExplorable = this.$store.state.i.isExplorable;
},
mounted() {
@@ -87,6 +93,7 @@ export default defineComponent({
isLocked: !!this.isLocked,
autoAcceptFollowed: !!this.autoAcceptFollowed,
noCrawle: !!this.noCrawle,
+ isExplorable: !!this.isExplorable,
});
}
}
diff --git a/src/models/entities/user.ts b/src/models/entities/user.ts
index fee5906a3d..ba2062fdb6 100644
--- a/src/models/entities/user.ts
+++ b/src/models/entities/user.ts
@@ -157,6 +157,13 @@ export class User {
})
public isModerator: boolean;
+ @Index()
+ @Column('boolean', {
+ default: true,
+ comment: 'Whether the User is explorable.'
+ })
+ public isExplorable: boolean;
+
@Column('varchar', {
length: 128, array: true, default: '{}'
})
diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts
index 87f50b448b..29facf5239 100644
--- a/src/models/repositories/user.ts
+++ b/src/models/repositories/user.ts
@@ -240,6 +240,7 @@ export class UserRepository extends Repository<User> {
carefulBot: profile!.carefulBot,
autoAcceptFollowed: profile!.autoAcceptFollowed,
noCrawle: profile!.noCrawle,
+ isExplorable: user.isExplorable,
hasUnreadSpecifiedNotes: NoteUnreads.count({
where: { userId: user.id, isSpecified: true },
take: 1
diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts
index 9f6392174b..f0a312b21a 100644
--- a/src/remote/activitypub/models/person.ts
+++ b/src/remote/activitypub/models/person.ts
@@ -153,6 +153,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
lastFetchedAt: new Date(),
name: person.name,
isLocked: !!person.manuallyApprovesFollowers,
+ isExplorable: !!person.discoverable,
username: person.preferredUsername,
usernameLower: person.preferredUsername!.toLowerCase(),
host,
@@ -336,6 +337,7 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint
isBot: object.type === 'Service',
isCat: (person as any).isCat === true,
isLocked: !!person.manuallyApprovesFollowers,
+ isExplorable: !!person.discoverable,
} as Partial<User>;
if (avatar) {
diff --git a/src/remote/activitypub/renderer/index.ts b/src/remote/activitypub/renderer/index.ts
index cf0fd8d85a..a34febff2f 100644
--- a/src/remote/activitypub/renderer/index.ts
+++ b/src/remote/activitypub/renderer/index.ts
@@ -38,6 +38,7 @@ export const attachLdSignature = async (activity: any, user: ILocalUser): Promis
toot: 'http://joinmastodon.org/ns#',
Emoji: 'toot:Emoji',
featured: 'toot:featured',
+ discoverable: 'toot:discoverable',
// schema
schema: 'http://schema.org#',
PropertyValue: 'schema:PropertyValue',
diff --git a/src/remote/activitypub/renderer/person.ts b/src/remote/activitypub/renderer/person.ts
index 87dca19acd..4462f88315 100644
--- a/src/remote/activitypub/renderer/person.ts
+++ b/src/remote/activitypub/renderer/person.ts
@@ -70,6 +70,7 @@ export async function renderPerson(user: ILocalUser) {
image: banner ? renderImage(banner) : null,
tag,
manuallyApprovesFollowers: user.isLocked,
+ discoverable: !!user.isExplorable,
publicKey: renderKey(user, keypair, `#main-key`),
isCat: user.isCat,
attachment: attachment.length ? attachment : undefined
diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts
index 5c01c24b53..db866ae67a 100644
--- a/src/remote/activitypub/type.ts
+++ b/src/remote/activitypub/type.ts
@@ -135,6 +135,7 @@ export interface IPerson extends IObject {
name?: string;
preferredUsername?: string;
manuallyApprovesFollowers?: boolean;
+ discoverable?: boolean;
inbox?: string;
sharedInbox?: string; // 後方互換性のため
publicKey: {
diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts
index 0872671208..8ac427cd5b 100644
--- a/src/server/api/endpoints/i/update.ts
+++ b/src/server/api/endpoints/i/update.ts
@@ -92,6 +92,10 @@ export const meta = {
}
},
+ isExplorable: {
+ validator: $.optional.bool,
+ },
+
carefulBot: {
validator: $.optional.bool,
desc: {
@@ -208,6 +212,7 @@ export default define(meta, async (ps, user, token) => {
}
if (ps.mutingNotificationTypes !== undefined) profileUpdates.mutingNotificationTypes = ps.mutingNotificationTypes as typeof notificationTypes[number][];
if (typeof ps.isLocked === 'boolean') updates.isLocked = ps.isLocked;
+ if (typeof ps.isExplorable === 'boolean') updates.isExplorable = ps.isExplorable;
if (typeof ps.isBot === 'boolean') updates.isBot = ps.isBot;
if (typeof ps.carefulBot === 'boolean') profileUpdates.carefulBot = ps.carefulBot;
if (typeof ps.autoAcceptFollowed === 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
diff --git a/src/server/api/endpoints/users.ts b/src/server/api/endpoints/users.ts
index 9d7991b406..1c16472578 100644
--- a/src/server/api/endpoints/users.ts
+++ b/src/server/api/endpoints/users.ts
@@ -64,12 +64,13 @@ export const meta = {
export default define(meta, async (ps, me) => {
const query = Users.createQueryBuilder('user');
+ query.where('user.isExplorable = TRUE');
switch (ps.state) {
- case 'admin': query.where('user.isAdmin = TRUE'); break;
- case 'moderator': query.where('user.isModerator = TRUE'); break;
- case 'adminOrModerator': query.where('user.isAdmin = TRUE OR isModerator = TRUE'); break;
- case 'alive': query.where('user.updatedAt > :date', { date: new Date(Date.now() - 1000 * 60 * 60 * 24 * 5) }); break;
+ case 'admin': query.andWhere('user.isAdmin = TRUE'); break;
+ case 'moderator': query.andWhere('user.isModerator = TRUE'); break;
+ case 'adminOrModerator': query.andWhere('user.isAdmin = TRUE OR isModerator = TRUE'); break;
+ case 'alive': query.andWhere('user.updatedAt > :date', { date: new Date(Date.now() - 1000 * 60 * 60 * 24 * 5) }); break;
}
switch (ps.origin) {
diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts
index 1b59624aa9..7f80b52753 100644
--- a/src/server/api/endpoints/users/recommendation.ts
+++ b/src/server/api/endpoints/users/recommendation.ts
@@ -42,6 +42,7 @@ export const meta = {
export default define(meta, async (ps, me) => {
const query = Users.createQueryBuilder('user')
.where('user.isLocked = FALSE')
+ .andWhere('user.isExplorable = TRUE')
.andWhere('user.host IS NULL')
.andWhere('user.updatedAt >= :date', { date: new Date(Date.now() - ms('7days')) })
.andWhere('user.id != :meId', { meId: me.id })
diff --git a/src/services/create-system-user.ts b/src/services/create-system-user.ts
index 7f59efb448..3c44c7427f 100644
--- a/src/services/create-system-user.ts
+++ b/src/services/create-system-user.ts
@@ -34,6 +34,7 @@ export async function createSystemUser(username: string) {
token: secret,
isAdmin: false,
isLocked: true,
+ isExplorable: false,
isBot: true,
}));