summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-11-07 18:04:32 +0900
committerGitHub <noreply@github.com>2021-11-07 18:04:32 +0900
commita28c515ef63a6f9c188cf0a7f544db1afa8e1331 (patch)
tree4b207f6998e0697ab5c732c04769b069dfd054c7 /src/models
parentperf: delete-account処理を軽くする (#7958) (diff)
downloadmisskey-a28c515ef63a6f9c188cf0a7f544db1afa8e1331.tar.gz
misskey-a28c515ef63a6f9c188cf0a7f544db1afa8e1331.tar.bz2
misskey-a28c515ef63a6f9c188cf0a7f544db1afa8e1331.zip
feat: make possible to configure following/followers visibility (#7959)
* feat: make possible to configure following/followers visibility * add test * ap * add ap test * set Cache-Control * hide following/followers count
Diffstat (limited to 'src/models')
-rw-r--r--src/models/entities/user-profile.ts8
-rw-r--r--src/models/repositories/user.ts15
2 files changed, 20 insertions, 3 deletions
diff --git a/src/models/entities/user-profile.ts b/src/models/entities/user-profile.ts
index 1f450f223d..8a8cacfd52 100644
--- a/src/models/entities/user-profile.ts
+++ b/src/models/entities/user-profile.ts
@@ -2,7 +2,7 @@ import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn } from 'type
import { id } from '../id';
import { User } from './user';
import { Page } from './page';
-import { notificationTypes } from '@/types';
+import { ffVisibility, notificationTypes } from '@/types';
// TODO: このテーブルで管理している情報すべてレジストリで管理するようにしても良いかも
// ただ、「emailVerified が true なユーザーを find する」のようなクエリは書けなくなるからウーン
@@ -80,6 +80,12 @@ export class UserProfile {
})
public publicReactions: boolean;
+ @Column('enum', {
+ enum: ffVisibility,
+ default: 'public',
+ })
+ public ffVisibility: typeof ffVisibility[number];
+
@Column('varchar', {
length: 128, nullable: true,
})
diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts
index 9598e87191..fc0860970c 100644
--- a/src/models/repositories/user.ts
+++ b/src/models/repositories/user.ts
@@ -187,6 +187,16 @@ export class UserRepository extends Repository<User> {
.getMany() : [];
const profile = opts.detail ? await UserProfiles.findOneOrFail(user.id) : null;
+ const followingCount = profile == null ? null :
+ (profile.ffVisibility === 'public') || (meId === user.id) ? user.followingCount :
+ (profile.ffVisibility === 'followers') && (relation!.isFollowing) ? user.followingCount :
+ null;
+
+ const followersCount = profile == null ? null :
+ (profile.ffVisibility === 'public') || (meId === user.id) ? user.followersCount :
+ (profile.ffVisibility === 'followers') && (relation!.isFollowing) ? user.followersCount :
+ null;
+
const falsy = opts.detail ? false : undefined;
const packed = {
@@ -230,8 +240,8 @@ export class UserRepository extends Repository<User> {
birthday: profile!.birthday,
lang: profile!.lang,
fields: profile!.fields,
- followersCount: user.followersCount,
- followingCount: user.followingCount,
+ followersCount: followersCount || 0,
+ followingCount: followingCount || 0,
notesCount: user.notesCount,
pinnedNoteIds: pins.map(pin => pin.noteId),
pinnedNotes: Notes.packMany(pins.map(pin => pin.note!), me, {
@@ -240,6 +250,7 @@ export class UserRepository extends Repository<User> {
pinnedPageId: profile!.pinnedPageId,
pinnedPage: profile!.pinnedPageId ? Pages.pack(profile!.pinnedPageId, me) : null,
publicReactions: profile!.publicReactions,
+ ffVisibility: profile!.ffVisibility,
twoFactorEnabled: profile!.twoFactorEnabled,
usePasswordLessLogin: profile!.usePasswordLessLogin,
securityKeys: profile!.twoFactorEnabled