- Gruppi (3) - lista degli utenti del gruppo
This commit is contained in:
@@ -3,6 +3,8 @@ const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = 'F';
|
||||
|
||||
@@ -24,7 +26,7 @@ const MyGroupSchema = new Schema({
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
idSector: {
|
||||
idCatGrp: {
|
||||
type: Number,
|
||||
},
|
||||
userId: {
|
||||
@@ -52,12 +54,20 @@ const MyGroupSchema = new Schema({
|
||||
link_telegram: {
|
||||
type: String,
|
||||
},
|
||||
visibility: {
|
||||
type: Number,
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
visibility: [
|
||||
{
|
||||
type: Number,
|
||||
},
|
||||
],
|
||||
pwd_cryp: {
|
||||
type: String,
|
||||
},
|
||||
admins: [
|
||||
{
|
||||
_id: false,
|
||||
username: {type: String},
|
||||
date: {type: Date},
|
||||
},
|
||||
@@ -93,6 +103,14 @@ MyGroupSchema.statics.getFieldsForSearch = function() {
|
||||
|
||||
MyGroupSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
|
||||
if (params.options) {
|
||||
if (tools.isBitActive(params.options,
|
||||
shared_consts.OPTIONS_SEARCH_USER_ONLY_FULL_WORDS)) {
|
||||
params.fieldsearch = User.getFieldsForSearchUserFriend();
|
||||
}
|
||||
}
|
||||
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
@@ -103,42 +121,43 @@ MyGroupSchema.statics.findAllIdApp = async function(idapp) {
|
||||
};
|
||||
|
||||
// Rimuovo la Richiesta del Gruppo
|
||||
MyGroupSchema.statics.removeReqGroup = async function(
|
||||
idapp, username, groupnameDest) {
|
||||
const {User} = require('../models/user');
|
||||
MyGroupSchema.statics.removeReqGroup = async function(idapp, username, groupnameDest) {
|
||||
|
||||
return User.updateOne({idapp, username: username},
|
||||
{$pull: {'profile.req_groups': {groupname: {$in: [groupnameDest]}}}});
|
||||
return MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
{$pull: {req_users: {username: {$in: [username]}}}});
|
||||
};
|
||||
|
||||
function getWhatToShow(idapp, username) {
|
||||
// ++Todo: MyGroup what to show
|
||||
MyGroupSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
// FOR ME, PERMIT ALL
|
||||
return {
|
||||
groupname: 1,
|
||||
title: 1,
|
||||
descr: 1,
|
||||
visibility: 1,
|
||||
idSector: 1,
|
||||
idCatGrp: 1,
|
||||
userId: 1,
|
||||
photos: 1,
|
||||
idCity: 1,
|
||||
website: 1,
|
||||
link_telegram: 1,
|
||||
note: 1,
|
||||
admins: 1,
|
||||
blocked: 1,
|
||||
req_users: 1,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
function getWhatToShow_Unknown(idapp, username) {
|
||||
MyGroupSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
return {
|
||||
groupname: 1,
|
||||
title: 1,
|
||||
descr: 1,
|
||||
photos: 1,
|
||||
visibility: 1,
|
||||
idSector: 1,
|
||||
idCatGrp: 1,
|
||||
idCity: 1,
|
||||
note: 1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -170,10 +189,9 @@ MyGroupSchema.statics.getUsernameReqGroupsByGroupname = async function(
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getInfoGroupByGroupname = async function(
|
||||
idapp, groupname) {
|
||||
MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname) {
|
||||
|
||||
const whatToShow = getWhatToShow(idapp, groupname);
|
||||
const whatToShow = this.getWhatToShow(idapp, groupname);
|
||||
|
||||
return MyGroup.findOne({
|
||||
idapp,
|
||||
@@ -187,8 +205,8 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username) {
|
||||
try {
|
||||
const {User} = require('../models/user');
|
||||
|
||||
const whatToShow = getWhatToShow(idapp, username);
|
||||
const whatToShow_Unknown = getWhatToShow_Unknown(idapp, username);
|
||||
const whatToShow = this.getWhatToShow(idapp, username);
|
||||
const whatToShow_Unknown = this.getWhatToShow_Unknown(idapp, username);
|
||||
const arrUsernameGroups = await User.getUsernameGroupsByUsername(idapp,
|
||||
username);
|
||||
// const arrUsernameReqGroups = await MyGroup.getUsernameReqGroupsByGroupname(idapp, username);
|
||||
|
||||
Reference in New Issue
Block a user