merge: upstream
This commit is contained in:
commit
11628e4b6a
285 changed files with 3413 additions and 1913 deletions
|
|
@ -62,17 +62,17 @@ export const meta = {
|
|||
reporter: {
|
||||
type: 'object',
|
||||
nullable: false, optional: false,
|
||||
ref: 'User',
|
||||
ref: 'UserDetailedNotMe',
|
||||
},
|
||||
targetUser: {
|
||||
type: 'object',
|
||||
nullable: false, optional: false,
|
||||
ref: 'User',
|
||||
ref: 'UserDetailedNotMe',
|
||||
},
|
||||
assignee: {
|
||||
type: 'object',
|
||||
nullable: true, optional: true,
|
||||
ref: 'User',
|
||||
ref: 'UserDetailedNotMe',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { SignupService } from '@/core/SignupService.js';
|
|||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { localUsernameSchema, passwordSchema } from '@/models/User.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { Packed } from '@/misc/json-schema.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
|
@ -18,7 +19,7 @@ export const meta = {
|
|||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'User',
|
||||
ref: 'MeDetailed',
|
||||
properties: {
|
||||
token: {
|
||||
type: 'string',
|
||||
|
|
@ -60,11 +61,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
});
|
||||
|
||||
const res = await this.userEntityService.pack(account, account, {
|
||||
detail: true,
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: true,
|
||||
});
|
||||
}) as Packed<'MeDetailed'> & { token: string };
|
||||
|
||||
(res as any).token = secret;
|
||||
res.token = secret;
|
||||
|
||||
return res;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export const meta = {
|
|||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'User',
|
||||
ref: 'UserDetailedNotMe',
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
const res = await this.userEntityService.pack(profile.user!, null, {
|
||||
detail: true,
|
||||
schema: 'UserDetailedNotMe',
|
||||
});
|
||||
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ export const meta = {
|
|||
},
|
||||
required: ['id', 'createdAt', 'user'],
|
||||
},
|
||||
}
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
|
|
@ -92,7 +92,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
return await Promise.all(assigns.map(async assign => ({
|
||||
id: assign.id,
|
||||
createdAt: this.idService.parse(assign.id).date.toISOString(),
|
||||
user: await this.userEntityService.pack(assign.user!, me, { detail: true }),
|
||||
user: await this.userEntityService.pack(assign.user!, me, { schema: 'UserDetailed' }),
|
||||
expiresAt: assign.expiresAt?.toISOString() ?? null,
|
||||
})));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export const meta = {
|
|||
user: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'UserDetailed',
|
||||
ref: 'UserDetailedNotMe',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
const users = await query.getMany();
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { detail: true });
|
||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (user != null) {
|
||||
return {
|
||||
type: 'User',
|
||||
object: await this.userEntityService.pack(user, me, { detail: true }),
|
||||
object: await this.userEntityService.pack(user, me, { schema: 'UserDetailedNotMe' }),
|
||||
};
|
||||
} else if (note != null) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
return {
|
||||
accessToken: accessToken.token,
|
||||
user: await this.userEntityService.pack(session.userId, null, {
|
||||
detail: true,
|
||||
schema: 'UserDetailedNotMe',
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
await this.userBlockingService.block(blocker, blockee);
|
||||
|
||||
return await this.userEntityService.pack(blockee.id, blocker, {
|
||||
detail: true,
|
||||
schema: 'UserDetailedNotMe',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
await this.userBlockingService.unblock(blocker, blockee);
|
||||
|
||||
return await this.userEntityService.pack(blockee.id, blocker, {
|
||||
detail: true,
|
||||
schema: 'UserDetailedNotMe',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
relations: ['user'],
|
||||
});
|
||||
|
||||
const users = await this.userEntityService.packMany(records.map(r => r.user!), null, { detail: false });
|
||||
const users = await this.userEntityService.packMany(records.map(r => r.user!), null);
|
||||
|
||||
return records.map(r => ({
|
||||
id: r.id,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
.limit(ps.limit)
|
||||
.getMany();
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { detail: true });
|
||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailedNotMe' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
const users = await query.limit(ps.limit).getMany();
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { detail: true });
|
||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
userProfile.loggedInDates = [...userProfile.loggedInDates, today];
|
||||
}
|
||||
|
||||
return await this.userEntityService.pack<true, true>(userProfile.user!, userProfile.user!, {
|
||||
detail: true,
|
||||
return await this.userEntityService.pack(userProfile.user!, userProfile.user!, {
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: isSecure,
|
||||
userProfile,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
// Publish meUpdated event
|
||||
this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, {
|
||||
detail: true,
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: true,
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
|
||||
// Publish meUpdated event
|
||||
this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, {
|
||||
detail: true,
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: true,
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
// Publish meUpdated event
|
||||
this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, {
|
||||
detail: true,
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: true,
|
||||
}));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
// Publish meUpdated event
|
||||
this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, {
|
||||
detail: true,
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: true,
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
// Publish meUpdated event
|
||||
this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, {
|
||||
detail: true,
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: true,
|
||||
}));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
// Publish meUpdated event
|
||||
this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, {
|
||||
detail: true,
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: true,
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
throw err;
|
||||
});
|
||||
|
||||
return await this.userEntityService.pack<true, true>(me.id, me, {
|
||||
detail: true,
|
||||
return await this.userEntityService.pack(me.id, me, {
|
||||
schema: 'MeDetailed',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
throw err;
|
||||
});
|
||||
|
||||
return await this.userEntityService.pack<true, true>(me.id, me, {
|
||||
detail: true,
|
||||
return await this.userEntityService.pack(me.id, me, {
|
||||
schema: 'MeDetailed',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export const meta = {
|
|||
|
||||
res: {
|
||||
type: 'object',
|
||||
ref: 'UserDetailed',
|
||||
ref: 'MeDetailed',
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
});
|
||||
|
||||
const iObj = await this.userEntityService.pack(me.id, me, {
|
||||
detail: true,
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -478,8 +478,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
verifiedLinks: [],
|
||||
});
|
||||
|
||||
const iObj = await this.userEntityService.pack<true, true>(user.id, user, {
|
||||
detail: true,
|
||||
const iObj = await this.userEntityService.pack(user.id, user, {
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: isSecure,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -314,6 +314,11 @@ export const meta = {
|
|||
type: 'string',
|
||||
optional: false, nullable: true,
|
||||
},
|
||||
policies: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'RolePolicies',
|
||||
},
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
var: ps.var,
|
||||
userId: me.id,
|
||||
user: await this.userEntityService.pack(me.id, { id: page.userId }, {
|
||||
detail: true,
|
||||
schema: 'UserDetailed',
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -52,7 +52,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) as MiUser[], me, { detail: true });
|
||||
return await this.userEntityService.packMany(users.filter(x => x !== null) as MiUser[], me, { schema: 'UserDetailed' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,32 @@ export const meta = {
|
|||
requireCredential: false,
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
users: {
|
||||
type: 'number',
|
||||
},
|
||||
data: {
|
||||
type: 'object',
|
||||
additionalProperties: {
|
||||
anyOf: [{
|
||||
type: 'number',
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
required: [
|
||||
'createdAt',
|
||||
'users',
|
||||
'data',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
allowGet: true,
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ export const meta = {
|
|||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
format: 'misskey:id'
|
||||
format: 'misskey:id',
|
||||
},
|
||||
user: {
|
||||
type: 'object',
|
||||
ref: 'User'
|
||||
ref: 'UserDetailed',
|
||||
},
|
||||
},
|
||||
required: ['id', 'user'],
|
||||
|
|
@ -94,7 +94,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
return await Promise.all(assigns.map(async assign => ({
|
||||
id: assign.id,
|
||||
user: await this.userEntityService.pack(assign.user!, me, { detail: true }),
|
||||
user: await this.userEntityService.pack(assign.user!, me, { schema: 'UserDetailed' }),
|
||||
})));
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
const users = await query.getMany();
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { detail: true });
|
||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
// Make replies object (includes weights)
|
||||
const repliesObj = await Promise.all(topRepliedUsers.map(async (user) => ({
|
||||
user: await this.userEntityService.pack(user, me, { detail: true }),
|
||||
user: await this.userEntityService.pack(user, me, { schema: 'UserDetailed' }),
|
||||
weight: repliedUsers[user] / peak,
|
||||
})));
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export const meta = {
|
|||
},
|
||||
user: {
|
||||
type: 'object',
|
||||
ref: 'User',
|
||||
ref: 'UserLite',
|
||||
},
|
||||
withReplies: {
|
||||
type: 'boolean',
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
|||
import { QueryService } from '@/core/QueryService.js';
|
||||
import { NoteReactionEntityService } from '@/core/entities/NoteReactionEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { CacheService } from '@/core/CacheService.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
|
||||
export const meta = {
|
||||
|
|
@ -34,6 +37,11 @@ export const meta = {
|
|||
code: 'REACTIONS_NOT_PUBLIC',
|
||||
id: '673a7dd2-6924-1093-e0c0-e68456ceae5c',
|
||||
},
|
||||
isRemoteUser: {
|
||||
message: 'Currently unavailable to display reactions of remote users. See https://github.com/misskey-dev/misskey/issues/12964',
|
||||
code: 'IS_REMOTE_USER',
|
||||
id: '6b95fa98-8cf9-2350-e284-f0ffdb54a805',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
|
@ -59,14 +67,24 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
@Inject(DI.noteReactionsRepository)
|
||||
private noteReactionsRepository: NoteReactionsRepository,
|
||||
|
||||
private cacheService: CacheService,
|
||||
private userEntityService: UserEntityService,
|
||||
private noteReactionEntityService: NoteReactionEntityService,
|
||||
private queryService: QueryService,
|
||||
private roleService: RoleService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: ps.userId });
|
||||
const iAmModerator = me ? await this.roleService.isModerator(me) : false; // Moderators can see reactions of all users
|
||||
if (!iAmModerator) {
|
||||
const user = await this.cacheService.findUserById(ps.userId);
|
||||
if (this.userEntityService.isRemoteUser(user)) {
|
||||
throw new ApiError(meta.errors.isRemoteUser);
|
||||
}
|
||||
|
||||
if ((me == null || me.id !== ps.userId) && !profile.publicReactions) {
|
||||
throw new ApiError(meta.errors.reactionsNotPublic);
|
||||
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: ps.userId });
|
||||
if ((me == null || me.id !== ps.userId) && !profile.publicReactions) {
|
||||
throw new ApiError(meta.errors.reactionsNotPublic);
|
||||
}
|
||||
}
|
||||
|
||||
const query = this.queryService.makePaginationQuery(this.noteReactionsRepository.createQueryBuilder('reaction'),
|
||||
|
|
|
|||
|
|
@ -76,7 +76,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, { detail: true });
|
||||
return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
.getMany();
|
||||
}
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { detail: !!ps.detail });
|
||||
return await this.userEntityService.packMany(users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
}
|
||||
|
||||
return await this.userEntityService.packMany(users, me, { detail: ps.detail });
|
||||
return await this.userEntityService.packMany(users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
return await Promise.all(_users.map(u => this.userEntityService.pack(u, me, {
|
||||
detail: true,
|
||||
schema: 'UserDetailed',
|
||||
})));
|
||||
} else {
|
||||
// Lookup user
|
||||
|
|
@ -146,7 +146,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
return await this.userEntityService.pack(user, me, {
|
||||
detail: true,
|
||||
schema: 'UserDetailed',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue