mirror of
https://git.boykissers.com/pawkey/pawkey-sk.git
synced 2025-12-20 04:04:16 +00:00
improve performance of /v1/accounts/relationships
This commit is contained in:
@@ -342,7 +342,7 @@ export interface MegalodonInterface {
|
||||
* @param ids Array of account IDs.
|
||||
* @return Array of Relationship.
|
||||
*/
|
||||
getRelationships(ids: Array<string>): Promise<Response<Array<Entity.Relationship>>>
|
||||
getRelationships(ids: string | Array<string>): Promise<Response<Array<Entity.Relationship>>>
|
||||
/**
|
||||
* Search for matching accounts by username or display name.
|
||||
*
|
||||
|
||||
@@ -606,11 +606,16 @@ export default class Misskey implements MegalodonInterface {
|
||||
*
|
||||
* @param ids Array of account ID, for example `['1sdfag', 'ds12aa']`.
|
||||
*/
|
||||
public async getRelationships(ids: Array<string>): Promise<Response<Array<Entity.Relationship>>> {
|
||||
return Promise.all(ids.map(id => this.getRelationship(id))).then(results => ({
|
||||
...results[0],
|
||||
data: results.map(r => r.data)
|
||||
}))
|
||||
public async getRelationships(ids: string | Array<string>): Promise<Response<Array<Entity.Relationship>>> {
|
||||
return this.client
|
||||
.post<MisskeyAPI.Entity.Relation[]>('/api/users/relation', {
|
||||
userId: ids
|
||||
})
|
||||
.then(res => {
|
||||
return Object.assign(res, {
|
||||
data: res.data.map(r => MisskeyAPI.Converter.relation(r))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user