- Gruppi (3) - lista degli utenti del gruppo
This commit is contained in:
@@ -50,6 +50,7 @@ const {StatusSkill} = require('../models/statusSkill');
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
const {Sector} = require('../models/sector');
|
||||
const {CatGrp} = require('../models/catgrp');
|
||||
const {Level} = require('../models/level');
|
||||
const Pickup = require('../models/pickup');
|
||||
const {Newstosent} = require('../models/newstosent');
|
||||
@@ -315,6 +316,8 @@ function getTableByTableName(tablename) {
|
||||
mytable = Province;
|
||||
else if (tablename === 'sectors')
|
||||
mytable = Sector;
|
||||
else if (tablename === 'catgrps')
|
||||
mytable = CatGrp;
|
||||
else if (tablename === 'levels')
|
||||
mytable = Level;
|
||||
else if (shared_consts.TablePickup.includes(tablename))
|
||||
@@ -351,7 +354,8 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_USER_ID.includes(params.table)) {
|
||||
mydata.userId = req.user._id;
|
||||
if (!mydata.userId)
|
||||
mydata.userId = req.user._id;
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_PERM_NEWREC.includes(params.table)) {
|
||||
@@ -360,20 +364,31 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (params.table === shared_consts.TAB_MYGROUPS) {
|
||||
if (shared_consts.MYGROUPS_KEY_TO_CRYPTED in mydata) {
|
||||
if (mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]) {
|
||||
mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED + shared_consts.SUFFIX_CRYPTED] = tools.cryptdata(mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_USER_INCLUDE_MY.includes(params.table)) {
|
||||
if (!mydata.admins) {
|
||||
mydata.admins = [];
|
||||
} else {
|
||||
const arrnew = [];
|
||||
/*const arrnew = [];
|
||||
for (const username of mydata.admins) {
|
||||
arrnew.push({username});
|
||||
}
|
||||
mydata.admins = arrnew;
|
||||
|
||||
*/
|
||||
}
|
||||
const indfind = mydata.admins.findIndex((rec) => (rec.username === req.user.username));
|
||||
|
||||
if (indfind < 0) {
|
||||
mydata.admins.push({_id: new ObjectID(), username: req.user.username});
|
||||
mydata.admins.push({username: req.user.username});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,7 +649,6 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
fieldsvalue.crypted = true;
|
||||
fieldsvalue.value_str = tools.cryptdata(fieldsvalue.value_str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (mydata.table === shared_consts.TAB_SITES) {
|
||||
@@ -1089,6 +1103,7 @@ function load(req, res, version) {
|
||||
let subSkills = SubSkill.findAllIdApp(idapp);
|
||||
let statusSkills = StatusSkill.findAllIdApp(idapp);
|
||||
let sectors = Sector.findAllIdApp(idapp);
|
||||
let catgrps = CatGrp.findAllIdApp(idapp);
|
||||
let cities = City.findAllIdApp(idapp);
|
||||
let cart = null;
|
||||
let orderscart = null;
|
||||
@@ -1145,7 +1160,9 @@ function load(req, res, version) {
|
||||
sectors,
|
||||
statusSkills,
|
||||
cities,
|
||||
myuserextra]).then((arrdata) => {
|
||||
myuserextra,
|
||||
catgrps,
|
||||
]).then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
let myuser = req.user;
|
||||
if (myuser) {
|
||||
@@ -1216,6 +1233,8 @@ function load(req, res, version) {
|
||||
sectors: arrdata[27],
|
||||
statusSkills: arrdata[28],
|
||||
cities: arrdata[29],
|
||||
// myuser arrdata[30]
|
||||
catgrps: arrdata[31],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1425,11 +1444,14 @@ function uploadFile(req, res, version) {
|
||||
const ris = await resizer(newname, setup_image_compress);
|
||||
|
||||
if (ris) {
|
||||
tools.delete(newname, false, () => {});
|
||||
if (tools.isFileExists(resized_img)) {
|
||||
tools.delete(newname, false, () => {});
|
||||
|
||||
tools.move(resized_img, newname, (err) => {
|
||||
|
||||
});
|
||||
tools.move(resized_img, newname, (err) => {
|
||||
if (err)
|
||||
console.error('err', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('newname', e);
|
||||
|
||||
@@ -5,34 +5,45 @@ const tools = require('../tools/general');
|
||||
|
||||
const server_constants = require('../tools/server_constants');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
const {authenticate} = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
|
||||
const { User } = require('../models/user');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
const {User} = require('../models/user');
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
|
||||
router.post('/load', authenticate, async (req, res) => {
|
||||
const idapp = req.body.idapp;
|
||||
const groupname = req.body.groupname;
|
||||
|
||||
try{
|
||||
data = await MyGroup.findOne({idapp, groupname}).lean();
|
||||
try {
|
||||
const whatshow = MyGroup.getWhatToShow(idapp, req.user.username);
|
||||
const data = await MyGroup.findOne({idapp, groupname}, whatshow).lean();
|
||||
|
||||
res.send(data);
|
||||
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
|
||||
|
||||
}catch (e) {
|
||||
console.error('Error in MyGroups');
|
||||
const users_in_group = await User.find(
|
||||
{
|
||||
idapp,
|
||||
'profile.mygroups': {
|
||||
$elemMatch: {groupname: {$eq: groupname}},
|
||||
}
|
||||
},
|
||||
whatshowUsers
|
||||
);
|
||||
|
||||
res.send({mygroup: data, users_in_group});
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error in MyGroups', e);
|
||||
return res.status(400).send(e);
|
||||
}
|
||||
|
||||
const ris = null
|
||||
|
||||
const ris = null;
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ var mongoose = require('mongoose').set('debug', false);
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const _ = require('lodash');
|
||||
const { MySkill } = require('../models/myskill');
|
||||
var { User } = require('../models/user');
|
||||
const {MySkill} = require('../models/myskill');
|
||||
var {User} = require('../models/user');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
|
||||
@@ -23,22 +23,27 @@ router.post('/page', authenticate, function(req, res, next) {
|
||||
let idSkill = req.body.idSkill;
|
||||
let idapp = req.body.idapp;
|
||||
|
||||
return MySkill.getMySkillByIdkill(idapp, idSkill).then((ris) => {
|
||||
return MySkill.getMySkillByIdkill(idapp, idSkill).
|
||||
then((ris) => {
|
||||
|
||||
if (ris) {
|
||||
res.send(ris);
|
||||
/*
|
||||
const userId = ris.userId;
|
||||
return User.getUsernameById(idapp, userId).then((username) =>
|
||||
{
|
||||
res.send({...ris, username});
|
||||
});
|
||||
*/
|
||||
if (ris) {
|
||||
res.send(ris);
|
||||
/*
|
||||
const userId = ris.userId;
|
||||
return User.getUsernameById(idapp, userId).then((username) =>
|
||||
{
|
||||
res.send({...ris, username});
|
||||
});
|
||||
*/
|
||||
|
||||
} else {
|
||||
res.status(400).send();
|
||||
}
|
||||
}).catch((e) => {
|
||||
console.error('Err', e);
|
||||
res.status(400).send(e);
|
||||
})
|
||||
|
||||
} else {
|
||||
res.status(400).send(e);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -549,7 +549,7 @@ router.post('/groups/cmd', authenticate, (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
return MyGroup.setGroupsCmd(idapp, usernameOrig, groupnameDest, cmd, value).then((ris) => {
|
||||
return User.setGroupsCmd(idapp, usernameOrig, groupnameDest, cmd, value).then((ris) => {
|
||||
res.send(ris);
|
||||
}).catch((e) => {
|
||||
tools.mylog('ERRORE IN groups/cmd: ' + e.message);
|
||||
|
||||
Reference in New Issue
Block a user