2021-08-19 21:55:45 +09:00
|
|
|
import define from '../../define';
|
|
|
|
import { Users } from '@/models/index';
|
2018-11-01 00:11:21 +09:00
|
|
|
|
|
|
|
export const meta = {
|
2019-02-23 11:20:58 +09:00
|
|
|
tags: ['users'],
|
|
|
|
|
2022-01-18 22:27:10 +09:00
|
|
|
requireCredential: true,
|
2018-11-01 00:11:52 +09:00
|
|
|
|
2021-03-06 22:34:11 +09:00
|
|
|
res: {
|
2022-01-18 22:27:10 +09:00
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
oneOf: [
|
|
|
|
{
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
2021-03-06 22:34:11 +09:00
|
|
|
properties: {
|
|
|
|
id: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 23:58:30 +09:00
|
|
|
format: 'id',
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isFollowing: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
hasPendingFollowRequestFromYou: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
hasPendingFollowRequestToYou: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isFollowed: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isBlocking: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isBlocked: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isMuted: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
|
|
|
},
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
{
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'array',
|
2021-03-06 22:34:11 +09:00
|
|
|
items: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
properties: {
|
|
|
|
id: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 23:58:30 +09:00
|
|
|
format: 'id',
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isFollowing: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
hasPendingFollowRequestFromYou: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
hasPendingFollowRequestToYou: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isFollowed: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isBlocking: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isBlocked: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
isMuted: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'boolean',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2022-01-18 22:27:10 +09:00
|
|
|
} as const;
|
2018-11-01 00:11:21 +09:00
|
|
|
|
2022-02-19 14:05:32 +09:00
|
|
|
const paramDef = {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
userId: {
|
|
|
|
anyOf: [
|
|
|
|
{ type: 'string', format: 'misskey:id' },
|
|
|
|
{
|
|
|
|
type: 'array',
|
|
|
|
items: { type: 'string', format: 'misskey:id' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ['userId'],
|
|
|
|
} as const;
|
|
|
|
|
2022-01-03 02:12:50 +09:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-02-19 14:05:32 +09:00
|
|
|
export default define(meta, paramDef, async (ps, me) => {
|
2018-11-01 00:11:21 +09:00
|
|
|
const ids = Array.isArray(ps.userId) ? ps.userId : [ps.userId];
|
|
|
|
|
2019-04-07 21:50:36 +09:00
|
|
|
const relations = await Promise.all(ids.map(id => Users.getRelation(me.id, id)));
|
2018-11-01 00:11:21 +09:00
|
|
|
|
2019-02-22 11:46:58 +09:00
|
|
|
return Array.isArray(ps.userId) ? relations : relations[0];
|
|
|
|
});
|