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