feed with followers only

This commit is contained in:
Adolfo Reyna
2021-09-02 12:02:09 -07:00
parent fa0d6ee199
commit 9a302a87de
4 changed files with 70 additions and 2 deletions

View File

@@ -45,6 +45,32 @@ userDB = (DB) => {
return r[index];
}
DB.followProfile = async (profileId, followProfileId)=>{
const _id = DB.ObjectID(profileId);
let update = {
$addToSet:{
following: followProfileId
}
}
return DB.profileCols.updateOne({_id}, update).catch((err)=>{
console.log(err);
return false;
});
}
DB.unfollowProfile = async (profileId, followProfileId)=>{
const _id = DB.ObjectID(profileId);
let update = {
$pull:{
following: followProfileId
}
}
return DB.profileCols.updateOne({_id}, update).catch((err)=>{
console.log(err);
return false;
});
}
//Groups
DB.getGroups = async () => {
let r = await DB.profileCols.find({isGroup: true})
@@ -75,6 +101,7 @@ userDB = (DB) => {
["subscribed." + profileid]: new Date()
}
}
DB.followProfile(profileid, groupid)
return DB.profileCols.updateOne({_id}, update).catch((err)=>{
console.log(err);
return false;
@@ -88,6 +115,7 @@ userDB = (DB) => {
["subscribed." + profileid]: "",
}
}
DB.unfollowProfile(profileid, groupid)
return DB.profileCols.updateOne({_id}, update).catch((err)=>{
console.log(err);
return false;