2019-02-04 19:48:08 -07:00
|
|
|
import $ from 'cafy';
|
2018-11-01 22:47:44 -06:00
|
|
|
import define from '../../define';
|
2019-04-07 06:50:36 -06:00
|
|
|
import { ID } from '../../../../misc/cafy-id';
|
|
|
|
import { Users } from '../../../../models';
|
2018-10-31 09:11:21 -06:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
desc: {
|
|
|
|
'ja-JP': 'ユーザー間のリレーションを取得します。'
|
|
|
|
},
|
|
|
|
|
2019-02-22 19:20:58 -07:00
|
|
|
tags: ['users'],
|
|
|
|
|
2020-02-15 05:33:32 -07:00
|
|
|
requireCredential: true as const,
|
2018-10-31 09:11:52 -06:00
|
|
|
|
2018-10-31 09:11:21 -06:00
|
|
|
params: {
|
2018-11-01 12:32:24 -06:00
|
|
|
userId: {
|
2019-02-22 19:20:58 -07:00
|
|
|
validator: $.either($.type(ID), $.arr($.type(ID)).unique()),
|
2018-10-31 09:11:21 -06:00
|
|
|
desc: {
|
|
|
|
'ja-JP': 'ユーザーID (配列でも可)'
|
|
|
|
}
|
2018-11-01 12:32:24 -06:00
|
|
|
}
|
2018-10-31 09:11:21 -06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-21 19:46:58 -07:00
|
|
|
export default define(meta, async (ps, me) => {
|
2018-10-31 09:11:21 -06:00
|
|
|
const ids = Array.isArray(ps.userId) ? ps.userId : [ps.userId];
|
|
|
|
|
2019-04-07 06:50:36 -06:00
|
|
|
const relations = await Promise.all(ids.map(id => Users.getRelation(me.id, id)));
|
2018-10-31 09:11:21 -06:00
|
|
|
|
2019-02-21 19:46:58 -07:00
|
|
|
return Array.isArray(ps.userId) ? relations : relations[0];
|
|
|
|
});
|