new version Visualizzazione Service

This commit is contained in:
Surya Paolo
2023-04-04 15:26:56 +02:00
parent 6d1ad4132f
commit 8a77dabc22
8 changed files with 198 additions and 63 deletions

View File

@@ -449,7 +449,21 @@ const UserSchema = new mongoose.Schema({
},
noFoto: {
type: Boolean,
}
},
bookmark: [
{
_id: false,
id: { type: String },
tab: { type: Number },
},
],
favorite: [
{
_id: false,
id: { type: String },
tab: { type: Number },
},
],
},
});
@@ -1882,6 +1896,33 @@ UserSchema.statics.removeReqFriend = async function (
{ $pull: { 'profile.req_friends': { username: { $in: [usernameDest] } } } });
};
// Rimuovo il Favorite
UserSchema.statics.removeFavorite = async function (
idapp, id, tab) {
return await User.updateOne({ idapp, username },
{ $pull: { 'profile.favorite': { id: { $in: [id] }, tab } } });
};
// Aggiungo il Favorite
UserSchema.statics.addFavorite = async function (
idapp, username, id, tab) {
return await User.updateOne({ idapp, username },
{ $push: { 'profile.favorite': { id, tab } } });
};
// Rimuovo il Bookmark
UserSchema.statics.removeBookmark = async function (
idapp, id, tab) {
return await User.updateOne({ idapp, username },
{ $pull: { 'profile.bookmark': { id: { $in: [id] }, tab } } });
};
// Aggiungo il Bookmark
UserSchema.statics.addBookmark = async function (
idapp, username, id, tab) {
return await User.updateOne({ idapp, username },
{ $push: { 'profile.bookmark': { id, tab } } });
};
UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, usernameDest, cmd, value, disablenotif) {
const { SendNotif } = require('../models/sendnotif');