aggiunto "Seen"
This commit is contained in:
@@ -282,6 +282,7 @@ let aggregation = [
|
|||||||
username_who_report: 1,
|
username_who_report: 1,
|
||||||
myfav: 1,
|
myfav: 1,
|
||||||
mybook: 1,
|
mybook: 1,
|
||||||
|
myseen: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -452,6 +452,13 @@ const UserSchema = new mongoose.Schema({
|
|||||||
noFoto: {
|
noFoto: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
|
seen: [
|
||||||
|
{
|
||||||
|
_id: false,
|
||||||
|
id: { type: String },
|
||||||
|
tab: { type: Number },
|
||||||
|
},
|
||||||
|
],
|
||||||
bookmark: [
|
bookmark: [
|
||||||
{
|
{
|
||||||
_id: false,
|
_id: false,
|
||||||
@@ -1607,6 +1614,7 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
'profile.favorite': 1,
|
'profile.favorite': 1,
|
||||||
'profile.bookmark': 1,
|
'profile.bookmark': 1,
|
||||||
|
'profile.seen': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'useraport.username': 1,
|
'useraport.username': 1,
|
||||||
@@ -1653,6 +1661,7 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
'profile.favorite': 1,
|
'profile.favorite': 1,
|
||||||
'profile.bookmark': 1,
|
'profile.bookmark': 1,
|
||||||
|
'profile.seen': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'useraport.username': 1,
|
'useraport.username': 1,
|
||||||
@@ -1700,6 +1709,7 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
'profile.favorite': 1,
|
'profile.favorite': 1,
|
||||||
'profile.bookmark': 1,
|
'profile.bookmark': 1,
|
||||||
|
'profile.seen': 1,
|
||||||
'mycities': 1,
|
'mycities': 1,
|
||||||
'comune': 1,
|
'comune': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
@@ -1946,6 +1956,12 @@ UserSchema.statics.addBookmark = async function (
|
|||||||
return await User.updateOne({ idapp, username },
|
return await User.updateOne({ idapp, username },
|
||||||
{ $push: { 'profile.bookmark': { id, tab } } });
|
{ $push: { 'profile.bookmark': { id, tab } } });
|
||||||
};
|
};
|
||||||
|
// Aggiungo il Bookmark
|
||||||
|
UserSchema.statics.addSeen = async function (
|
||||||
|
idapp, username, id, tab) {
|
||||||
|
return await User.updateOne({ idapp, username },
|
||||||
|
{ $push: { 'profile.seen': { id, tab } } });
|
||||||
|
};
|
||||||
|
|
||||||
UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, usernameDest, cmd, value, disablenotif) {
|
UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, usernameDest, cmd, value, disablenotif) {
|
||||||
|
|
||||||
@@ -2800,6 +2816,7 @@ function getWhatToShow(idapp, username) {
|
|||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.favorite': 1,
|
'profile.favorite': 1,
|
||||||
'profile.bookmark': 1,
|
'profile.bookmark': 1,
|
||||||
|
'profile.seen': 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2825,6 +2842,7 @@ function getWhatToShow_Unknown(idapp, username) {
|
|||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
'profile.favorite': 1,
|
'profile.favorite': 1,
|
||||||
'profile.bookmark': 1,
|
'profile.bookmark': 1,
|
||||||
|
'profile.seen': 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2853,6 +2871,7 @@ UserSchema.statics.getWhatToShow_IfFriends = async function (idapp, username) {
|
|||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
'profile.favorite': 1,
|
'profile.favorite': 1,
|
||||||
'profile.bookmark': 1,
|
'profile.bookmark': 1,
|
||||||
|
'profile.seen': 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1568,6 +1568,11 @@ router.post('/cmd', authenticate, async (req, res) => {
|
|||||||
else
|
else
|
||||||
ris = await User.removeBookmark(idapp, username, id, tab);
|
ris = await User.removeBookmark(idapp, username, id, tab);
|
||||||
}
|
}
|
||||||
|
} else if (cmd === shared_consts.CMD_USER.SET_SEEN) {
|
||||||
|
if (tab) {
|
||||||
|
if (value)
|
||||||
|
ris = await User.addSeen(idapp, username, id, tab);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let state = (value && ris && ris.ok === 1) ? 1 : ((!value && ris && ris.ok === 1) ? -1 : 0);
|
let state = (value && ris && ris.ok === 1) ? 1 : ((!value && ris && ris.ok === 1) ? -1 : 0);
|
||||||
|
|||||||
@@ -1980,11 +1980,44 @@ module.exports = {
|
|||||||
as: 'mybook',
|
as: 'mybook',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "users",
|
||||||
|
let: {
|
||||||
|
tab: numtab,
|
||||||
|
id: '$_id',
|
||||||
|
},
|
||||||
|
pipeline: [
|
||||||
|
{
|
||||||
|
$unwind: '$profile.seen',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
$expr: {
|
||||||
|
$and: [
|
||||||
|
{ $eq: ['$profile.seen.id', '$$id'] },
|
||||||
|
{ $eq: ['$profile.seen.tab', '$$tab'] },
|
||||||
|
{ $eq: ['$idapp', idapp] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
username: 1, name: 1, surname: 1, 'profile.resid_province': 1, 'profile.img': 1,
|
||||||
|
'profile.qualifica': 1,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
as: 'myseen',
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
proj = {
|
proj = {
|
||||||
myfav: 1,
|
myfav: 1,
|
||||||
mybook: 1,
|
mybook: 1,
|
||||||
|
myseen: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
return { query, proj };
|
return { query, proj };
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ module.exports = {
|
|||||||
CMD_USER: {
|
CMD_USER: {
|
||||||
SET_FAVORITE: 1,
|
SET_FAVORITE: 1,
|
||||||
SET_BOOKMARK: 2,
|
SET_BOOKMARK: 2,
|
||||||
|
SET_SEEN: 3,
|
||||||
},
|
},
|
||||||
|
|
||||||
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps', 'myskills', 'mygoods'],
|
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps', 'myskills', 'mygoods'],
|
||||||
@@ -579,6 +580,7 @@ module.exports = {
|
|||||||
'profile.username_telegram': 1,
|
'profile.username_telegram': 1,
|
||||||
'profile.favorite': 1,
|
'profile.favorite': 1,
|
||||||
'profile.bookmark': 1,
|
'profile.bookmark': 1,
|
||||||
|
'profile.seen': 1,
|
||||||
reported: 1,
|
reported: 1,
|
||||||
date_report: 1,
|
date_report: 1,
|
||||||
username_who_report: 1,
|
username_who_report: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user