2019-02-05 04:48:08 +02:00
|
|
|
import $ from 'cafy';
|
2021-03-23 10:43:07 +02:00
|
|
|
import { ID } from '@/misc/cafy-id';
|
2018-11-02 06:47:44 +02:00
|
|
|
import define from '../../define';
|
2019-04-07 15:50:36 +03:00
|
|
|
import { Blockings } from '../../../../models';
|
|
|
|
import { makePaginationQuery } from '../../common/make-pagination-query';
|
2018-10-30 21:59:01 +02:00
|
|
|
|
|
|
|
export const meta = {
|
2020-04-03 16:42:29 +03:00
|
|
|
tags: ['account'],
|
2019-02-23 04:20:58 +02:00
|
|
|
|
2020-02-15 14:33:32 +02:00
|
|
|
requireCredential: true as const,
|
2018-10-30 21:59:01 +02:00
|
|
|
|
2019-04-07 15:50:36 +03:00
|
|
|
kind: 'read:blocks',
|
2018-10-31 04:16:13 +02:00
|
|
|
|
|
|
|
params: {
|
2018-11-01 20:32:24 +02:00
|
|
|
limit: {
|
2019-02-13 09:33:07 +02:00
|
|
|
validator: $.optional.num.range(1, 100),
|
2018-10-31 04:16:13 +02:00
|
|
|
default: 30
|
2018-11-01 20:32:24 +02:00
|
|
|
},
|
2018-10-31 04:16:13 +02:00
|
|
|
|
2018-11-01 20:32:24 +02:00
|
|
|
sinceId: {
|
2019-02-13 09:33:07 +02:00
|
|
|
validator: $.optional.type(ID),
|
2018-11-01 20:32:24 +02:00
|
|
|
},
|
2018-10-31 04:16:13 +02:00
|
|
|
|
2018-11-01 20:32:24 +02:00
|
|
|
untilId: {
|
2019-02-13 09:33:07 +02:00
|
|
|
validator: $.optional.type(ID),
|
2018-11-01 20:32:24 +02:00
|
|
|
},
|
2019-02-24 12:42:26 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
res: {
|
2019-06-27 12:04:09 +03:00
|
|
|
type: 'array' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
2019-02-24 12:42:26 +02:00
|
|
|
items: {
|
2019-06-27 12:04:09 +03:00
|
|
|
type: 'object' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
2019-04-23 16:35:26 +03:00
|
|
|
ref: 'Blocking',
|
2019-02-24 12:42:26 +02:00
|
|
|
}
|
|
|
|
},
|
2018-10-30 21:59:01 +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 query = makePaginationQuery(Blockings.createQueryBuilder('blocking'), ps.sinceId, ps.untilId)
|
|
|
|
.andWhere(`blocking.blockerId = :meId`, { meId: me.id });
|
2018-10-30 21:59:01 +02:00
|
|
|
|
2019-04-07 15:50:36 +03:00
|
|
|
const blockings = await query
|
2019-04-12 19:43:22 +03:00
|
|
|
.take(ps.limit!)
|
2019-04-07 15:50:36 +03:00
|
|
|
.getMany();
|
2018-10-31 04:16:13 +02:00
|
|
|
|
2019-04-07 15:50:36 +03:00
|
|
|
return await Blockings.packMany(blockings, me);
|
2019-02-22 04:46:58 +02:00
|
|
|
});
|