From 06630c097b3865ca61e6effa0ff42fa460b83ba1 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Mon, 25 Sep 2023 05:33:25 +0200 Subject: [PATCH] upd: update user data fetching on masto api --- packages/backend/src/core/entities/UserEntityService.ts | 8 ++++---- packages/megalodon/src/misskey/api_client.ts | 8 ++++---- packages/megalodon/src/misskey/entities/user.ts | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index 3f007ebc11..e72b301cc9 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -344,6 +344,7 @@ export class UserEntityService implements OnModuleInit { host: user.host, avatarUrl: user.avatarUrl ?? this.getIdenticonUrl(user), avatarBlurhash: user.avatarBlurhash, + description: profile!.description, createdAt: user.createdAt.toISOString(), isBot: user.isBot ?? falsy, isCat: user.isCat ?? falsy, @@ -355,6 +356,9 @@ export class UserEntityService implements OnModuleInit { faviconUrl: instance.faviconUrl, themeColor: instance.themeColor, } : undefined) : undefined, + followersCount: followersCount ?? 0, + followingCount: followingCount ?? 0, + notesCount: user.notesCount, emojis: this.customEmojiService.populateEmojis(user.emojis, user.host), onlineStatus: this.getOnlineStatus(user), // パフォーマンス上の理由でローカルユーザーのみ @@ -379,16 +383,12 @@ export class UserEntityService implements OnModuleInit { isLocked: user.isLocked, isSilenced: this.roleService.getUserPolicies(user.id).then(r => !r.canPublicNote), isSuspended: user.isSuspended ?? falsy, - description: profile!.description, location: profile!.location, birthday: profile!.birthday, listenbrainz: profile!.listenbrainz, lang: profile!.lang, fields: profile!.fields, verifiedLinks: profile!.verifiedLinks, - followersCount: followersCount ?? 0, - followingCount: followingCount ?? 0, - notesCount: user.notesCount, pinnedNoteIds: pins.map(pin => pin.noteId), pinnedNotes: this.noteEntityService.packMany(pins.map(pin => pin.note!), me, { detail: true, diff --git a/packages/megalodon/src/misskey/api_client.ts b/packages/megalodon/src/misskey/api_client.ts index a9806c0abf..9bec2a2f0e 100644 --- a/packages/megalodon/src/misskey/api_client.ts +++ b/packages/megalodon/src/misskey/api_client.ts @@ -88,10 +88,10 @@ namespace MisskeyAPI { suspended: null, limited: null, created_at: u.createdAt ? u.createdAt : '', - followers_count: 0, - following_count: 0, - statuses_count: 0, - note: '', + followers_count: u.followersCount ? u.followersCount : 0, + following_count: u.followingCount ? u.followingCount : 0, + statuses_count: u.notesCount ? u.notesCount : 0, + note: u.description ? u.description : '', url: u.host ? `https://${u.host}/@${u.username}` : host ? `https://${host}/@${u.username}` : acct, avatar: u.avatarUrl, avatar_static: u.avatarColor, diff --git a/packages/megalodon/src/misskey/entities/user.ts b/packages/megalodon/src/misskey/entities/user.ts index 4a1db07eac..441e0056f4 100644 --- a/packages/megalodon/src/misskey/entities/user.ts +++ b/packages/megalodon/src/misskey/entities/user.ts @@ -5,7 +5,11 @@ namespace MisskeyEntity { id: string name: string username: string + description?: string createdAt?: string + followingCount?: number + followersCount?: number + notesCount?: number host: string | null avatarUrl: string avatarColor: string