1
0
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:
Hazelnoot
2025-03-21 22:51:33 -04:00
parent f5be341acc
commit de26ffd60b
3 changed files with 14 additions and 12 deletions

View File

@@ -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.
*

View File

@@ -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))
})
})
}
/**