File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,6 +156,29 @@ export class Actor {
156156 }
157157}
158158
159+ // TODO: we can give this a better name
160+ export class ActorWithProfileFunction extends Actor {
161+ async profile ( ) {
162+ const data = await this . client
163+ . get ( 'app.bsky.actor.getProfile' , {
164+ params : { actor : this . did } ,
165+ } )
166+ . then ( ( res ) => res . data ) ;
167+
168+ if (
169+ data . viewer ?. knownFollowers ?. followers &&
170+ data . viewer ?. knownFollowers ?. followers . length > 0
171+ ) {
172+ data . viewer . knownFollowers . followers =
173+ data . viewer . knownFollowers . followers . map (
174+ ( follower ) => new BasicActorProfile ( this . client , follower ) ,
175+ ) ;
176+ }
177+
178+ return data ;
179+ }
180+ }
181+
159182export class BasicActorProfile
160183 extends Actor
161184 implements AppBskyActorDefs . ProfileViewBasic
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type {
55 At ,
66 Queries ,
77} from '@tsky/lexicons' ;
8- import { DetailedActorProfile } from '~/actor' ;
8+ import { ActorWithProfileFunction } from '~/actor' ;
99import { Feed } from '~/feed' ;
1010import { List } from '~/list' ;
1111import { Search } from '~/search' ;
@@ -30,12 +30,8 @@ export class Agent {
3030 /**
3131 * Get detailed profile view of an actor. Does not require auth, but contains relevant metadata with auth.
3232 */
33- async actor ( identifier : At . DID | At . Handle ) : Promise < DetailedActorProfile > {
34- const res = await this . client . get ( 'app.bsky.actor.getProfile' , {
35- params : { actor : identifier } ,
36- } ) ;
37-
38- return new DetailedActorProfile ( this . client , res . data ) ;
33+ async actor ( identifier : At . DID ) : Promise < ActorWithProfileFunction > {
34+ return new ActorWithProfileFunction ( this . client , identifier ) ;
3935 }
4036
4137 list ( uri : string ) {
Original file line number Diff line number Diff line change 11import type { AppBskyFeedGetTimeline } from '@tsky/lexicons' ;
2- import { Actor } from '~/actor' ;
2+ import { ActorWithProfileFunction } from '~/actor' ;
33import type { RPCOptions } from '~/types' ;
44import { Paginator } from '~/utils' ;
55import { Mute } from './mute' ;
@@ -8,7 +8,7 @@ import { Preferences } from './preferences';
88import { Suggestion } from './suggestion' ;
99import { Unmute } from './unmute' ;
1010
11- export class User extends Actor {
11+ export class User extends ActorWithProfileFunction {
1212 get preferences ( ) {
1313 return new Preferences ( this . client ) ;
1414 }
You can’t perform that action at this time.
0 commit comments