2018-11-23 01:01:14 +02:00
|
|
|
import $ from 'cafy';
|
2021-08-19 12:33:41 +03:00
|
|
|
import { ID } from '@/misc/cafy-id.js';
|
|
|
|
import define from '../../define.js';
|
|
|
|
import { Users } from '@/models/index.js';
|
2018-11-23 01:01:14 +02:00
|
|
|
|
|
|
|
export const meta = {
|
2019-02-23 04:20:58 +02:00
|
|
|
tags: ['admin'],
|
|
|
|
|
2020-02-15 14:33:32 +02:00
|
|
|
requireCredential: true as const,
|
2018-11-23 01:01:14 +02:00
|
|
|
requireModerator: true,
|
|
|
|
|
|
|
|
params: {
|
|
|
|
userId: {
|
|
|
|
validator: $.type(ID),
|
|
|
|
},
|
2021-03-06 15:34:11 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
res: {
|
|
|
|
type: 'object' as const,
|
|
|
|
nullable: false as const, optional: false as const,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: false as const, optional: false as const,
|
|
|
|
format: 'id'
|
|
|
|
},
|
|
|
|
createdAt: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: false as const, optional: false as const,
|
|
|
|
format: 'date-time'
|
|
|
|
},
|
|
|
|
updatedAt: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const,
|
|
|
|
format: 'date-time'
|
|
|
|
},
|
|
|
|
lastFetchedAt: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const
|
|
|
|
},
|
|
|
|
username: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
folowersCount: {
|
|
|
|
type: 'number' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
followingCount: {
|
|
|
|
type: 'number' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
notesCount: {
|
|
|
|
type: 'number' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
avatarId: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const
|
|
|
|
},
|
|
|
|
bannerId: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const
|
|
|
|
},
|
|
|
|
tags: {
|
|
|
|
type: 'array' as const,
|
|
|
|
nullable: false as const, optional: false as const,
|
|
|
|
items: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
}
|
|
|
|
},
|
|
|
|
avatarUrl: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const,
|
|
|
|
format: 'url'
|
|
|
|
},
|
|
|
|
bannerUrl: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const,
|
|
|
|
format: 'url'
|
|
|
|
},
|
|
|
|
avatarBlurhash: {
|
|
|
|
type: 'any' as const,
|
|
|
|
nullable: true as const, optional: false as const,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
bannerBlurhash: {
|
|
|
|
type: 'any' as const,
|
|
|
|
nullable: true as const, optional: false as const,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
isSuspended: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
isSilenced: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
isLocked: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
nullable: false as const, optional: false as const,
|
|
|
|
},
|
|
|
|
isBot: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
isCat: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
isAdmin: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
isModerator: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
},
|
|
|
|
emojis: {
|
|
|
|
type: 'array' as const,
|
|
|
|
nullable: false as const, optional: false as const,
|
|
|
|
items: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: false as const, optional: false as const
|
|
|
|
}
|
|
|
|
},
|
|
|
|
host: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const
|
|
|
|
},
|
|
|
|
inbox: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const
|
|
|
|
},
|
|
|
|
sharedInbox: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const
|
|
|
|
},
|
|
|
|
featured: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const
|
|
|
|
},
|
|
|
|
uri: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: true as const, optional: false as const
|
|
|
|
},
|
|
|
|
token: {
|
|
|
|
type: 'string' as const,
|
|
|
|
nullable: false as const, optional: false as const,
|
|
|
|
default: '<MASKED>'
|
|
|
|
}
|
|
|
|
}
|
2018-11-23 01:01:14 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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
|
|
|
});
|