2019-02-05 11:48:08 +09:00
|
|
|
import $ from 'cafy';
|
2021-08-19 18:33:41 +09:00
|
|
|
import define from '../../define.js';
|
|
|
|
import { ID } from '@/misc/cafy-id.js';
|
|
|
|
import { Users } from '@/models/index.js';
|
2018-11-01 00:11:21 +09:00
|
|
|
|
|
|
|
export const meta = {
|
2019-02-23 11:20:58 +09:00
|
|
|
tags: ['users'],
|
|
|
|
|
2020-02-15 21:33:32 +09:00
|
|
|
requireCredential: true as const,
|
2018-11-01 00:11:52 +09:00
|
|
|
|
2018-11-01 00:11:21 +09:00
|
|
|
params: {
|
2018-11-02 03:32:24 +09:00
|
|
|
userId: {
|
2019-02-23 11:20:58 +09:00
|
|
|
validator: $.either($.type(ID), $.arr($.type(ID)).unique()),
|
2018-11-02 03:32:24 +09:00
|
|
|
}
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
res: {
|
|
|
|
oneOf: [
|
|
|
|
{
|
|
|
|
type: 'object' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: 'string' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
|
|
|
format: 'id'
|
|
|
|
},
|
|
|
|
isFollowing: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
hasPendingFollowRequestFromYou: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
hasPendingFollowRequestToYou: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
isFollowed: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
isBlocking: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
isBlocked: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
isMuted: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'array' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
|
|
|
items: {
|
|
|
|
type: 'object' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: 'string' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
|
|
|
format: 'id'
|
|
|
|
},
|
|
|
|
isFollowing: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
hasPendingFollowRequestFromYou: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
hasPendingFollowRequestToYou: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
isFollowed: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
isBlocking: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
isBlocked: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
},
|
|
|
|
isMuted: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
optional: false as const, nullable: false as const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2018-11-01 00:11:21 +09:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-22 11:46:58 +09:00
|
|
|
export default define(meta, 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];
|
|
|
|
});
|