2019-02-07 06:59:18 -06:00
|
|
|
import $ from 'cafy';
|
|
|
|
import define from '../../../define';
|
|
|
|
import deleteFollowing from '../../../../../services/following/delete';
|
2019-04-07 07:50:36 -05:00
|
|
|
import { Followings, Users } from '../../../../../models';
|
2019-04-12 11:43:22 -05:00
|
|
|
import { ensure } from '../../../../../prelude/ensure';
|
2019-02-07 06:59:18 -06:00
|
|
|
|
|
|
|
export const meta = {
|
2019-02-22 20:20:58 -06:00
|
|
|
tags: ['admin'],
|
|
|
|
|
2019-02-07 06:59:18 -06:00
|
|
|
requireCredential: true,
|
|
|
|
requireModerator: true,
|
|
|
|
|
|
|
|
params: {
|
|
|
|
host: {
|
|
|
|
validator: $.str
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-21 20:46:58 -06:00
|
|
|
export default define(meta, async (ps, me) => {
|
2019-04-07 07:50:36 -05:00
|
|
|
const followings = await Followings.find({
|
|
|
|
followerHost: ps.host
|
2019-02-07 06:59:18 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
const pairs = await Promise.all(followings.map(f => Promise.all([
|
2019-04-12 11:43:22 -05:00
|
|
|
Users.findOne(f.followerId).then(ensure),
|
|
|
|
Users.findOne(f.followeeId).then(ensure)
|
2019-02-07 06:59:18 -06:00
|
|
|
])));
|
|
|
|
|
|
|
|
for (const pair of pairs) {
|
|
|
|
deleteFollowing(pair[0], pair[1]);
|
|
|
|
}
|
2019-02-21 20:46:58 -06:00
|
|
|
});
|