This commit is contained in:
syuilo
2018-07-11 14:03:21 +09:00
parent 8ef066adda
commit 1af3c42001
5 changed files with 235 additions and 8 deletions

View File

@@ -23,12 +23,16 @@ export const getFriendIds = async (me: mongodb.ObjectID, includeMe = true) => {
return myfollowingIds;
};
export const getFriends = async (me: mongodb.ObjectID, includeMe = true) => {
export const getFriends = async (me: mongodb.ObjectID, includeMe = true, remoteOnly = false) => {
const q: any = remoteOnly ? {
followerId: me,
'_followee.host': { $ne: null }
} : {
followerId: me
};
// Fetch relation to other users who the I follows
const followings = await Following
.find({
followerId: me
});
.find(q);
// ID list of other users who the I follows
const myfollowings = followings.map(following => ({