Creare Visualizzazione Nuova della scheda della MySkill (Bacheca)

This commit is contained in:
paoloar77
2022-02-14 15:38:34 +01:00
parent 621848d9d7
commit 6bea6828ff
4 changed files with 50 additions and 35 deletions

View File

@@ -1417,7 +1417,7 @@ UserSchema.statics.setFriendsCmd = async function(
} }
if (ris) { if (ris) {
// Invia una notifica alla persona // Invia una notifica alla persona
tools.sendNotificationByUsername(idapp, usernameDest, cmd, true); tools.sendNotificationByUsername(idapp, usernameDest, cmd, true, usernameOrig);
} }
} else { } else {
if (foundIfAlreadyAskFriend) { if (foundIfAlreadyAskFriend) {

View File

@@ -34,7 +34,7 @@ const Product = require('../models/product');
const Variant = require('../models/variant'); const Variant = require('../models/variant');
const TypedError = require('../modules/ErrorHandler'); const TypedError = require('../modules/ErrorHandler');
const { MyGroup } = require('../models/mygroup'); const {MyGroup} = require('../models/mygroup');
const mongoose = require('mongoose').set('debug', false); const mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers'); const Subscription = mongoose.model('subscribers');
@@ -192,7 +192,8 @@ router.post('/', async (req, res) => {
recuser = await User.findByCellAndNameSurname(user.idapp, user.profile.cell, recuser = await User.findByCellAndNameSurname(user.idapp, user.profile.cell,
user.name, user.surname); user.name, user.surname);
if (recuser && user.name !== '' && user.surname !== '' && user.profile.cell !== '') { if (recuser && user.name !== '' && user.surname !== '' &&
user.profile.cell !== '') {
console.log('UTENTE GIA ESISTENTE:\n'); console.log('UTENTE GIA ESISTENTE:\n');
console.log(user); console.log(user);
// User already registered! // User already registered!
@@ -211,16 +212,20 @@ router.post('/', async (req, res) => {
// nomeaportador_corretto = recextra.aportador_solidario_originale_name_surname; // nomeaportador_corretto = recextra.aportador_solidario_originale_name_surname;
// } // }
const id_aportador = await User.getIdByUsername(user.idapp,
user.aportador_solidario);
const id_aportador = await User.getIdByUsername(user.idapp, user.aportador_solidario);
if (!id_aportador && tools.getAskToVerifyReg(body.idapp)) { if (!id_aportador && tools.getAskToVerifyReg(body.idapp)) {
// Si sta tentando di registrare una persona sotto che non corrisponde! // Si sta tentando di registrare una persona sotto che non corrisponde!
let msg = 'Il link di registrazione non sembra risultare valido.<br>invitante: ' + user.aportador_solidario + '<br>username: ' + user.username; let msg = 'Il link di registrazione non sembra risultare valido.<br>invitante: ' +
user.aportador_solidario + '<br>username: ' + user.username;
await telegrambot.sendMsgTelegramToTheManagers(user.idapp, msg); await telegrambot.sendMsgTelegramToTheManagers(user.idapp, msg);
res.status(400).send({ code: server_constants.RIS_CODE_USER_APORTADOR_NOT_VALID, msg: '' }); res.status(400).
send({
code: server_constants.RIS_CODE_USER_APORTADOR_NOT_VALID,
msg: '',
});
return 1; return 1;
} }
@@ -335,12 +340,17 @@ router.post('/profile', authenticate, (req, res) => {
//++Todo: controlla che tipo di dati ha il permesso di leggere //++Todo: controlla che tipo di dati ha il permesso di leggere
return User.getUserProfileByUsername(idapp, username, req.user.username, false, req.user.perm).then((ris) => { return User.getUserProfileByUsername(idapp, username, req.user.username, false, req.user.perm).
res.send(ris); then((ris) => {
}).catch((e) => {
tools.mylog('ERRORE IN Profile: ' + e.message); return User.getFriendsByUsername(idapp, req.user.username).then((friends) => {
res.status(400).send(); res.send({user: ris, friends });
}); });
}).catch((e) => {
tools.mylog('ERRORE IN Profile: ' + e.message);
res.status(400).send();
});
}); });
@@ -498,7 +508,6 @@ router.post('/groups', authenticate, (req, res) => {
idapp = req.body.idapp; idapp = req.body.idapp;
locale = req.body.locale; locale = req.body.locale;
return MyGroup.getGroupsByUsername(idapp, username, req).then((ris) => { return MyGroup.getGroupsByUsername(idapp, username, req).then((ris) => {
res.send(ris); res.send(ris);
}).catch((e) => { }).catch((e) => {
@@ -520,16 +529,19 @@ router.post('/friends/cmd', authenticate, (req, res) => {
if (!User.isAdmin(req.user.perm) || !User.isManager(req.user.perm)) { if (!User.isAdmin(req.user.perm) || !User.isManager(req.user.perm)) {
// If without permissions, exit // If without permissions, exit
if (usernameOrig !== usernameLogged) { if (usernameOrig !== usernameLogged) {
return res.status(404).send({code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: ''}); return res.status(404).
send({code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: ''});
} }
} }
return User.setFriendsCmd(idapp, usernameOrig, usernameDest, cmd, value).then((ris) => { return User.setFriendsCmd(idapp, usernameOrig, usernameDest, cmd, value).
res.send(ris); then((ris) => {
}).catch((e) => { res.send(ris);
tools.mylog('ERRORE IN Friends/cmd: ' + e.message); }).
res.status(400).send(); catch((e) => {
}); tools.mylog('ERRORE IN Friends/cmd: ' + e.message);
res.status(400).send();
});
}); });
@@ -545,16 +557,19 @@ router.post('/groups/cmd', authenticate, (req, res) => {
if (!User.isAdmin(req.user.perm) || !User.isManager(req.user.perm)) { if (!User.isAdmin(req.user.perm) || !User.isManager(req.user.perm)) {
// If without permissions, exit // If without permissions, exit
if (usernameOrig !== usernameLogged) { if (usernameOrig !== usernameLogged) {
return res.status(404).send({code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: ''}); return res.status(404).
send({code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: ''});
} }
} }
return User.setGroupsCmd(idapp, usernameOrig, groupnameDest, cmd, value).then((ris) => { return User.setGroupsCmd(idapp, usernameOrig, groupnameDest, cmd, value).
res.send(ris); then((ris) => {
}).catch((e) => { res.send(ris);
tools.mylog('ERRORE IN groups/cmd: ' + e.message); }).
res.status(400).send(); catch((e) => {
}); tools.mylog('ERRORE IN groups/cmd: ' + e.message);
res.status(400).send();
});
}); });
@@ -892,10 +907,10 @@ async function eseguiDbOp(idapp, mydata, locale) {
await mytable.DuplicateAllRecords(idapporig, idappdest). await mytable.DuplicateAllRecords(idapporig, idappdest).
then((numrec) => { then((numrec) => {
// tools.mylogshow(' REC TO MODIFY: ', rec); // tools.mylogshow(' REC TO MODIFY: ', rec);
numrectot += numrec numrectot += numrec;
}); });
} }
}catch (e){ } catch (e) {
console.log('e', e); console.log('e', e);
} }

View File

@@ -3,7 +3,7 @@ const tools = require('../tools/general');
const appTelegram = [tools.FREEPLANET, tools.ISP]; const appTelegram = [tools.FREEPLANET, tools.ISP];
const appTelegram_TEST = [tools.FREEPLANET, tools.PDNM, tools.ISP]; const appTelegram_TEST = [tools.FREEPLANET, tools.PDNM, tools.ISP];
const appTelegram_DEVELOP = [tools.PDNM]; const appTelegram_DEVELOP = [tools.ISP];
const appTelegramFinti = ['2', tools.CNM]; const appTelegramFinti = ['2', tools.CNM];
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET]; const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];

View File

@@ -803,7 +803,7 @@ module.exports = {
}, },
sendNotificationByUsername: async function(idapp, username, cmd, telegram) { sendNotificationByUsername: async function(idapp, username, cmd, telegram, usernameOrig) {
var {User} = require('../models/user'); var {User} = require('../models/user');
@@ -821,8 +821,8 @@ module.exports = {
let actions = []; let actions = [];
if (cmd) { if (cmd) {
if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) { if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
descr = printf(this.get__('RICHIESTA_AMICIZIA', lang), username); descr = printf(this.get__('RICHIESTA_AMICIZIA', lang), usernameOrig);
openUrl = '/my/' + username; openUrl = '/my/' + usernameOrig;
tag = 'reqfriends'; tag = 'reqfriends';
} }
} }