1
0

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
This commit is contained in:
syuilo
2021-11-07 18:04:32 +09:00
committed by GitHub
parent 07526ada45
commit a28c515ef6
14 changed files with 317 additions and 10 deletions
+13 -2
View File
@@ -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