2018-11-23 01:01:14 +02:00
|
|
|
import $ from 'cafy';
|
2021-08-19 15:55:45 +03:00
|
|
|
import { ID } from '@/misc/cafy-id';
|
|
|
|
import define from '../../define';
|
|
|
|
import { Users } from '@/models/index';
|
2018-11-23 01:01:14 +02:00
|
|
|
|
|
|
|
export const meta = {
|
2019-02-23 04:20:58 +02:00
|
|
|
tags: ['admin'],
|
|
|
|
|
2022-01-18 15:27:10 +02:00
|
|
|
requireCredential: true,
|
2018-11-23 01:01:14 +02:00
|
|
|
requireModerator: true,
|
|
|
|
|
|
|
|
params: {
|
|
|
|
userId: {
|
|
|
|
validator: $.type(ID),
|
|
|
|
},
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
res: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'object',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
properties: {
|
|
|
|
id: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: false, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
format: 'id',
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
createdAt: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: false, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
format: 'date-time',
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
updatedAt: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
format: 'date-time',
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
lastFetchedAt: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
username: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
name: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
folowersCount: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'number',
|
|
|
|
nullable: false, optional: true,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
followingCount: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'number',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
notesCount: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'number',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
avatarId: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
bannerId: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
tags: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'array',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
items: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: false, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
},
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
avatarUrl: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
format: 'url',
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
bannerUrl: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
format: 'url',
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
avatarBlurhash: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'any',
|
|
|
|
nullable: true, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
default: null,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
bannerBlurhash: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'any',
|
|
|
|
nullable: true, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
default: null,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
isSuspended: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'boolean',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
isSilenced: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'boolean',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
isLocked: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'boolean',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
isBot: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'boolean',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
isCat: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'boolean',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
isAdmin: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'boolean',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
isModerator: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'boolean',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
emojis: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'array',
|
|
|
|
nullable: false, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
items: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: false, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
},
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
host: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
inbox: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
sharedInbox: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
featured: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
uri: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
token: {
|
2022-01-18 15:27:10 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true, optional: false,
|
2021-12-09 16:58:30 +02:00
|
|
|
default: '<MASKED>',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-01-18 15:27:10 +02:00
|
|
|
} as const;
|
2018-11-23 01:01:14 +02:00
|
|
|
|
2022-01-02 19:12:50 +02:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2019-02-22 04:46:58 +02:00
|
|
|
export default define(meta, async (ps, me) => {
|
2019-04-07 15:50:36 +03:00
|
|
|
const user = await Users.findOne(ps.userId as string);
|
2018-11-23 01:01:14 +02:00
|
|
|
|
|
|
|
if (user == null) {
|
2019-02-22 04:46:58 +02:00
|
|
|
throw new Error('user not found');
|
2018-11-23 01:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-02-18 10:53:56 +02:00
|
|
|
if ((me.isModerator && !me.isAdmin) && user.isAdmin) {
|
2019-02-22 04:46:58 +02:00
|
|
|
throw new Error('cannot show info of admin');
|
2018-11-23 01:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-08-09 19:32:27 +03:00
|
|
|
return {
|
|
|
|
...user,
|
|
|
|
token: user.token != null ? '<MASKED>' : user.token,
|
|
|
|
};
|
2019-02-22 04:46:58 +02:00
|
|
|
});
|