fix: ordinamento membri (namecomplete (concat: name, surname, username)
This commit is contained in:
@@ -132,6 +132,7 @@ const textlang = {
|
||||
'CREATO_NUOVO_GRUPPO': '✅ Hai appena creato un nuovo Gruppo chiamato %s',
|
||||
'ACCETTATO_NOTIFICA_ADMINS': '✅ l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
||||
'GROUP_REQUEST': 'Richiesta di entrare nel Gruppo %s da parte di %s',
|
||||
"CLICCA_QUI": "CLICCA QUI",
|
||||
},
|
||||
si: {},
|
||||
es: {
|
||||
@@ -883,7 +884,7 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
sendNotificationByUsername: async function (idapp, username, cmd, telegram, usernameOrig) {
|
||||
sendNotificationByUsername: async function (idapp, username, cmd, telegram, usernameOrig, recObjCreator) {
|
||||
|
||||
var { User } = require('../models/user');
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
@@ -919,22 +920,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.SETHANDSHAKE) {
|
||||
descr = printf(this.get__('RICHIESTA_HANDSHAKE', lang), usernameOrig);
|
||||
openUrl = '/my/' + usernameOrig;
|
||||
tag = 'reqhandshake';
|
||||
|
||||
const userrecDest = await User.getUserShortDataByUsername(idapp, usernameOrig);
|
||||
|
||||
const foundIfAlreadyHandShake = await User.isMyHandShake(idapp, username, usernameOrig);
|
||||
|
||||
if (userrecDest) {
|
||||
sendmynotif = false; // non lo rimandare 2 volte !
|
||||
if (!foundIfAlreadyHandShake) {
|
||||
// SEND TELEGRAM NOTIFICATION
|
||||
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_HANDSHAKE, userrecDest, username, usernameOrig);
|
||||
}
|
||||
}
|
||||
|
||||
// const foundIfAlready = await User.isMyHandShake(idapp, username, usernameOrig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1770,6 +1756,11 @@ module.exports = {
|
||||
return myrec ? myrec.id : -1
|
||||
},
|
||||
|
||||
getTableByNumTab(numtab) {
|
||||
const myrec = shared_consts.MYTABS.find((rec) => rec.id === numtab)
|
||||
return myrec ? myrec.table : ''
|
||||
},
|
||||
|
||||
getGroupnameLookupPipeLine(params, proj) {
|
||||
|
||||
let myquery = [
|
||||
@@ -1811,6 +1802,17 @@ module.exports = {
|
||||
if (params.af_objId_tab) {
|
||||
const myobj = {};
|
||||
myobj['myId' + num] = { '$toObjectId': '$' + params.lk_LF };
|
||||
|
||||
if (params.lk_tab === 'users') {
|
||||
myobj.namecomplete = {
|
||||
$concat: [
|
||||
{ $toLower: "$name" },
|
||||
{ $toLower: "$surname" },
|
||||
{ $toLower: "$username" },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
query.push(
|
||||
{ '$addFields': myobj },
|
||||
);
|
||||
@@ -1971,7 +1973,7 @@ module.exports = {
|
||||
{
|
||||
$project: {
|
||||
username: 1, name: 1, surname: 1, 'profile.resid_province': 1, 'profile.img': 1,
|
||||
'profile.qualifica': 1,
|
||||
'profile.qualifica': 1,
|
||||
}
|
||||
},
|
||||
],
|
||||
@@ -2202,14 +2204,6 @@ module.exports = {
|
||||
// console.log('QUERYMATCH', query[0].$match.or);
|
||||
// console.log('filter', params.filter);
|
||||
|
||||
if (params.sortBy) {
|
||||
// maybe we want to sort by blog title or something
|
||||
const mysort = { $sort: params.sortBy };
|
||||
// console.log('sortBy', params.sortBy);
|
||||
// console.table(mysort);
|
||||
query.push(mysort);
|
||||
}
|
||||
|
||||
let numrowend = params.endRow - params.startRow;
|
||||
if (numrowend < 0)
|
||||
numrowend = 1;
|
||||
@@ -2611,6 +2605,14 @@ module.exports = {
|
||||
if (q1) query = [...query, ...q1];
|
||||
}
|
||||
|
||||
if (params.sortBy) {
|
||||
// maybe we want to sort by blog title or something
|
||||
const mysort = { $sort: params.sortBy };
|
||||
// console.log('sortBy', params.sortBy);
|
||||
// console.table(mysort);
|
||||
query.push(mysort);
|
||||
}
|
||||
|
||||
query.push(
|
||||
{
|
||||
$group: {
|
||||
@@ -3854,6 +3856,11 @@ module.exports = {
|
||||
|
||||
let myhost = this.getHostByIdApp(params.idapp);
|
||||
|
||||
if (params.textaddTelegram) {
|
||||
if (params.openUrl)
|
||||
content = content + '\n' + '<a href="' + myhost + params.openUrl + '">' + params.textaddTelegram + '</a>';
|
||||
}
|
||||
|
||||
/*if (params.openUrl)
|
||||
content = content + '\n' + '<a href="' + myhost + params.openUrl + '">' + i18n.__('OPEN PAGE') + '</a>';
|
||||
|
||||
@@ -3867,5 +3874,5 @@ module.exports = {
|
||||
return `<a href='${link}'>${username}</a>`;
|
||||
},
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -227,6 +227,8 @@ module.exports = {
|
||||
|
||||
const sendemail = require('../sendemail');
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
/// ... rivedere il crea gruppo... notifiche...
|
||||
try {
|
||||
if (!recnotif.typesend) {
|
||||
@@ -248,7 +250,8 @@ module.exports = {
|
||||
usernameDest: recnotif.usernameDest ? recnotif.usernameDest : recnotif.dest,
|
||||
tag: recnotif.tag ? recnotif.tag : '',
|
||||
actions: recnotif.actions ? recnotif.actions : [],
|
||||
id: recnotif._id
|
||||
id: recnotif._id,
|
||||
textaddTelegram: recnotif.textaddTelegram ? recnotif.textaddTelegram : '',
|
||||
};
|
||||
|
||||
if (tools.isBitActive(recnotif.typesend, shared_consts.MessageOptions.Notify_ByPushNotification) && this.checkifSendPushNotification) {
|
||||
@@ -287,6 +290,8 @@ module.exports = {
|
||||
try {
|
||||
console.log('SendMsgToParam', params.typesend);
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
let textsent = '';
|
||||
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
@@ -536,5 +541,66 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
getNumFavoriteByIdObj: async function (idapp, numtab, id) {
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
let query = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
"profile.favorite": {
|
||||
$elemMatch:
|
||||
{ id, tab: numtab }
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{
|
||||
_id: null,
|
||||
count: { $sum: 1 },
|
||||
}
|
||||
},
|
||||
{ $project: { _id: 0 } }
|
||||
];
|
||||
|
||||
try {
|
||||
const [result] = await User.aggregate(query);
|
||||
|
||||
return result ? result.count : 0;
|
||||
} catch (err) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
},
|
||||
|
||||
getUserCreatorByNumTabAndId: async function (idapp, id, numtab) {
|
||||
try {
|
||||
const table = tools.getTableByNumTab(numtab);
|
||||
const mytable = this.getTableByTableName(table);
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
if (mytable) {
|
||||
const rec = await mytable.findOne({ _id: id, idapp }, { username: 1, lang: 1, userId: 1, descr: 1 });
|
||||
if (rec) {
|
||||
const recuser = await User.getUserById(idapp, rec.userId);
|
||||
|
||||
let numfav = await this.getNumFavoriteByIdObj(idapp, numtab, id);
|
||||
let exist = numfav > 1;
|
||||
if (recuser)
|
||||
return { userId: rec.userId, username: recuser.username, descr: rec.descr, id: rec._id, table, exist, numfav };
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Err:', e);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -95,6 +95,10 @@ module.exports = {
|
||||
SENDCOINS_REFUSE_SENT: 2222,
|
||||
},
|
||||
|
||||
USERCMD: {
|
||||
FAVORITE: 3001,
|
||||
},
|
||||
|
||||
REPORT_FILT_RESP: 1,
|
||||
REPORT_FILT_ATTIVITA: 2,
|
||||
|
||||
@@ -449,6 +453,9 @@ module.exports = {
|
||||
TYPEDIR_HANDSHAKE: 10,
|
||||
ID_HANDSHAKE_ACCEPTED: 2,
|
||||
|
||||
TYPEDIR_FAVORITE: 11,
|
||||
ID_FAVORITE_ADDED: 1,
|
||||
|
||||
TYPEDIR_TEST: 444,
|
||||
ID_TEST_NEW_REC: 1,
|
||||
},
|
||||
@@ -523,7 +530,11 @@ module.exports = {
|
||||
{
|
||||
'dir': 5,
|
||||
'value': 1
|
||||
}
|
||||
},
|
||||
{
|
||||
'dir': 11,
|
||||
'value': 1
|
||||
},
|
||||
],
|
||||
|
||||
CIRCUIT_STATUS: {
|
||||
@@ -569,6 +580,8 @@ module.exports = {
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
namecomplete: 1,
|
||||
date_reg: 1,
|
||||
};
|
||||
|
||||
if (proj_add)
|
||||
@@ -577,4 +590,26 @@ module.exports = {
|
||||
return proj;
|
||||
},
|
||||
|
||||
getDirectoryByTable(table, barre = false) {
|
||||
let add = '';
|
||||
if (barre)
|
||||
add = '/';
|
||||
|
||||
if (table === 'myskills') {
|
||||
return add + 'myservice' + add
|
||||
} else if (table === 'mybachecas') {
|
||||
return add + 'mypage' + add
|
||||
} else if (table === 'myhosps') {
|
||||
return add + 'myhosps' + add
|
||||
} else if (table === 'mygoods') {
|
||||
return add + 'mygood' + add
|
||||
} else if (table === 'mygroups') {
|
||||
return add + 'grp' + add
|
||||
} else if (table === 'circuits') {
|
||||
return add + 'circuit' + add
|
||||
}
|
||||
|
||||
return ''
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user