Introduce followed log and following log
This commit is contained in:
parent
7942f76acb
commit
319e905bf9
14 changed files with 101 additions and 117 deletions
|
|
@ -42,8 +42,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
// Check if already following
|
||||
const exist = await Following.findOne({
|
||||
followerId: follower._id,
|
||||
followeeId: followee._id,
|
||||
deletedAt: { $exists: false }
|
||||
followeeId: followee._id
|
||||
});
|
||||
|
||||
if (exist !== null) {
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
// Check not following
|
||||
const exist = await Following.findOne({
|
||||
followerId: follower._id,
|
||||
followeeId: followee._id,
|
||||
deletedAt: { $exists: false }
|
||||
followeeId: followee._id
|
||||
});
|
||||
|
||||
if (exist === null) {
|
||||
|
|
@ -51,12 +50,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
}
|
||||
|
||||
// Delete following
|
||||
await Following.update({
|
||||
await Following.findOneAndDelete({
|
||||
_id: exist._id
|
||||
}, {
|
||||
$set: {
|
||||
deletedAt: new Date()
|
||||
}
|
||||
});
|
||||
|
||||
// Send response
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue