fix: ordinamento membri (namecomplete (concat: name, surname, username)
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user