1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-24 19:48:26 +09:00
misskey/src/api/common/get-friends.ts

26 lines
621 B
TypeScript
Raw Normal View History

2016-12-29 07:49:51 +09:00
import * as mongodb from 'mongodb';
import Following from '../models/following';
export default async (me: mongodb.ObjectID, includeMe: boolean = true) => {
// Fetch relation to other users who the I follows
// SELECT followee
const myfollowing = await Following
.find({
follower_id: me,
// 削除されたドキュメントは除く
deleted_at: { $exists: false }
}, {
followee_id: true
})
.toArray();
// ID list of other users who the I follows
const myfollowingIds = myfollowing.map(follow => follow.followee_id);
if (includeMe) {
myfollowingIds.push(me);
}
return myfollowingIds;
};