subscribe to profiles
This commit is contained in:
@@ -29,9 +29,7 @@ postDB = (DB)=>{
|
||||
const id = DB.ObjectID(postid);
|
||||
let update = {
|
||||
$unset:{
|
||||
reactions:{
|
||||
[userid]: {}
|
||||
}
|
||||
["reactions." + profileid]: ""
|
||||
},
|
||||
$set: {
|
||||
lastUpdated: new Date()
|
||||
|
||||
@@ -13,7 +13,7 @@ userDB = (DB) => {
|
||||
}
|
||||
|
||||
DB.getProfile = async (profileId) => {
|
||||
if (userProfileCache[profileId]) return userProfileCache[profileId];
|
||||
//if (userProfileCache[profileId]) return userProfileCache[profileId];
|
||||
const _id = DB.ObjectID(profileId);
|
||||
let r = await DB.profileCols.findOne({ _id }).catch((err) => {
|
||||
console.log(err);
|
||||
@@ -68,6 +68,31 @@ userDB = (DB) => {
|
||||
return r;
|
||||
}
|
||||
|
||||
DB.subscribeToGroup = async (profileid, groupid) => {
|
||||
const _id = DB.ObjectID(groupid);
|
||||
let update = {
|
||||
$set:{
|
||||
["subscribed." + profileid]: new Date()
|
||||
}
|
||||
}
|
||||
return DB.profileCols.updateOne({_id}, update).catch((err)=>{
|
||||
console.log(err);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
DB.unsubscribeToGroup = async (profileid, groupid) => {
|
||||
const _id = DB.ObjectID(groupid);
|
||||
let update = {
|
||||
$unset:{
|
||||
["subscribed." + profileid]: "",
|
||||
}
|
||||
}
|
||||
return DB.profileCols.updateOne({_id}, update).catch((err)=>{
|
||||
console.log(err);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user