Add to the Circuit
Remove to the Circuit Revoke request Users Admins
This commit is contained in:
1
docs/todo.txt
Normal file
1
docs/todo.txt
Normal file
@@ -0,0 +1 @@
|
||||
- mygroups array is visible by ALL :( (only with visibility correct you have to show)
|
||||
@@ -1,140 +0,0 @@
|
||||
------------
|
||||
|
||||
// ++Todo: PRIORITA' ALTA:
|
||||
|
||||
- ETELEGRAM: 400 Bad Request: message identifier is not specified.
|
||||
- ETELEGRAM: 400 Bad Request: message is too long
|
||||
|
||||
|
||||
- Togliere gli imbarchi: far pagare subito la persona.
|
||||
|
||||
- Errore durante la sostituzione...
|
||||
- Se sostuisci una persona, al nuovo utente gli arriva il messaggio sbagliato!
|
||||
(🌟Caro Tiziana - TiziCaso 🌟 Il tuo imbarco è stato cancellato,
|
||||
questo succede quando non riceviamo risposta ad un nostro messaggio per giorni.)
|
||||
|
||||
- Il dono al Fondo, fallo fare a prescindere (non al 57¨ dono).
|
||||
|
||||
- Controllare che ci sono registrazioni doppie !! (stesso username e stessa email!)
|
||||
|
||||
- Mostrare il numero della tua posizione...
|
||||
|
||||
- (Linuccia) - Natalina Malerbi
|
||||
DA CONTROLLARE CHE LEI NON HA PAGATO 8.44.
|
||||
QUINDI QUALCUNO HA PRESO IL SUO POSTO.
|
||||
|
||||
- 7.64 : NATALINA NON HA LA RITESSITURA !!
|
||||
|
||||
|
||||
- SubAccount:
|
||||
filtro.
|
||||
|
||||
- Aggiornare le Traduzioni di Darja (ritessitura).
|
||||
|
||||
- Sistemare la email che arriva ai Donatori (HTML) non si legge !!!
|
||||
|
||||
- Flotte: Poter scegliere quale messaggio inviare !
|
||||
|
||||
- SE CAMBIANO LE CREDENZIALI: EMAIL... o username: segnalarlo sul BOT !
|
||||
|
||||
- Alla sostituzione, mandare msg all'Invitante
|
||||
|
||||
- CONTROLLARE CHE IN NAVI NON CI SIANO i num_tess e ind_order UGUALI !
|
||||
ad esempio Angela
|
||||
- Record 1 -> ind_order = 51 num_tess = 1
|
||||
- Record 2 -> ind_order = 51 num_tess = 1 <--- DEV'ESSERE A 3 !
|
||||
|
||||
- Puoi imbarcarti non piu di 2 volte temporanee.
|
||||
|
||||
- Togliere Sogno e Video.
|
||||
|
||||
- Controllare che da errore in fase di cancellazione dell'utente, dal profilo:
|
||||
Fare una pagina intermedia che dice che sei stato cancellato...
|
||||
|
||||
- Controllare la data nel tragitto sembra essere sbagliata (vedi Cinzia Ortolan).
|
||||
|
||||
|
||||
- Profili Incompleti:
|
||||
Poter inviare dei messaggi in automatico per ricordargli di completare ...
|
||||
|
||||
- Se non hai fatto una registrazione con verifica email o BOT:
|
||||
Mandare email dicendo che se non t'iscrivi, verrai cancellato.
|
||||
|
||||
- Se non si è qualificato entro 7 gg, manda un msg a lui e all'invitante che verrà cancellato entro 7 gg.
|
||||
|
||||
- Se sei in conversazione e premi i menu, esci dalla conversazione !
|
||||
|
||||
- CHIEDERE ALLA PERSONA SE VUOLE ESSERE SOSPESO OPPURE CANCELLATO!
|
||||
Se ha solo questo imbarco:
|
||||
- Come da tua richiesta, sei stato sostituito.
|
||||
- Vuoi cancellare questo profilo? -> "Nascosto"
|
||||
- Vuoi Sospendere il profilo? -> "Sospeso"
|
||||
|
||||
- Se l'utente entra ed è "Nascosto":
|
||||
- Gli chiedo se vuole ripristinare l'account...
|
||||
|
||||
- Rimettere "made_gift" a false se si ha sbagliato...
|
||||
|
||||
- Fondo Ayni 9.152 : aggiungere registrazione Paolo2 Arena. e mettere paypal.me ??
|
||||
|
||||
- Mandare msg ai Non Invitati, o inferiori di 2.
|
||||
|
||||
- aggiungere le note di pagamento, a nome di chi è il pagamento?
|
||||
|
||||
- Inviare il Link che punta alla Pagina del Sito, per effettuare il Dono!
|
||||
E per eventualmente Entrare nella GIFT CHAT!
|
||||
|
||||
- Mettere i messaggi del DONO in LINGUA (metterli sul server).
|
||||
|
||||
- ULTIMA FLOTTA DA - A DEFINITIVA
|
||||
- ULTIMA NAVE DEFINITIVA...N.NN
|
||||
|
||||
|
||||
- Non poter sostituire i Ritessuti ! D8
|
||||
|
||||
|
||||
- Il LastNave non sembra essere corretto!
|
||||
|
||||
|
||||
- Sistemare la Creazione delle Navi... in semi-automatico.
|
||||
|
||||
|
||||
// ++Todo: PRIORITA' NORMALE:
|
||||
|
||||
- Fare funzione che passa un Utente secondario in un utente Primario! (c'è gia)
|
||||
|
||||
// ++Todo: DA FARE PIU AVANTI:
|
||||
|
||||
|
||||
- Per il Fondo Ayni, prevedere anche altri Metodi di Pagamento... Revolut, N26, ecc...
|
||||
ed inserirlo sul sito per il Sognatore (flag Pagato al Fondo: nave.offerta_al_fondo).
|
||||
|
||||
- Le pagine dovranno andare memorizzate su statics/upload/pages/.... di modo da risparmiare banda.
|
||||
|
||||
- Per Regalare una propria Nave?
|
||||
|
||||
|
||||
TESTARE -> inviare il msg anche al Sognatore della Gift Chat
|
||||
|
||||
|
||||
// ++Todo: SISTEMARE:
|
||||
|
||||
|
||||
|
||||
SOSTITUISCI:
|
||||
|
||||
- Inviare messaggi solo per ITALIANI (o di lingua cmq).
|
||||
|
||||
- CONTROLLARE CON ARGENTINA E PORTOGALLO e Brasile:
|
||||
Il sito deve comparire in Spagnolo e in Portoghese
|
||||
|
||||
|
||||
TRADURRE:
|
||||
|
||||
.update({}, {$unset: {$ind_order: 1}, {multi: true});
|
||||
|
||||
|
||||
|
||||
|
||||
// ++Todo: FATTO: DA CONTROLLARE
|
||||
|
||||
@@ -114,7 +114,7 @@ if (process.env.NODE_ENV === 'production') {
|
||||
host: 'https://www.centrolisticorimini.it',
|
||||
portapp: '0',
|
||||
dir: '/var/www/centrolisticorimini.it',
|
||||
email_from: 'info.pianetalibero@gmail.com', // ++TODO: Sarà da cambiare email d'invio !?!?!?
|
||||
email_from: 'info.pianetalibero@gmail.com',
|
||||
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
|
||||
telegram_key:'',
|
||||
telegram_bot_name: '',
|
||||
@@ -261,7 +261,7 @@ if (process.env.NODE_ENV === 'production') {
|
||||
host: 'https://www.centrolisticorimini.it',
|
||||
portapp: '0',
|
||||
dir: '/var/www/centrolisticorimini.it',
|
||||
email_from: 'info.pianetalibero@gmail.com', // ++TODO: Sarà da cambiare email d'invio !?!?!?
|
||||
email_from: 'info.pianetalibero@gmail.com',
|
||||
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
|
||||
telegram_key:'',
|
||||
telegram_bot_name: '',
|
||||
|
||||
@@ -32,5 +32,22 @@
|
||||
"FRIEND_REPORTED_YOU": "Hai segnalato %s per comportamenti non idonei.",
|
||||
"FRIEND_UNBLOCKED_TO_ME": "Sei stato riattivato da %s",
|
||||
"FRIEND_UNBLOCKED": "E' stato riattivato %s da %s.",
|
||||
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s."
|
||||
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Accetta Ingresso nel Circuito %s:",
|
||||
"CIRCUIT_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel circuito %s",
|
||||
"CIRCUIT_CREATED": "✅ %s ha creato un nuovo Circuito chiamato %s",
|
||||
"CIRCUIT_REQUEST": "Richiesta di entrare nel Circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN_YOU": "Sei stato aggiunto come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN_YOU": "Ti è stato rimosso l'incarico di Amministratore del circuito %s da parte di %s",
|
||||
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il Circuito %s da parte di %s",
|
||||
"CIRCUIT_ELIMINATO": "Il circuito %s è stato eliminato da parte di %s",
|
||||
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Circuito %s. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
|
||||
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal Circuito %s",
|
||||
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal Circuito %s",
|
||||
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal Circuito %s (da parte di %s)"
|
||||
}
|
||||
|
||||
@@ -41,12 +41,16 @@ const AccountSchema = new Schema({
|
||||
saldo: {
|
||||
type: Number,
|
||||
},
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
AccountSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const Account = this;
|
||||
|
||||
const myfind = {idapp};
|
||||
const myfind = {idapp, deleted: false};
|
||||
|
||||
return await Account.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
@@ -79,7 +83,7 @@ AccountSchema.statics.getFieldsForSearch = function() {
|
||||
|
||||
AccountSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
AccountSchema.statics.getAccountsByUsername = async function(idapp, username) {
|
||||
@@ -93,7 +97,7 @@ AccountSchema.statics.getAccountsByUsername = async function(idapp, username) {
|
||||
'username': username,
|
||||
};
|
||||
|
||||
return await Account.find(myquery);
|
||||
return await Account.find(myquery).lean();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ mongoose.level = 'F';
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const {User} = require('./user');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -49,9 +48,6 @@ const CircuitSchema = new Schema({
|
||||
systemUserId: {
|
||||
type: String,
|
||||
},
|
||||
founderUserId: {
|
||||
type: String,
|
||||
},
|
||||
totCircolante: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -149,6 +145,16 @@ const CircuitSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
CircuitSchema.pre('save', async function(next) {
|
||||
if (this.isNew) {
|
||||
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
CircuitSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const Circuit = this;
|
||||
|
||||
@@ -186,7 +192,7 @@ CircuitSchema.statics.getFieldsForSearch = function() {
|
||||
|
||||
CircuitSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
@@ -201,18 +207,23 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
longdescr: 1,
|
||||
regulation: 1,
|
||||
systemUserId: 1,
|
||||
founderUserId: 1,
|
||||
createdBy: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
nome_valuta: 1,
|
||||
symbol: 1,
|
||||
abbrev: 1,
|
||||
data_costituz: 1,
|
||||
img_logo: 1,
|
||||
admins: 1,
|
||||
req_users: 1,
|
||||
refused_users: 1,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// Rimuovi dagli Admin del Circuito
|
||||
MyGroupSchema.statics.removeAdminOfMyCircuit = async function(idapp, username, name) {
|
||||
CircuitSchema.statics.removeAdminOfMyCircuit = async function(idapp, username, name) {
|
||||
|
||||
return Circuit.updateOne({idapp, name},
|
||||
{$pull: {admins: {username: {$in: [username]}}}});
|
||||
@@ -236,6 +247,12 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
abbrev: 1,
|
||||
data_costituz: 1,
|
||||
img_logo: 1,
|
||||
admins: 1,
|
||||
createdBy: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
req_users: 1,
|
||||
refused_users: 1,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -247,20 +264,29 @@ CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, re
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, username);
|
||||
const whatToShow_Unknown = this.getWhatToShow_Unknown(idapp, username);
|
||||
// const arrUsernameCircuits = await User.getUsernameCircuitsByUsername(idapp,
|
||||
// username);
|
||||
// const arrUsernameCircuits = await User.getUsernameCircuitsByUsername(idapp, username);
|
||||
// const arrUsernameReqCircuits = await MyCircuit.getUsernameReqCircuitsByCircuitname(idapp, username);
|
||||
|
||||
let listUserAccounts = await Account.getAccountsByUsername(idapp, username);
|
||||
|
||||
const manage_mycircuits = await Circuit.find({
|
||||
idapp,
|
||||
'admins': {
|
||||
$elemMatch: {username: {$eq: username}},
|
||||
},
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
}).lean();
|
||||
|
||||
let listcircuits = await Circuit.find({
|
||||
idapp,
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
}, whatToShow_Unknown);
|
||||
}, whatToShow_Unknown).lean();
|
||||
|
||||
let listSentRequestCircuits = await Circuit.find({
|
||||
let asked_circuits = await Circuit.find({
|
||||
idapp,
|
||||
'req_users': {
|
||||
$elemMatch: {username: {$eq: username}},
|
||||
@@ -268,9 +294,9 @@ CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, re
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
}, whatToShow_Unknown);
|
||||
}, whatToShow_Unknown).lean();
|
||||
|
||||
let listRefusedCircuits = await Circuit.find({
|
||||
let refused_circuits = await Circuit.find({
|
||||
idapp,
|
||||
'refused_users': {
|
||||
$elemMatch: {username: {$eq: username}},
|
||||
@@ -278,29 +304,78 @@ CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, re
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
}, whatToShow_Unknown);
|
||||
}, whatToShow_Unknown).lean();
|
||||
|
||||
return {
|
||||
listUserAccounts,
|
||||
listcircuits,
|
||||
listSentRequestCircuits,
|
||||
listRefusedCircuits,
|
||||
asked_circuits,
|
||||
refused_circuits,
|
||||
manage_mycircuits,
|
||||
mycircuits: req.user.profile.mycircuits,
|
||||
};
|
||||
|
||||
} catch (e) {
|
||||
console.log('Error', e);
|
||||
console.log('Error getCircuitsByUsername', e);
|
||||
}
|
||||
|
||||
return {
|
||||
listUsersCircuit: [],
|
||||
listRequestUsersCircuit: [],
|
||||
listTrusted: [],
|
||||
listSentRequestCircuits: [],
|
||||
listRefusedCircuits: [],
|
||||
asked_circuits: [],
|
||||
refused_circuits: [],
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getInfoCircuitByName = async function(idapp, name) {
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, '');
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
name,
|
||||
};
|
||||
|
||||
try {
|
||||
return await Circuit.findOne(myfind, whatToShow).lean();
|
||||
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.deleteCircuit = async function(idapp, usernameOrig, name) {
|
||||
console.log('Circuito ' + name + ' rimosso da ' + usernameOrig);
|
||||
return Circuit.findOneAndRemove({idapp, name});
|
||||
};
|
||||
|
||||
// Rimuovo la Richiesta del Circuito
|
||||
CircuitSchema.statics.removeReqCircuit = async function(idapp, username, name) {
|
||||
|
||||
return Circuit.updateOne({idapp, name},
|
||||
{$pull: {req_users: {username: {$in: [username]}}}});
|
||||
};
|
||||
|
||||
// Aggiungi agli utenti Rifiutati del Circuito
|
||||
CircuitSchema.statics.refuseReqCircuit = async function(idapp, username, name) {
|
||||
|
||||
return Circuit.updateOne({idapp, name},
|
||||
{
|
||||
$push:
|
||||
{
|
||||
refused_users: {
|
||||
username,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
const Circuit = mongoose.model('Circuit', CircuitSchema);
|
||||
|
||||
module.exports = {Circuit};
|
||||
|
||||
@@ -266,6 +266,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -323,6 +324,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -380,6 +382,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -437,6 +440,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -494,6 +498,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
|
||||
@@ -170,6 +170,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
surname: 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -263,6 +264,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -319,6 +321,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -376,6 +379,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -432,6 +436,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -488,6 +493,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
|
||||
@@ -332,7 +332,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname)
|
||||
return null;
|
||||
}
|
||||
|
||||
return rec;
|
||||
return ris;
|
||||
|
||||
};
|
||||
|
||||
@@ -348,8 +348,7 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req)
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, username);
|
||||
const whatToShow_Unknown = this.getWhatToShow_Unknown(idapp, username);
|
||||
const arrUsernameGroups = await User.getUsernameGroupsByUsername(idapp,
|
||||
username);
|
||||
const arrUsernameGroups = await User.getUsernameGroupsByUsername(idapp, username);
|
||||
// const arrUsernameReqGroups = await MyGroup.getUsernameReqGroupsByGroupname(idapp, username);
|
||||
|
||||
let listUsersGroup = await User.find({
|
||||
|
||||
@@ -170,6 +170,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
surname: 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -259,6 +260,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -311,6 +313,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -363,6 +366,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -415,6 +419,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -467,6 +472,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
|
||||
@@ -171,6 +171,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
surname: 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -263,6 +264,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -318,6 +320,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -373,6 +376,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -430,6 +434,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
@@ -485,6 +490,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
|
||||
@@ -219,7 +219,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
||||
tag = 'remgroup';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REFUSED) {
|
||||
newdescr = i18n.__('GROUPS_REFUSED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
tag = 'addgroup';
|
||||
tag = 'refgroup';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER) {
|
||||
newdescr = i18n.__('GROUP_REQUEST_TO_ENTER', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.singleadmin_username);
|
||||
tag = 'reqgroups';
|
||||
@@ -249,6 +249,59 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
||||
}
|
||||
tag = 'removeadmingrp';
|
||||
}
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
|
||||
tag = 'circuit';
|
||||
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path;
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC) {
|
||||
newdescr = i18n.__('CIRCUIT_CREATED', userorig, recnotif.paramsObj.circuitnameDest);
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||
if (recnotif.paramsObj.isAdmin) {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS_CIRCUIT', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_ACCEPTED', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
}
|
||||
tag = 'addcircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED) {
|
||||
if (recnotif.paramsObj.username_action === recnotif.paramsObj.usernameDest && userorig === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_EXIT_USER_TO_ME', recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
} else if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED_TO_ME', recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
} else if (userorig === recnotif.paramsObj.username_action) {
|
||||
newdescr = i18n.__('CIRCUIT_EXIT_USER', userorig, recnotif.paramsObj.circuitnameDest);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
}
|
||||
|
||||
tag = 'remcircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REFUSED) {
|
||||
newdescr = i18n.__('CIRCUIT_REFUSED', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
tag = 'refcircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER) {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.singleadmin_username);
|
||||
tag = 'reqcircuits';
|
||||
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_DELETE_USER) {
|
||||
newdescr = i18n.__('CIRCUIT_ELIMINATO', userorig, recnotif.paramsObj.username_action);
|
||||
tag = 'deletecircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ADDED_ADMIN) {
|
||||
if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_ADDED_ADMIN_YOU', recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_ADDED_ADMIN', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
}
|
||||
tag = 'addadmingrp';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN) {
|
||||
if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUITS_REMOVED_ADMIN_YOU', recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUITS_REMOVED_ADMIN', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
}
|
||||
tag = 'removeadmincircuit';
|
||||
}
|
||||
}
|
||||
|
||||
recnotif.tag = recnotif.tag ? recnotif.tag : tag;
|
||||
@@ -371,26 +424,35 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
}
|
||||
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
||||
dest = myrecnotif.dest;
|
||||
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ACCEPTED) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_ACCEPTED;
|
||||
dest = myrecnotif.dest;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REFUSED) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_REFUSED;
|
||||
dest = myrecnotif.dest;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REMOVED) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_REMOVED;
|
||||
dest = myrecnotif.dest;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_BLOCK_USER) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_BLOCKED;
|
||||
dest = myrecnotif.dest;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_DELETE_USER) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_DELETED;
|
||||
}
|
||||
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||
dest = myrecnotif.dest;
|
||||
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER;
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_ACCEPTED;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REFUSED) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER;
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_REFUSED;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED) {
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_REMOVED;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_BLOCK_USER) {
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_BLOCKED;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_DELETE_USER) {
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_DELETED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +543,11 @@ sendNotifSchema.statics.getExtraParam = function(myrecnotif, paramsObj) {
|
||||
out.paramsObj = paramsObj;
|
||||
out.options = paramsObj.options ? paramsObj.options : [];
|
||||
out.typesend = paramsObj.typesend ? paramsObj.typesend : 0;
|
||||
if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
|
||||
out.extrafield = paramsObj.circuitnameDest ? paramsObj.circuitnameDest : '';
|
||||
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||
out.extrafield = paramsObj.groupnameDest ? paramsObj.groupnameDest : '';
|
||||
}
|
||||
|
||||
return myrecnotif;
|
||||
};
|
||||
@@ -515,11 +581,11 @@ sendNotifSchema.statics.createNewNotifToSingleUser = async function(req, res, pa
|
||||
|
||||
try {
|
||||
let myrecnotif = new SendNotif(this.getDefaultRec(req));
|
||||
myrecnotif = this.getExtraParam(myrecnotif, paramsObj);
|
||||
|
||||
myrecnotif.typedir = typedir;
|
||||
myrecnotif.typeid = typeid;
|
||||
|
||||
myrecnotif = this.getExtraParam(myrecnotif, paramsObj);
|
||||
|
||||
await SendNotif.sendToSingleUserDest(myrecnotif, req, res, onlysave);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -14,6 +14,7 @@ const {Graduatoria} = require('../models/graduatoria');
|
||||
// const { ExtraList } = require('../models/extralist');
|
||||
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
const {Circuit} = require('../models/circuit');
|
||||
|
||||
const {Account} = require('../models/account');
|
||||
|
||||
@@ -371,6 +372,13 @@ const UserSchema = new mongoose.Schema({
|
||||
date: {type: Date},
|
||||
}], // username
|
||||
|
||||
mycircuits: [
|
||||
{
|
||||
_id: false,
|
||||
circuitname: {type: String},
|
||||
date: {type: Date},
|
||||
}], // username
|
||||
|
||||
notifs: [
|
||||
{
|
||||
_id: false,
|
||||
@@ -1583,7 +1591,14 @@ UserSchema.statics.getUsernameGroupsByUsername = async function(
|
||||
idapp, username) {
|
||||
|
||||
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
'groups');
|
||||
'mygroups');
|
||||
|
||||
};
|
||||
UserSchema.statics.getUsernameCircuitsByUsername = async function(
|
||||
idapp, username) {
|
||||
|
||||
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
'mycircuits');
|
||||
|
||||
};
|
||||
|
||||
@@ -1600,6 +1615,12 @@ UserSchema.statics.removeFromMyGroups = async function(
|
||||
return User.updateOne({idapp, username},
|
||||
{$pull: {'profile.mygroups': {groupname: {$in: [groupnameDest]}}}});
|
||||
};
|
||||
// Rimuovo il Gruppo
|
||||
UserSchema.statics.removeFromCircuits = async function(idapp, username, circuitname) {
|
||||
return User.updateOne({idapp, username},
|
||||
{$pull: {'profile.mycircuits': {circuitname: {$in: [circuitname]}}}});
|
||||
|
||||
};
|
||||
|
||||
// Rimuovo il Gruppo per Tutti gli Utenti
|
||||
UserSchema.statics.removeAllUsersFromMyGroups = async function(idapp, groupnameDest) {
|
||||
@@ -1607,6 +1628,12 @@ UserSchema.statics.removeAllUsersFromMyGroups = async function(idapp, groupnameD
|
||||
{$pull: {'profile.mygroups': {groupname: {$in: [groupnameDest]}}}});
|
||||
};
|
||||
|
||||
// Rimuovo il Circuito per Tutti gli Utenti
|
||||
UserSchema.statics.removeAllUsersFromMyCircuits = async function(idapp, circuitname) {
|
||||
return User.updateMany({idapp},
|
||||
{$pull: {'profile.mycircuits': {circuitname: {$in: [circuitname]}}}});
|
||||
};
|
||||
|
||||
// Rimuovo la Richiesta di Amicizia
|
||||
UserSchema.statics.removeReqFriend = async function(
|
||||
idapp, username, usernameDest) {
|
||||
@@ -1871,6 +1898,18 @@ UserSchema.statics.ifAlreadyInGroup = async function(idapp, usernameOrig, groupn
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.ifAlreadyInCircuit = async function(idapp, usernameOrig, circuitname) {
|
||||
|
||||
// Controllo se è stato già inserito
|
||||
return User.findOne({
|
||||
idapp,
|
||||
username: usernameOrig,
|
||||
'profile.mycircuits': {
|
||||
$elemMatch: {circuitname: {$eq: circuitname}},
|
||||
},
|
||||
}).lean();
|
||||
};
|
||||
|
||||
UserSchema.statics.countUsersInGroup = async function(idapp, groupnameDest) {
|
||||
|
||||
// Controllo se è stato già inserito
|
||||
@@ -1883,6 +1922,19 @@ UserSchema.statics.countUsersInGroup = async function(idapp, groupnameDest) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.countUsersInCircuit = async function(idapp, circuitname) {
|
||||
|
||||
// Controllo se è stato già inserito
|
||||
return User.countDocuments({
|
||||
idapp,
|
||||
'profile.mycircuits': {
|
||||
$elemMatch: {circuitname: {$eq: name}},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameDest, cmd, value, username_action) {
|
||||
|
||||
let ris = null;
|
||||
@@ -1984,6 +2036,12 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
||||
|
||||
ris = await MyGroup.removeReqGroup(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
||||
|
||||
} else if (cmd === shared_consts.GROUPSCMD.REFUSE_REQ_GROUP) {
|
||||
|
||||
ris = await MyGroup.removeReqGroup(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
||||
|
||||
ris = await MyGroup.refuseReqGroup(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
||||
|
||||
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_GROUP) {
|
||||
|
||||
await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
||||
@@ -2019,19 +2077,19 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
||||
return ris;
|
||||
};
|
||||
|
||||
UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, name, cmd, value, username_action) {
|
||||
UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitname, cmd, value, username_action) {
|
||||
|
||||
let ris = null;
|
||||
let update = {};
|
||||
try {
|
||||
if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
const foundIfAlreadyCircuit = await this.ifAlreadyInCircuit(idapp, usernameOrig, name);
|
||||
const foundIfAlreadyCircuit = await this.ifAlreadyInCircuit(idapp, usernameOrig, circuitname);
|
||||
|
||||
if (!foundIfAlreadyCircuit) {
|
||||
update = {
|
||||
$push: {
|
||||
'profile.mycircuits': {
|
||||
circuitname: name,
|
||||
circuitname,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
@@ -2040,31 +2098,31 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, name, cmd
|
||||
|
||||
// Elimina la richiesta:
|
||||
update = {$pull: {req_users: {username: {$in: [usernameOrig]}}}};
|
||||
await Circuit.updateOne({idapp, groupname: name}, update);
|
||||
await Circuit.updateOne({idapp, name: circuitname}, update);
|
||||
|
||||
// Elimina eventualmente se era bloccato:
|
||||
update = {$pull: {refused_users: {username: {$in: [usernameOrig]}}}};
|
||||
await Circuit.updateOne({idapp, groupname: name}, update);
|
||||
await Circuit.updateOne({idapp, name: circuitname}, update);
|
||||
} else {
|
||||
ris = false;
|
||||
}
|
||||
if (ris) {
|
||||
// Invia una notifica alla persona e agli Admin
|
||||
tools.sendNotificationByGroupname(idapp, usernameOrig, name, cmd, value, true, username_action);
|
||||
ris = await Circuit.getInfoGroupByGroupname(idapp, name);
|
||||
tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, value, true, username_action);
|
||||
ris = await Circuit.getInfoCircuitByName(idapp, circuitname);
|
||||
}
|
||||
} else if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||
// Aggiungo la richiesta di Gruppo a me
|
||||
const foundIfAlreadyAskGroup = await Circuit.findOne({
|
||||
const foundIfAlreadyAskCircuit = await Circuit.findOne({
|
||||
idapp,
|
||||
groupname: name,
|
||||
name: circuitname,
|
||||
'req_users': {
|
||||
$elemMatch: {username: {$eq: usernameOrig}},
|
||||
},
|
||||
});
|
||||
|
||||
if (value) {
|
||||
if (!foundIfAlreadyAskGroup) {
|
||||
if (!foundIfAlreadyAskCircuit) {
|
||||
update = {
|
||||
$push: {
|
||||
'req_users': {
|
||||
@@ -2073,83 +2131,70 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, name, cmd
|
||||
},
|
||||
},
|
||||
};
|
||||
ris = await Circuit.updateOne({idapp, groupname: name},
|
||||
update);
|
||||
ris = await Circuit.updateOne({idapp, name: circuitname}, update);
|
||||
}
|
||||
if (ris) {
|
||||
// Invia una notifica alla persona
|
||||
await tools.sendNotificationByGroupname(idapp, usernameOrig, name, cmd, true, true, username_action);
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, true, true, username_action);
|
||||
}
|
||||
} else {
|
||||
if (foundIfAlreadyAskGroup) {
|
||||
ris = await this.removeFromCircuits(idapp, usernameOrig, name); // Rimuovo il Gruppo da me
|
||||
if (foundIfAlreadyAskCircuit) {
|
||||
ris = await this.removeFromCircuits(idapp, usernameOrig, circuitname); // Rimuovo il Gruppo da me
|
||||
|
||||
// Invia una notifica alla persona
|
||||
await tools.sendNotificationByGroupname(idapp, usernameOrig, name, cmd, false, true, username_action);
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action);
|
||||
}
|
||||
}
|
||||
|
||||
if (ris) {
|
||||
ris = await Circuit.getInfoGroupByGroupname(idapp, name);
|
||||
}
|
||||
ris = await Circuit.getInfoCircuitByName(idapp, circuitname);
|
||||
|
||||
} else if (cmd === shared_consts.GROUPSCMD.REMOVE_FROM_CIRCUIT) {
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST) {
|
||||
|
||||
// Remove if is also an Admin
|
||||
await Circuit.removeAdminOfMyCircuit(idapp, usernameOrig, name);
|
||||
await Circuit.removeAdminOfMyCircuit(idapp, usernameOrig, circuitname);
|
||||
|
||||
ris = await User.removeFromCircuits(idapp, usernameOrig, name); // Rimuovo l'Amicizia da me
|
||||
ris = await this.removeFromCircuits(idapp, usernameOrig, circuitname); // Rimuovo l'Amicizia da me
|
||||
console.log('ris', ris);
|
||||
|
||||
// Invia una notifica alla persona
|
||||
await tools.sendNotificationByGroupname(idapp, usernameOrig, name, cmd, false, true, username_action);
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action);
|
||||
|
||||
} else if (cmd === shared_consts.GROUPSCMD.DELETE_GROUP) {
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.DELETE) {
|
||||
|
||||
ris = await User.removeFromCircuits(idapp, usernameOrig, name); // Rimuovo l'Amicizia da me
|
||||
ris = await this.removeFromCircuits(idapp, usernameOrig, circuitname); // Rimuovo l'Amicizia da me
|
||||
|
||||
if (ris) {
|
||||
// Invia una notifica alla persona e agli Admin
|
||||
await tools.sendNotificationByGroupname(idapp, usernameOrig, name, cmd, false, true, username_action);
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action);
|
||||
|
||||
}
|
||||
ris = await Circuit.deleteGroup(idapp, usernameOrig, name); // Rimuovo l'Amicizia da me
|
||||
console.log('ris', ris);
|
||||
ris = await Circuit.deleteCircuit(idapp, usernameOrig, circuitname); // Rimuovo l'Amicizia da me
|
||||
|
||||
} else if (cmd === shared_consts.GROUPSCMD.CANCEL_REQ_GROUP) {
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.CANCEL_REQ) {
|
||||
|
||||
ris = await Circuit.removeReqGroup(idapp, usernameOrig, name); // Rimuovo l'Amicizia da me
|
||||
ris = await Circuit.removeReqCircuit(idapp, usernameOrig, circuitname); // Rimuovo l'Amicizia da me
|
||||
|
||||
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_GROUP) {
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REFUSE_REQ) {
|
||||
|
||||
await User.removeFromCircuits(idapp, usernameOrig, name); // Rimuovo l'Amicizia da me
|
||||
ris = await Circuit.removeReqCircuit(idapp, usernameOrig, circuitname); // Rimuovo l'Amicizia da me
|
||||
|
||||
// Blocco il Gruppo
|
||||
ris = await Circuit.updateOne({idapp, groupname: name}, {
|
||||
$set: {
|
||||
blocked: true,
|
||||
username_who_block: usernameOrig,
|
||||
date_blocked: new Date(),
|
||||
},
|
||||
});
|
||||
//++Todo: Send Notification to Admin and Group's manager
|
||||
tools.sendNotificationByGroupname(idapp, usernameOrig, name, cmd, false, true, username_action);
|
||||
ris = await Circuit.refuseReqCircuit(idapp, usernameOrig, circuitname); // Rimuovo l'Amicizia da me
|
||||
|
||||
} else if (cmd === shared_consts.GROUPSCMD.ADDADMIN_OFCIRCUIT) {
|
||||
ris = await Circuit.addToAdminOfCircuit(idapp, usernameOrig, name); // Rimuovo la richiesta di entrare nel gruppo
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) {
|
||||
ris = await Circuit.addToAdminOfCircuit(idapp, usernameOrig, circuitname); // Rimuovo la richiesta di entrare nel gruppo
|
||||
|
||||
// Invia una notifica alla persona
|
||||
await tools.sendNotificationByGroupname(idapp, usernameOrig, name, cmd, false, true, username_action);
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action);
|
||||
|
||||
} else if (cmd === shared_consts.GROUPSCMD.REMOVEADMIN_OFCIRCUIT) {
|
||||
ris = await Circuit.removeAdminOfCircuit(idapp, usernameOrig, name); // Rimuovo la richiesta di entrare nel gruppo
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
|
||||
ris = await Circuit.removeAdminOfCircuit(idapp, usernameOrig, circuitname); // Rimuovo la richiesta di entrare nel gruppo
|
||||
|
||||
// Invia una notifica alla persona
|
||||
await tools.sendNotificationByGroupname(idapp, usernameOrig, name, cmd, false, true, username_action);
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action);
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error: ', e);
|
||||
console.error('Error setCircuitCmd: ', e);
|
||||
}
|
||||
|
||||
return ris;
|
||||
@@ -3635,7 +3680,7 @@ UserSchema.statics.DbOp = async function(idapp, mydata) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
|
||||
UserSchema.statics.addExtraInfo = async function(idapp, recUser, req) {
|
||||
|
||||
try {
|
||||
const listSentMyRequestFriends = await User.find({
|
||||
@@ -3694,15 +3739,11 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
|
||||
? listManageGroups
|
||||
: [];
|
||||
|
||||
// UserAccounts
|
||||
|
||||
const listUserAccounts = await Account.getAccountsByUsername(idapp, recUser.username);
|
||||
|
||||
recUser._doc.profile.listUserAccounts = listUserAccounts
|
||||
? listUserAccounts
|
||||
: [];
|
||||
// Circuit
|
||||
|
||||
const circuitobj = await Circuit.getCircuitsByUsername(idapp, recUser.username, req);
|
||||
|
||||
recUser._doc.profile = {...recUser._doc.profile, ...circuitobj};
|
||||
|
||||
return recUser._doc;
|
||||
|
||||
|
||||
@@ -45,23 +45,24 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
const whatshow = Circuit.getWhatToShow(idapp, req.user.username);
|
||||
let data = await Circuit.findOne({idapp, path}, whatshow).lean();
|
||||
|
||||
let cities = [];
|
||||
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
|
||||
|
||||
let users_in_circuit = [];
|
||||
if (data && data.circuitId) {
|
||||
|
||||
if (data) {
|
||||
users_in_circuit = await User.find(
|
||||
{
|
||||
idapp,
|
||||
circuitId: data.circuitId,
|
||||
'profile.mycircuits': {
|
||||
$elemMatch: {circuitname: {$eq: data.name}},
|
||||
},
|
||||
},
|
||||
whatshowUsers,
|
||||
).lean();
|
||||
|
||||
}
|
||||
|
||||
data = await getCircuitRecAdminsInfo(idapp, data);
|
||||
|
||||
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
|
||||
|
||||
res.send({circuit: data, users_in_circuit});
|
||||
|
||||
} catch (e) {
|
||||
|
||||
@@ -276,7 +276,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_USER_INCLUDE_MY.includes(params.table)) {
|
||||
if (mydata.admins.length <= 0) {
|
||||
if (!mydata.admins || mydata.admins.length <= 0) {
|
||||
// Aggiungi solo se non esistono Admin:
|
||||
mydata.admins = [];
|
||||
const indfind = mydata.admins.findIndex(
|
||||
@@ -321,6 +321,16 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
if (alreadyexist) {
|
||||
return res.send({code: server_constants.RIS_CODE_REC_ALREADY_EXIST_NAME});
|
||||
}
|
||||
} else if (params.table === shared_consts.TAB_MYCIRCUITS && isnewrec) {
|
||||
// Controlla se esiste già con lo stesso nome
|
||||
let alreadyexist = await Circuit.findOne({idapp, name: mydata.name});
|
||||
if (alreadyexist) {
|
||||
return res.send({code: server_constants.RIS_CODE_REC_ALREADY_EXIST_CODE});
|
||||
}
|
||||
alreadyexist = await Circuit.findOne({idapp, path: mydata.path});
|
||||
if (alreadyexist) {
|
||||
return res.send({code: server_constants.RIS_CODE_REC_ALREADY_EXIST_NAME});
|
||||
}
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_UPDATE_LASTMODIFIED.includes(params.table)) {
|
||||
@@ -343,6 +353,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
let typedir = 0;
|
||||
let typeid = 0;
|
||||
let groupnameDest = '';
|
||||
let circuitnameDest = '';
|
||||
|
||||
if (isnewrec) {
|
||||
// New Record created
|
||||
@@ -367,10 +378,16 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
groupnameDest = myrec ? myrec.groupname : '';
|
||||
setnotif = true;
|
||||
}
|
||||
if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(params.table)) {
|
||||
typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
|
||||
typeid = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
||||
circuitnameDest = myrec ? myrec.name : '';
|
||||
setnotif = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (setnotif) {
|
||||
await SendNotif.createNewNotification(req, res, {groupnameDest}, params.table, myrec, typedir, typeid);
|
||||
await SendNotif.createNewNotification(req, res, {groupnameDest, circuitnameDest}, params.table, myrec, typedir, typeid);
|
||||
}
|
||||
|
||||
if (params.table === shared_consts.TAB_MYGROUPS && isnewrec) {
|
||||
@@ -381,6 +398,13 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
shared_consts.GROUPSCMD.SETGROUP, true, req.user.username).then((ris) => {
|
||||
return res.send(myrec);
|
||||
});
|
||||
} else if (params.table === shared_consts.TAB_MYCIRCUITS && isnewrec) {
|
||||
// nuovo Record:
|
||||
// aggiungi il creatore al Circuito stesso
|
||||
return User.setCircuitCmd(mydata.idapp, req.user.username, myrec.name,
|
||||
shared_consts.CIRCUITCMD.SET, true, req.user.username).then((ris) => {
|
||||
return res.send(myrec);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1000,6 +1024,9 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
||||
if (tablename === shared_consts.TAB_MYGROUPS) {
|
||||
// Se è un gruppo, allora cancella anche tutti i suoi riferimenti
|
||||
User.removeAllUsersFromMyGroups(rec.idapp, rec.groupname);
|
||||
} else if (tablename === shared_consts.TAB_MYCIRCUITS) {
|
||||
// Se è un gruppo, allora cancella anche tutti i suoi riferimenti
|
||||
User.removeAllUsersFromMyCircuits(rec.idapp, rec.name);
|
||||
}
|
||||
|
||||
tools.refreshAllTablesInMem(rec.idapp, tablename, true, rec.username);
|
||||
@@ -1198,7 +1225,7 @@ function load(req, res, version) {
|
||||
let myuserextra = null;
|
||||
if (req.user) {
|
||||
// askedfriends = User.getAskedFriendsByUsername(idapp, req.user.username);
|
||||
myuserextra = User.addExtraInfo(idapp, req.user);
|
||||
myuserextra = User.addExtraInfo(idapp, req.user, req);
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
@@ -1345,7 +1372,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate, async (req, res) => {
|
||||
if (!arrcfgrec)
|
||||
return res.status(404).send();
|
||||
|
||||
// ++Todo: Add to Log Stat ....
|
||||
// ++Add to Log Stat ....
|
||||
|
||||
// const sall = '0';
|
||||
|
||||
|
||||
@@ -716,7 +716,7 @@ router.post('/circuits/cmd', authenticate, (req, res) => {
|
||||
const idapp = req.body.idapp;
|
||||
const locale = req.body.locale;
|
||||
const usernameOrig = req.body.usernameOrig;
|
||||
const name = req.body.name;
|
||||
const circuitname = req.body.circuitname;
|
||||
const cmd = req.body.cmd;
|
||||
const value = req.body.value;
|
||||
|
||||
@@ -728,12 +728,12 @@ router.post('/circuits/cmd', authenticate, (req, res) => {
|
||||
}
|
||||
}*/
|
||||
|
||||
return User.setCircuitCmd(idapp, usernameOrig, name, cmd, value, usernameLogged).
|
||||
return User.setCircuitCmd(idapp, usernameOrig, circuitname, cmd, value, usernameLogged).
|
||||
then((ris) => {
|
||||
res.send(ris);
|
||||
}).
|
||||
catch((e) => {
|
||||
tools.mylog('ERRORE IN groups/cmd: ' + e.message);
|
||||
tools.mylog('ERRORE IN circuits/cmd: ' + e.message);
|
||||
res.status(400).send();
|
||||
});
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ const printf = require('util').format;
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
const {Circuit} = require('../models/circuit');
|
||||
const {CalZoom} = require('../models/calzoom');
|
||||
const {MyBot} = require('../models/bot');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
@@ -450,6 +451,7 @@ const Status = {
|
||||
const Cmd = {
|
||||
VALIDATE_REGISTRATION: 1,
|
||||
RICHIESTA_GRUPPO: 2,
|
||||
RICHIESTA_CIRCUIT: 3,
|
||||
};
|
||||
|
||||
const Destin = {
|
||||
@@ -864,6 +866,20 @@ const MyTelegramBot = {
|
||||
|
||||
domanda = printf(getstr(langdest, 'MSG_ACCEPT_NEWENTRY_INGROUP'), groupname) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Accetta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + groupid,
|
||||
},
|
||||
{
|
||||
text: '🚫 Rifiuta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + groupid,
|
||||
},
|
||||
]);
|
||||
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
domanda = i18n.__({phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest} , groupname) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Accetta ' + myuser.username,
|
||||
@@ -3822,9 +3838,13 @@ if (true) {
|
||||
const userDest = data.userDest ? await User.getUserShortDataByUsername(idapp, data.userDest) : null;
|
||||
|
||||
let group = null;
|
||||
let circuit = null;
|
||||
if (data.groupId) {
|
||||
group = await MyGroup.findOne({idapp, _id: data.groupId}).lean();
|
||||
}
|
||||
if (data.circuitId) {
|
||||
circuit = await Circuit.findOne({idapp, _id: data.circuitId}).lean();
|
||||
}
|
||||
|
||||
let cmd = 0;
|
||||
|
||||
@@ -3912,6 +3932,30 @@ if (true) {
|
||||
await User.setGroupsCmd(user.idapp, data.username, group.groupname, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (circuit) {
|
||||
cmd = shared_consts.CIRCUITCMD.SET;
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||
|
||||
if (!foundIfAlreadyCircuit) {
|
||||
// Aggiungilo nel Gruppo
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (circuit) {
|
||||
cmd = shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST;
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||
|
||||
if (foundIfAlreadyCircuit) {
|
||||
// Rimuovilo nel Circuito
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_AMICIZIA) {
|
||||
|
||||
|
||||
@@ -965,7 +965,7 @@ module.exports = {
|
||||
let typedir = shared_consts.TypeNotifs.TYPEDIR_GROUPS;
|
||||
let typeid = 0;
|
||||
let onlysave = false;
|
||||
let numuseringroup = await User.countUsersInGroup(idapp, groupname);
|
||||
let name = await User.countUsersInGroup(idapp, groupname);
|
||||
|
||||
if (cmd) {
|
||||
if (cmd === shared_consts.GROUPSCMD.SETGROUP) {
|
||||
@@ -1005,6 +1005,72 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
sendNotifCircuitByUsername: async function(
|
||||
cmd, idapp, usernameOrig, usernameDest, username_action, circuitname, path, myreccircuit, isAdmin, username_worked) {
|
||||
|
||||
const {SendNotif} = require('../models/sendnotif');
|
||||
const {User} = require('../models/user');
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
const req = this.getReqByPar(idapp, usernameOrig);
|
||||
|
||||
const user = await User.findOne({idapp, username: usernameDest},
|
||||
{_id: 1, lang: 1});
|
||||
if (user) {
|
||||
|
||||
let lang = user.lang;
|
||||
let paramsObj = {
|
||||
usernameDest,
|
||||
circuitnameDest: circuitname,
|
||||
path,
|
||||
username_action: username_action,
|
||||
singleadmin_username: usernameDest,
|
||||
options: 0,
|
||||
lang,
|
||||
isAdmin,
|
||||
username_worked,
|
||||
};
|
||||
|
||||
let sendnotif = true;
|
||||
let typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
|
||||
let typeid = 0;
|
||||
let onlysave = false;
|
||||
let numuserincircuit = await User.countUsersInCircuit(idapp, circuitname);
|
||||
|
||||
if (cmd) {
|
||||
if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
if (myreccircuit && myreccircuit.createdBy === usernameDest && numuserincircuit <= 1) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||
} else {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED;
|
||||
}
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REFUSE_REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REFUSED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER;
|
||||
// paramsObj.options = MessageOptions.Notify_OnlyToNotifinApp + MessageOptions.Notify_ByBotTelegram;
|
||||
const myuserdata = await User.getUserShortDataByUsername(idapp, username_action);
|
||||
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_CIRCUIT, myuserdata, usernameDest, circuitname,
|
||||
myreccircuit._id);
|
||||
onlysave = false;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ADDED_ADMIN_OFMYGROUP;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN_OFMYGROUP;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sendnotif && typeid > 0) {
|
||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||
await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
sendNotificationByGroupname: async function(idapp, usernameOrig, groupname, cmd, value, telegram, username_action) {
|
||||
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
@@ -1033,7 +1099,7 @@ module.exports = {
|
||||
|
||||
if (!giainviato && (cmd !== shared_consts.GROUPSCMD.REQGROUP)) {
|
||||
// SEND TO THE USER THE NOTIFICATION
|
||||
await this.sendNotifGroupByUsername(cmd, idapp, usernameOrig, usernameOrig, username_action, groupname, false);
|
||||
await this.sendNotifGroupByUsername(cmd, idapp, usernameOrig, usernameOrig, username_action, groupname, null, false);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
@@ -1042,6 +1108,45 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
sendNotificationByCircuit: async function(idapp, usernameOrig, circuitname, cmd, value, telegram, username_action) {
|
||||
|
||||
const {Circuit} = require('../models/circuit');
|
||||
const {User} = require('../models/user');
|
||||
|
||||
const circuit = await Circuit.findOne({idapp, name: circuitname}, {_id: 1, admins: 1, createdBy: 1, path: 1}).lean();
|
||||
if (!circuit)
|
||||
return;
|
||||
|
||||
let giainviato = false;
|
||||
|
||||
try {
|
||||
// SEND TO THE ADMINS THE NOTIFICATIONS
|
||||
for (const singleadmin of circuit.admins) {
|
||||
try {
|
||||
if (singleadmin.username) {
|
||||
if (usernameOrig === singleadmin.username)
|
||||
giainviato = true;
|
||||
|
||||
await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, singleadmin.username, username_action, circuitname,
|
||||
circuit.path, circuit, true);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('sendNotificationByCircuit', e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!giainviato && (cmd !== shared_consts.CIRCUITCMD.REQ)) {
|
||||
// SEND TO THE USER THE NOTIFICATION
|
||||
await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, usernameOrig, username_action, circuitname, circuit.path, null,
|
||||
false);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('sendNotificationByCircuit: ', e);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// **********************
|
||||
// SORT WITH PREV_ID
|
||||
// **********************
|
||||
@@ -1433,6 +1538,32 @@ module.exports = {
|
||||
return query;
|
||||
},
|
||||
|
||||
addQueryIdMatch: function(params) {
|
||||
|
||||
myquery = {};
|
||||
|
||||
if (shared_consts.TABLES_ID_NUMBER.includes(params.table)) {
|
||||
myquery = {
|
||||
$match: {
|
||||
$expr: {
|
||||
$eq: ['$_id', params.myid],
|
||||
},
|
||||
},
|
||||
};
|
||||
} else {
|
||||
myquery = {
|
||||
$match: {
|
||||
$expr: {
|
||||
$eq: ['$_id', mongoose.Types.ObjectId(params.myid)],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return myquery;
|
||||
},
|
||||
|
||||
getQueryTable: function(idapp, params, user) {
|
||||
|
||||
if (typeof params.startRow !== 'number') {
|
||||
@@ -1653,13 +1784,11 @@ module.exports = {
|
||||
numrowend = 1;
|
||||
|
||||
if (params.querytype === shared_consts.QUERYTYPE_MYGROUP || params.querytype === shared_consts.QUERYTYPE_CIRCUIT) {
|
||||
query.push({
|
||||
$match: {
|
||||
$expr: {
|
||||
$eq: ['$_id', params.myid],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const myq = this.addQueryIdMatch(params);
|
||||
if (myq)
|
||||
query.push(myq);
|
||||
|
||||
query.push({$project: {req_users: 1}});
|
||||
const qa1 = this.getLookup(
|
||||
{
|
||||
@@ -1690,14 +1819,13 @@ module.exports = {
|
||||
},
|
||||
);
|
||||
|
||||
} else if (params.querytype === shared_consts.QUERYTYPE_REFUSED_USER_GRP || params.querytype === shared_consts.QUERYTYPE_REFUSED_USER_CIRCUIT) {
|
||||
query.push({
|
||||
$match: {
|
||||
$expr: {
|
||||
$eq: ['$_id', params.myid],
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (params.querytype === shared_consts.QUERYTYPE_REFUSED_USER_GRP || params.querytype ===
|
||||
shared_consts.QUERYTYPE_REFUSED_USER_CIRCUIT) {
|
||||
|
||||
const myq = this.addQueryIdMatch(params);
|
||||
if (myq)
|
||||
query.push(myq);
|
||||
|
||||
query.push({$project: {refused_users: 1}});
|
||||
const qa1 = this.getLookup(
|
||||
{
|
||||
@@ -1861,11 +1989,11 @@ module.exports = {
|
||||
// BINARY CHECK (?): const filter = [{ visibility: { $bitsAnyClear: [1] } }];
|
||||
// if (!User.isAdmin(req.user.perm)) {
|
||||
// not Visibility_Group.HIDDEN
|
||||
if (true && !filteradmin) {
|
||||
if (!filteradmin) {
|
||||
const filter = [
|
||||
{
|
||||
visibility: {
|
||||
$nin: [shared_consts.Visibility_Group.HIDDEN]
|
||||
$nin: [shared_consts.Visibility_Group.HIDDEN],
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -2929,6 +3057,9 @@ module.exports = {
|
||||
|
||||
convertSpecialTags(user, msg) {
|
||||
try {
|
||||
if (!msg)
|
||||
return msg;
|
||||
|
||||
if (!!user) {
|
||||
msg = msg.replace('{appname}', this.getNomeAppByIdApp(user.idapp));
|
||||
msg = msg.replace('{username}', user.username);
|
||||
|
||||
@@ -332,6 +332,16 @@ module.exports = {
|
||||
} else {
|
||||
invia = false;
|
||||
}
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_CIRCUIT) {
|
||||
if (params.circuitnameDest) {
|
||||
addquery = {
|
||||
'profile.mycircuits': {
|
||||
$elemMatch: {circuitname: {$eq: params.circuitnameDest}},
|
||||
},
|
||||
};
|
||||
} else {
|
||||
invia = false;
|
||||
}
|
||||
}
|
||||
|
||||
let numrec = 0;
|
||||
|
||||
@@ -71,7 +71,11 @@ module.exports = {
|
||||
REQ: 2000,
|
||||
SET: 2001,
|
||||
REMOVE_FROM_MYLIST: 2144,
|
||||
REFUSE_REQ: 2145,
|
||||
CANCEL_REQ: 1146,
|
||||
DELETE: 2170,
|
||||
ADDADMIN: 2180,
|
||||
REMOVEADMIN: 2185,
|
||||
},
|
||||
|
||||
REPORT_FILT_RESP: 1,
|
||||
@@ -87,6 +91,7 @@ module.exports = {
|
||||
TAB_SETTINGS: 'settings',
|
||||
TAB_SITES: 'sites',
|
||||
TAB_MYGROUPS: 'mygroups',
|
||||
TAB_MYCIRCUITS: 'circuits',
|
||||
TAB_BOTS: 'bots',
|
||||
TAB_USERS: 'users',
|
||||
|
||||
@@ -115,7 +120,7 @@ module.exports = {
|
||||
|
||||
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps', 'myskills', 'mygoods'],
|
||||
|
||||
TABLES_USER_INCLUDE_MY: ['mygroups'],
|
||||
TABLES_USER_INCLUDE_MY: ['mygroups', 'circuits'],
|
||||
TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
|
||||
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
|
||||
@@ -125,6 +130,7 @@ module.exports = {
|
||||
TABLES_ADV_NOTIFICATION: ['myskills', 'myhosps', 'mygoods'],
|
||||
TABLES_EVENTS_NOTIFICATION: ['mybachecas'],
|
||||
TABLES_GROUPS_NOTIFICATION: ['mygroups'],
|
||||
TABLES_CIRCUITS_NOTIFICATION: ['circuits'],
|
||||
|
||||
TABLES_ID_NUMBER: [
|
||||
'permissions',
|
||||
@@ -144,7 +150,6 @@ module.exports = {
|
||||
'myhosps',
|
||||
'mygoods',
|
||||
'mygroups',
|
||||
'circuits',
|
||||
'movements'],
|
||||
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||
TABLES_CREATEDBY: ['mygroups', 'circuits'],
|
||||
@@ -238,6 +243,7 @@ module.exports = {
|
||||
SEND_TO_PAOLO: 20,
|
||||
SEND_TO_USER: 25,
|
||||
SEND_TO_GROUP: 30,
|
||||
SEND_TO_CIRCUIT: 35,
|
||||
SEND_TO_MYSELF: 40,
|
||||
SEND_TO_TELEG_NO_USERNAME_TELEG: 50,
|
||||
SEND_TO_TELEG_NO_VERIF_BY_APORTADOR: 60,
|
||||
@@ -260,6 +266,7 @@ module.exports = {
|
||||
REGISTRATION: 6,
|
||||
RICHIESTA_GRUPPO: 10,
|
||||
RICHIESTA_AMICIZIA: 15,
|
||||
RICHIESTA_CIRCUIT: 20,
|
||||
},
|
||||
|
||||
OrderStatus: {
|
||||
@@ -325,6 +332,15 @@ module.exports = {
|
||||
STATUS_GROUPS_REMOVED: 7,
|
||||
},
|
||||
|
||||
CircuitsNotif: {
|
||||
STATUS_NEW: 51,
|
||||
STATUS_ACCEPTED: 53,
|
||||
STATUS_REFUSED: 54,
|
||||
STATUS_BLOCKED: 55,
|
||||
STATUS_DELETED: 56,
|
||||
STATUS_REMOVED: 57,
|
||||
},
|
||||
|
||||
TypeNotifs: {
|
||||
TYPEDIR_BACHECA: 1,
|
||||
ID_BACHECA_NEW_GOOD: 1,
|
||||
@@ -354,6 +370,15 @@ module.exports = {
|
||||
ID_GROUP_REMOVED_ADMIN_OFMYGROUP: 256,
|
||||
|
||||
TYPEDIR_CIRCUITS: 5,
|
||||
ID_CIRCUIT_NEW_REC: 1,
|
||||
ID_CIRCUIT_ACCEPTED: 2,
|
||||
ID_CIRCUIT_REFUSED: 4,
|
||||
ID_CIRCUIT_REQUEST_TO_ENTER: 8,
|
||||
ID_CIRCUIT_BLOCK_USER: 16,
|
||||
ID_CIRCUIT_DELETE_USER: 32,
|
||||
ID_CIRCUIT_REMOVED: 64,
|
||||
ID_CIRCUIT_ADDED_ADMIN: 128,
|
||||
ID_CIRCUIT_REMOVED_ADMIN: 256,
|
||||
|
||||
TYPEDIR_BOOKING: 6,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user