Skip to content

Commit

Permalink
feat: センシティブなユーザーである場合警告を出すように
Browse files Browse the repository at this point in the history
  • Loading branch information
Esurio committed Jul 30, 2024
1 parent aa63ac0 commit 8b77f09
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 1 deletion.
4 changes: 4 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,10 @@ export interface Locale extends ILocale {
* リモートユーザーのため、情報が不完全です。
*/
"remoteUserCaution": string;
/**
* センシティブなユーザーです。
*/
"sensitiveUserCaution": string;
/**
* アクティビティ
*/
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ termsOfService: "利用規約"
start: "始める"
home: "ホーム"
remoteUserCaution: "リモートユーザーのため、情報が不完全です。"
sensitiveUserCaution: "センシティブなユーザーです。"
activity: "アクティビティ"
images: "画像"
image: "画像"
Expand Down
11 changes: 11 additions & 0 deletions packages/backend/migration/1722353293595-AddSensitiveProfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class AddSensitiveProfile1722353293595 {
name = 'AddSensitiveProfile1722353293595'

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

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "isSensitive"`);
}
}
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 @@ -569,6 +569,7 @@ export class UserEntityService implements OnModuleInit {
isLocked: user.isLocked,
isSilenced: this.roleService.getUserPolicies(user.id).then(r => !r.canPublicNote),
isSuspended: user.isSuspended,
isSensitive: user.isSensitive,
description: profile!.description,
location: profile!.location,
birthday: profile!.birthday,
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/models/UserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ export class MiUserProfile {
})
public isIndexable: boolean;

@Column('boolean', {
default: false,
comment: 'Whether User is sensitive.',
})
public isSensitive: boolean;

@Column('boolean', {
default: true,
})
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/models/json-schema/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ export const packedUserDetailedNotMeOnlySchema = {
nullable: false, optional: false,
example: false,
},
isSensitive: {
type: 'boolean',
nullable: false, optional: false,
example: false,
},
description: {
type: 'string',
nullable: true, optional: false,
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/server/api/endpoints/i/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
updates.isIndexable = ps.isIndexable;
profileUpdates.isIndexable = ps.isIndexable;
};
if (typeof ps.isSensitive === 'boolean') updates.isSensitive = ps.isSensitive;
if (typeof ps.isSensitive === 'boolean') {
updates.isSensitive = ps.isSensitive;
profileUpdates.isSensitive = ps.isSensitive;
};
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/cherrypick-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4033,6 +4033,8 @@ export type components = {
isSilenced: boolean;
/** @example false */
isSuspended: boolean;
/** @example false */
isSensitive: boolean;
/** @example Hi masters, I am Ai! */
description: string | null;
location: string | null;
Expand Down
19 changes: 19 additions & 0 deletions packages/frontend/src/components/MkUserSensitiveCaution.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<div :class="$style.root"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i>{{ i18n.ts.sensitiveUserCaution }}</div>
</template>

<script lang="ts" setup>
import { i18n } from '@/i18n.js';
</script>

<style lang="scss" module>
.root {
font-size: 0.8em;
padding: 16px;
background: var(--infoWarnBg);
color: var(--error);
border-radius: var(--radius);
}
</style>
2 changes: 2 additions & 0 deletions packages/frontend/src/pages/user/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="profile _gaps">
<MkAccountMoved v-if="user.movedTo" :movedTo="user.movedTo"/>
<MkRemoteCaution v-if="user.host != null" :href="user.url ?? user.uri!" class="warn"/>
<MkUserSensitiveCaution v-if="user.isSensitive" />

<div :key="user.id" class="main _panel">
<div class="banner-container" :style="style">
Expand Down Expand Up @@ -174,6 +175,7 @@ import MkNote from '@/components/MkNote.vue';
import MkFollowButton from '@/components/MkFollowButton.vue';
import MkAccountMoved from '@/components/MkAccountMoved.vue';
import MkRemoteCaution from '@/components/MkRemoteCaution.vue';
import MkUserSensitiveCaution from '@/components/MkUserSensitiveCaution.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import MkOmit from '@/components/MkOmit.vue';
import MkInfo from '@/components/MkInfo.vue';
Expand Down

0 comments on commit 8b77f09

Please sign in to comment.