From 7413634734d31b4558a5fbaed01d8d2a88c20742 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 18 Oct 2021 01:16:59 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=82=A2=E3=82=AF=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E4=B8=80=E8=A6=A7=E3=81=AE=E5=85=AC=E9=96=8B=E3=82=92?= =?UTF-8?q?=E3=82=AA=E3=83=97=E3=83=88=E3=82=A4=E3=83=B3=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- locales/ja-JP.yml | 2 ++ migration/1634486652000-user-public-reactions.ts | 14 ++++++++++++++ src/client/pages/settings/privacy.vue | 7 +++++++ src/client/pages/user/index.vue | 4 ++-- src/models/entities/user-profile.ts | 5 +++++ src/models/repositories/user.ts | 1 + src/server/api/endpoints/i/update.ts | 5 +++++ src/server/api/endpoints/users/reactions.ts | 14 +++++++++++++- 9 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 migration/1634486652000-user-public-reactions.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index c58886e0b6..a07096b3dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ ## 12.x.x (unreleased) ### Improvements -- クライアント: ユーザーのリアクション一覧を見れるように +- クライアント: 自分のリアクション一覧を見れるように + - 設定により、リアクション一覧を全員に公開することも可能 - クライアント: ユーザー検索の精度を強化 - クライアント: 新しいライトテーマを追加 - API: ユーザーのリアクション一覧を取得する users/reactions を追加 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 358da897d0..5402a05e4f 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -797,6 +797,8 @@ unread: "未読" filter: "フィルタ" controllPanel: "コントロールパネル" manageAccounts: "アカウントを管理" +makeReactionsPublic: "リアクション一覧を公開する" +makeReactionsPublicDescription: "あなたがしたリアクション一覧を誰でも見れるようにします。" _signup: almostThere: "ほとんど完了です" diff --git a/migration/1634486652000-user-public-reactions.ts b/migration/1634486652000-user-public-reactions.ts new file mode 100644 index 0000000000..da57a13269 --- /dev/null +++ b/migration/1634486652000-user-public-reactions.ts @@ -0,0 +1,14 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class userPublicReactions1634486652000 implements MigrationInterface { + name = 'userPublicReactions1634486652000' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "user_profile" ADD "publicReactions" boolean NOT NULL DEFAULT false`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "publicReactions"`); + } + +} diff --git a/src/client/pages/settings/privacy.vue b/src/client/pages/settings/privacy.vue index 7756158578..2a60ae1f46 100644 --- a/src/client/pages/settings/privacy.vue +++ b/src/client/pages/settings/privacy.vue @@ -5,6 +5,10 @@ {{ $ts.autoAcceptFollowed }} + + {{ $ts.makeReactionsPublic }} + + {{ $ts.hideOnlineStatus }} @@ -64,6 +68,7 @@ export default defineComponent({ noCrawle: false, isExplorable: false, hideOnlineStatus: false, + publicReactions: false, } }, @@ -80,6 +85,7 @@ export default defineComponent({ this.noCrawle = this.$i.noCrawle; this.isExplorable = this.$i.isExplorable; this.hideOnlineStatus = this.$i.hideOnlineStatus; + this.publicReactions = this.$i.publicReactions; }, mounted() { @@ -94,6 +100,7 @@ export default defineComponent({ noCrawle: !!this.noCrawle, isExplorable: !!this.isExplorable, hideOnlineStatus: !!this.hideOnlineStatus, + publicReactions: !!this.publicReactions, }); } } diff --git a/src/client/pages/user/index.vue b/src/client/pages/user/index.vue index 6811dff2db..f74bf49883 100644 --- a/src/client/pages/user/index.vue +++ b/src/client/pages/user/index.vue @@ -270,12 +270,12 @@ export default defineComponent({ title: this.$ts.overview, icon: 'fas fa-home', onClick: () => { this.$router.push('/@' + getAcct(this.user)); }, - }, { + }, ...(this.$i && (this.$i.id === this.user.id)) || this.user.publicReactions ? [{ active: this.page === 'reactions', title: this.$ts.reaction, icon: 'fas fa-laugh', onClick: () => { this.$router.push('/@' + getAcct(this.user) + '/reactions'); }, - }, { + }] : [], { active: this.page === 'clips', title: this.$ts.clips, icon: 'fas fa-paperclip', diff --git a/src/models/entities/user-profile.ts b/src/models/entities/user-profile.ts index a2da07d76f..1f450f223d 100644 --- a/src/models/entities/user-profile.ts +++ b/src/models/entities/user-profile.ts @@ -75,6 +75,11 @@ export class UserProfile { }) public emailNotificationTypes: string[]; + @Column('boolean', { + default: false, + }) + public publicReactions: boolean; + @Column('varchar', { length: 128, nullable: true, }) diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts index b6f27e32e2..2b77b613a8 100644 --- a/src/models/repositories/user.ts +++ b/src/models/repositories/user.ts @@ -231,6 +231,7 @@ export class UserRepository extends Repository { }), pinnedPageId: profile!.pinnedPageId, pinnedPage: profile!.pinnedPageId ? Pages.pack(profile!.pinnedPageId, me) : null, + publicReactions: profile!.publicReactions, twoFactorEnabled: profile!.twoFactorEnabled, usePasswordLessLogin: profile!.usePasswordLessLogin, securityKeys: profile!.twoFactorEnabled diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index 9dd637251d..3b8b1579ea 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -68,6 +68,10 @@ export const meta = { validator: $.optional.bool, }, + publicReactions: { + validator: $.optional.bool, + }, + carefulBot: { validator: $.optional.bool, }, @@ -180,6 +184,7 @@ export default define(meta, async (ps, _user, token) => { if (typeof ps.isLocked === 'boolean') updates.isLocked = ps.isLocked; if (typeof ps.isExplorable === 'boolean') updates.isExplorable = ps.isExplorable; if (typeof ps.hideOnlineStatus === 'boolean') updates.hideOnlineStatus = ps.hideOnlineStatus; + if (typeof ps.publicReactions === 'boolean') profileUpdates.publicReactions = ps.publicReactions; 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/reactions.ts b/src/server/api/endpoints/users/reactions.ts index 44d7887482..fe5e4d84a9 100644 --- a/src/server/api/endpoints/users/reactions.ts +++ b/src/server/api/endpoints/users/reactions.ts @@ -1,9 +1,10 @@ import $ from 'cafy'; import { ID } from '@/misc/cafy-id'; import define from '../../define'; -import { NoteReactions } from '@/models/index'; +import { NoteReactions, UserProfiles } from '@/models/index'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; +import { ApiError } from '../../error'; export const meta = { tags: ['users', 'reactions'], @@ -48,10 +49,21 @@ export const meta = { }, errors: { + reactionsNotPublic: { + message: 'Reactions of the user is not public.', + code: 'REACTIONS_NOT_PUBLIC', + id: '673a7dd2-6924-1093-e0c0-e68456ceae5c' + }, } }; export default define(meta, async (ps, me) => { + const profile = await UserProfiles.findOneOrFail(ps.userId); + + if (me == null || (me.id !== ps.userId && !profile.publicReactions)) { + throw new ApiError(meta.errors.reactionsNotPublic); + } + const query = makePaginationQuery(NoteReactions.createQueryBuilder('reaction'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) .andWhere(`reaction.userId = :userId`, { userId: ps.userId })