mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2025-09-18 21:38:07 +00:00
add "detail" flag to more user endpoints
This commit is contained in:
parent
ed68230811
commit
3dbfb4fa20
13 changed files with 110 additions and 34 deletions
|
@ -35,7 +35,7 @@ export const meta = {
|
|||
properties: {
|
||||
id: { type: 'string', format: 'misskey:id' },
|
||||
createdAt: { type: 'string', format: 'date-time' },
|
||||
user: { ref: 'UserDetailed' },
|
||||
user: { ref: 'User' },
|
||||
expiresAt: { type: 'string', format: 'date-time', nullable: true },
|
||||
},
|
||||
required: ['id', 'createdAt', 'user'],
|
||||
|
@ -50,6 +50,11 @@ export const paramDef = {
|
|||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
detail: {
|
||||
type: 'boolean',
|
||||
nullable: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
required: ['roleId'],
|
||||
} as const;
|
||||
|
@ -90,12 +95,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
.getMany();
|
||||
|
||||
const _users = assigns.map(({ user, userId }) => user ?? userId);
|
||||
const _userMap = await this.userEntityService.packMany(_users, me, { schema: 'UserDetailed' })
|
||||
const _userMap = await this.userEntityService.packMany(_users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' })
|
||||
.then(users => new Map(users.map(u => [u.id, u])));
|
||||
return await Promise.all(assigns.map(async assign => ({
|
||||
id: assign.id,
|
||||
createdAt: this.idService.parse(assign.id).date.toISOString(),
|
||||
user: _userMap.get(assign.userId) ?? await this.userEntityService.pack(assign.user!, me, { schema: 'UserDetailed' }),
|
||||
user: _userMap.get(assign.userId) ?? await this.userEntityService.pack(assign.user!, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' }),
|
||||
expiresAt: assign.expiresAt?.toISOString() ?? null,
|
||||
})));
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ export const meta = {
|
|||
items: {
|
||||
type: 'object',
|
||||
nullable: false, optional: false,
|
||||
ref: 'UserDetailed',
|
||||
ref: 'User',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
@ -44,6 +44,11 @@ export const paramDef = {
|
|||
default: null,
|
||||
description: 'The local host is represented with `null`.',
|
||||
},
|
||||
detail: {
|
||||
type: 'boolean',
|
||||
nullable: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
@ -115,7 +120,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
const users = await query.getMany();
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
||||
return await this.userEntityService.packMany(users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export const meta = {
|
|||
items: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'UserDetailed',
|
||||
ref: 'User',
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -43,6 +43,11 @@ export const paramDef = {
|
|||
state: { type: 'string', enum: ['all', 'alive'], default: 'all' },
|
||||
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'local' },
|
||||
trending: { type: 'boolean', default: false },
|
||||
detail: {
|
||||
type: 'boolean',
|
||||
nullable: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
required: ['tag', 'sort'],
|
||||
} as const;
|
||||
|
@ -96,7 +101,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
.map(([u]) => u);
|
||||
}
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
||||
return await this.userEntityService.packMany(users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export const meta = {
|
|||
items: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'UserDetailed',
|
||||
ref: 'User',
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -36,7 +36,13 @@ export const meta = {
|
|||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
properties: {
|
||||
detail: {
|
||||
type: 'boolean',
|
||||
nullable: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
|
@ -57,7 +63,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
host: acct.host ?? IsNull(),
|
||||
})));
|
||||
|
||||
return await this.userEntityService.packMany(users.filter(x => x != null), me, { schema: 'UserDetailed' });
|
||||
return await this.userEntityService.packMany(users.filter(x => x != null), me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ export const meta = {
|
|||
},
|
||||
user: {
|
||||
type: 'object',
|
||||
ref: 'UserDetailed',
|
||||
ref: 'User',
|
||||
},
|
||||
},
|
||||
required: ['id', 'user'],
|
||||
|
@ -58,6 +58,11 @@ export const paramDef = {
|
|||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
detail: {
|
||||
type: 'boolean',
|
||||
nullable: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
required: ['roleId'],
|
||||
} as const;
|
||||
|
@ -99,11 +104,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
.getMany();
|
||||
|
||||
const _users = assigns.map(({ user, userId }) => user ?? userId);
|
||||
const _userMap = await this.userEntityService.packMany(_users, me, { schema: 'UserDetailed' })
|
||||
const _userMap = await this.userEntityService.packMany(_users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' })
|
||||
.then(users => new Map(users.map(u => [u.id, u])));
|
||||
return await Promise.all(assigns.map(async assign => ({
|
||||
id: assign.id,
|
||||
user: _userMap.get(assign.userId) ?? await this.userEntityService.pack(assign.user!, me, { schema: 'UserDetailed' }),
|
||||
user: _userMap.get(assign.userId) ?? await this.userEntityService.pack(assign.user!, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' }),
|
||||
})));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export const meta = {
|
|||
items: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'UserDetailed',
|
||||
ref: 'User',
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -50,6 +50,11 @@ export const paramDef = {
|
|||
default: null,
|
||||
description: 'The local host is represented with `null`.',
|
||||
},
|
||||
detail: {
|
||||
type: 'boolean',
|
||||
nullable: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
@ -111,7 +116,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
.filter(([,p]) => p.canTrend)
|
||||
.map(([u]) => u);
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
||||
return await this.userEntityService.packMany(users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export const meta = {
|
|||
user: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'UserDetailed',
|
||||
ref: 'User',
|
||||
},
|
||||
weight: {
|
||||
type: 'number',
|
||||
|
@ -60,6 +60,11 @@ export const paramDef = {
|
|||
properties: {
|
||||
userId: { type: 'string', format: 'misskey:id' },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
detail: {
|
||||
type: 'boolean',
|
||||
nullable: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
required: ['userId'],
|
||||
} as const;
|
||||
|
@ -127,10 +132,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
const topRepliedUserIds = repliedUsersSorted.slice(0, ps.limit);
|
||||
|
||||
// Make replies object (includes weights)
|
||||
const _userMap = await this.userEntityService.packMany(topRepliedUserIds, me, { schema: 'UserDetailed' })
|
||||
const _userMap = await this.userEntityService.packMany(topRepliedUserIds, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' })
|
||||
.then(users => new Map(users.map(u => [u.id, u])));
|
||||
const repliesObj = await Promise.all(topRepliedUserIds.map(async (userId) => ({
|
||||
user: _userMap.get(userId) ?? await this.userEntityService.pack(userId, me, { schema: 'UserDetailed' }),
|
||||
user: _userMap.get(userId) ?? await this.userEntityService.pack(userId, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' }),
|
||||
weight: repliedUsers[userId] / peak,
|
||||
})));
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ export const meta = {
|
|||
items: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'UserDetailed',
|
||||
ref: 'User',
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -42,6 +42,11 @@ export const paramDef = {
|
|||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
offset: { type: 'integer', default: 0 },
|
||||
detail: {
|
||||
type: 'boolean',
|
||||
nullable: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
@ -83,7 +88,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
const users = await query.limit(ps.limit).offset(ps.offset).getMany();
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
||||
return await this.userEntityService.packMany(users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@ export const meta = {
|
|||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
ref: 'UserDetailed',
|
||||
ref: 'User',
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
ref: 'UserDetailed',
|
||||
ref: 'User',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -79,6 +79,11 @@ export const paramDef = {
|
|||
nullable: true,
|
||||
description: 'The local host is represented with `null`.',
|
||||
},
|
||||
detail: {
|
||||
type: 'boolean',
|
||||
nullable: false,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
anyOf: [
|
||||
{ required: ['userId'] },
|
||||
|
@ -125,7 +130,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (user != null) _users.push(user);
|
||||
}
|
||||
|
||||
const _userMap = await this.userEntityService.packMany(_users, me, { schema: 'UserDetailed' })
|
||||
const _userMap = await this.userEntityService.packMany(_users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' })
|
||||
.then(users => new Map(users.map(u => [u.id, u])));
|
||||
return _users.map(u => _userMap.get(u.id)!);
|
||||
} else {
|
||||
|
@ -156,7 +161,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
return await this.userEntityService.pack(user, me, {
|
||||
schema: 'UserDetailed',
|
||||
schema: ps.detail ? 'UserDetailed' : 'UserLite',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2067,6 +2067,7 @@ declare namespace entities {
|
|||
PagesUnlikeRequest,
|
||||
PagesUpdateRequest,
|
||||
PingResponse,
|
||||
PinnedUsersRequest,
|
||||
PinnedUsersResponse,
|
||||
PromoReadRequest,
|
||||
RenoteMuteCreateRequest,
|
||||
|
@ -3411,6 +3412,9 @@ export const permissions: readonly ["read:account", "write:account", "read:block
|
|||
// @public (undocumented)
|
||||
type PingResponse = operations['ping']['responses']['200']['content']['application/json'];
|
||||
|
||||
// @public (undocumented)
|
||||
type PinnedUsersRequest = operations['pinned-users']['requestBody']['content']['application/json'];
|
||||
|
||||
// @public (undocumented)
|
||||
type PinnedUsersResponse = operations['pinned-users']['responses']['200']['content']['application/json'];
|
||||
|
||||
|
|
|
@ -563,6 +563,7 @@ import type {
|
|||
PagesUnlikeRequest,
|
||||
PagesUpdateRequest,
|
||||
PingResponse,
|
||||
PinnedUsersRequest,
|
||||
PinnedUsersResponse,
|
||||
PromoReadRequest,
|
||||
RenoteMuteCreateRequest,
|
||||
|
@ -1044,7 +1045,7 @@ export type Endpoints = {
|
|||
'pages/unlike': { req: PagesUnlikeRequest; res: EmptyResponse };
|
||||
'pages/update': { req: PagesUpdateRequest; res: EmptyResponse };
|
||||
'ping': { req: EmptyRequest; res: PingResponse };
|
||||
'pinned-users': { req: EmptyRequest; res: PinnedUsersResponse };
|
||||
'pinned-users': { req: PinnedUsersRequest; res: PinnedUsersResponse };
|
||||
'promo/read': { req: PromoReadRequest; res: EmptyResponse };
|
||||
'renote-mute/create': { req: RenoteMuteCreateRequest; res: EmptyResponse };
|
||||
'renote-mute/delete': { req: RenoteMuteDeleteRequest; res: EmptyResponse };
|
||||
|
|
|
@ -566,6 +566,7 @@ export type PagesShowResponse = operations['pages___show']['responses']['200']['
|
|||
export type PagesUnlikeRequest = operations['pages___unlike']['requestBody']['content']['application/json'];
|
||||
export type PagesUpdateRequest = operations['pages___update']['requestBody']['content']['application/json'];
|
||||
export type PingResponse = operations['ping']['responses']['200']['content']['application/json'];
|
||||
export type PinnedUsersRequest = operations['pinned-users']['requestBody']['content']['application/json'];
|
||||
export type PinnedUsersResponse = operations['pinned-users']['responses']['200']['content']['application/json'];
|
||||
export type PromoReadRequest = operations['promo___read']['requestBody']['content']['application/json'];
|
||||
export type RenoteMuteCreateRequest = operations['renote-mute___create']['requestBody']['content']['application/json'];
|
||||
|
|
|
@ -10898,6 +10898,8 @@ export type operations = {
|
|||
untilId?: string;
|
||||
/** @default 10 */
|
||||
limit?: number;
|
||||
/** @default true */
|
||||
detail?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -10910,7 +10912,7 @@ export type operations = {
|
|||
id: string;
|
||||
/** Format: date-time */
|
||||
createdAt: string;
|
||||
user: components['schemas']['UserDetailed'];
|
||||
user: components['schemas']['User'];
|
||||
/** Format: date-time */
|
||||
expiresAt: string | null;
|
||||
})[];
|
||||
|
@ -11406,6 +11408,8 @@ export type operations = {
|
|||
* @default null
|
||||
*/
|
||||
hostname?: string | null;
|
||||
/** @default true */
|
||||
detail?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -11413,7 +11417,7 @@ export type operations = {
|
|||
/** @description OK (with results) */
|
||||
200: {
|
||||
content: {
|
||||
'application/json': components['schemas']['UserDetailed'][];
|
||||
'application/json': components['schemas']['User'][];
|
||||
};
|
||||
};
|
||||
/** @description Client error */
|
||||
|
@ -21853,6 +21857,8 @@ export type operations = {
|
|||
origin?: 'combined' | 'local' | 'remote';
|
||||
/** @default false */
|
||||
trending?: boolean;
|
||||
/** @default true */
|
||||
detail?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -21860,7 +21866,7 @@ export type operations = {
|
|||
/** @description OK (with results) */
|
||||
200: {
|
||||
content: {
|
||||
'application/json': components['schemas']['UserDetailed'][];
|
||||
'application/json': components['schemas']['User'][];
|
||||
};
|
||||
};
|
||||
/** @description Client error */
|
||||
|
@ -29830,11 +29836,19 @@ export type operations = {
|
|||
* **Credential required**: *No*
|
||||
*/
|
||||
'pinned-users': {
|
||||
requestBody: {
|
||||
content: {
|
||||
'application/json': {
|
||||
/** @default true */
|
||||
detail?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK (with results) */
|
||||
200: {
|
||||
content: {
|
||||
'application/json': components['schemas']['UserDetailed'][];
|
||||
'application/json': components['schemas']['User'][];
|
||||
};
|
||||
};
|
||||
/** @description Client error */
|
||||
|
@ -30962,6 +30976,8 @@ export type operations = {
|
|||
untilId?: string;
|
||||
/** @default 10 */
|
||||
limit?: number;
|
||||
/** @default true */
|
||||
detail?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -30972,7 +30988,7 @@ export type operations = {
|
|||
'application/json': {
|
||||
/** Format: misskey:id */
|
||||
id: string;
|
||||
user: components['schemas']['UserDetailed'];
|
||||
user: components['schemas']['User'];
|
||||
}[];
|
||||
};
|
||||
};
|
||||
|
@ -31635,6 +31651,8 @@ export type operations = {
|
|||
* @default null
|
||||
*/
|
||||
hostname?: string | null;
|
||||
/** @default true */
|
||||
detail?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -31642,7 +31660,7 @@ export type operations = {
|
|||
/** @description OK (with results) */
|
||||
200: {
|
||||
content: {
|
||||
'application/json': components['schemas']['UserDetailed'][];
|
||||
'application/json': components['schemas']['User'][];
|
||||
};
|
||||
};
|
||||
/** @description Client error */
|
||||
|
@ -32158,6 +32176,8 @@ export type operations = {
|
|||
userId: string;
|
||||
/** @default 10 */
|
||||
limit?: number;
|
||||
/** @default true */
|
||||
detail?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -32166,7 +32186,7 @@ export type operations = {
|
|||
200: {
|
||||
content: {
|
||||
'application/json': {
|
||||
user: components['schemas']['UserDetailed'];
|
||||
user: components['schemas']['User'];
|
||||
weight: number;
|
||||
}[];
|
||||
};
|
||||
|
@ -33179,6 +33199,8 @@ export type operations = {
|
|||
limit?: number;
|
||||
/** @default 0 */
|
||||
offset?: number;
|
||||
/** @default true */
|
||||
detail?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -33186,7 +33208,7 @@ export type operations = {
|
|||
/** @description OK (with results) */
|
||||
200: {
|
||||
content: {
|
||||
'application/json': components['schemas']['UserDetailed'][];
|
||||
'application/json': components['schemas']['User'][];
|
||||
};
|
||||
};
|
||||
/** @description Client error */
|
||||
|
@ -33521,6 +33543,8 @@ export type operations = {
|
|||
username?: string;
|
||||
/** @description The local host is represented with `null`. */
|
||||
host?: string | null;
|
||||
/** @default true */
|
||||
detail?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -33528,7 +33552,7 @@ export type operations = {
|
|||
/** @description OK (with results) */
|
||||
200: {
|
||||
content: {
|
||||
'application/json': components['schemas']['UserDetailed'] | components['schemas']['UserDetailed'][];
|
||||
'application/json': components['schemas']['User'] | components['schemas']['User'][];
|
||||
};
|
||||
};
|
||||
/** @description Client error */
|
||||
|
|
Loading…
Add table
Reference in a new issue