Sistemazioni varie BUGS
This commit is contained in:
@@ -549,8 +549,11 @@ UserSchema.statics.findByCredentials = function(idapp, username, password, pwdcr
|
||||
const User = this;
|
||||
let pwd = '';
|
||||
|
||||
let regexp = new RegExp(`${username}`, 'i');
|
||||
|
||||
return User.findOne({
|
||||
idapp, username: username,
|
||||
idapp,
|
||||
username: {$regex: regexp},
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}},
|
||||
@@ -641,13 +644,14 @@ UserSchema.statics.findByUsername = async function(idapp, username, alsoemail, o
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getUserShortDataByUsername = async function(
|
||||
idapp, username) {
|
||||
UserSchema.statics.getUserShortDataByUsername = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
let regexp = new RegExp(`${username}`, 'i');
|
||||
|
||||
const myrec = await User.findOne({
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
username: {$regex: regexp},
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {
|
||||
idapp: 1,
|
||||
@@ -898,7 +902,11 @@ UserSchema.statics.setVerifiedByAportador = async function(
|
||||
|
||||
const userver = await User.findOne(myquery, {verified_by_aportador: 1}).lean();
|
||||
|
||||
if (userver.verified_by_aportador !== valuebool) {
|
||||
let scrivi = true;
|
||||
if (userver) {
|
||||
scrivi = userver.verified_by_aportador !== valuebool;
|
||||
}
|
||||
if (scrivi) {
|
||||
const myrec = await User.findOneAndUpdate(myquery,
|
||||
{$set: {'verified_by_aportador': valuebool}}, {new: false});
|
||||
|
||||
@@ -2080,7 +2088,7 @@ UserSchema.statics.SetTelegramIdSuccess = async function(idapp, id, teleg_id) {
|
||||
if (record) {
|
||||
return User.findOne({
|
||||
idapp,
|
||||
_id: id
|
||||
_id: id,
|
||||
}).lean();
|
||||
}
|
||||
});
|
||||
@@ -2173,12 +2181,11 @@ UserSchema.statics.getNameSurnameByUsername = async function(
|
||||
UserSchema.statics.getIdByUsername = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
let regexp = new RegExp(`${username}`, 'i')
|
||||
let regexp = new RegExp(`${username}`, 'i');
|
||||
|
||||
return User.findOne({
|
||||
idapp,
|
||||
username :
|
||||
{ $regex: regexp },
|
||||
username: {$regex: regexp},
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {username: 1, _id: 1}).then((rec) => {
|
||||
return (!!rec) ? rec._id.toString() : '';
|
||||
@@ -2190,12 +2197,12 @@ UserSchema.statics.getIdByUsername = async function(idapp, username) {
|
||||
UserSchema.statics.getRealUsernameByUsername = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
let regexp = new RegExp(`${username}`, 'i')
|
||||
let regexp = new RegExp(`${username}`, 'i');
|
||||
|
||||
return User.findOne({
|
||||
idapp,
|
||||
username :
|
||||
{ $regex: regexp },
|
||||
username:
|
||||
{$regex: regexp},
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {username: 1, _id: 1}).then((rec) => {
|
||||
return (!!rec) ? rec.username : '';
|
||||
@@ -2548,6 +2555,21 @@ UserSchema.statics.getUsersRegistered = async function(idapp) {
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersOnLineToday = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
let starttoday = new Date();
|
||||
starttoday.setHours(6, 0, 0, 0);
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
lasttimeonline: {$gt: starttoday},
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
};
|
||||
|
||||
/*
|
||||
UserSchema.statics.getUsersQualified = async function (idapp, numinvitati) {
|
||||
const User = this;
|
||||
@@ -2648,8 +2670,8 @@ UserSchema.statics.getUsersAutorizzare = async function(idapp) {
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
'profile.teleg_id': {$gt: 0},
|
||||
$or: [{verified_by_aportador: {$exists: false}}, {verified_by_aportador: {$exists: true, $eq: false}}],
|
||||
'profile.teleg_id': { $gt: 0 },
|
||||
verified_by_aportador: { $exists: false },
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
|
||||
@@ -54,5 +54,11 @@ module.exports = {
|
||||
{_id: 52, idSectorGood: [15], descr: 'Abbigliamento'},
|
||||
{_id: 53, idSectorGood: [15], descr: 'Attrezzature e accessori Sport'},
|
||||
{_id: 54, idSectorGood: [15], descr: 'Bici e accessori'},
|
||||
{_id: 55, idSectorGood: [17], descr: 'Edilizia'},
|
||||
{_id: 56, idSectorGood: [17], descr: 'Cucina'},
|
||||
{_id: 57, idSectorGood: [17], descr: 'Modellismo'},
|
||||
{_id: 58, idSectorGood: [17], descr: 'Cucito'},
|
||||
{_id: 59, idSectorGood: [17], descr: 'Pulizia'},
|
||||
{_id: 60, idSectorGood: [17], descr: 'Per Imbiancare'},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -15,5 +15,8 @@ module.exports = {
|
||||
{_id: 13, descr: 'Musica e Film'},
|
||||
{_id: 14, descr: 'Scuola e Ufficio'},
|
||||
{_id: 15, descr: 'Sport'},
|
||||
{_id: 16, descr: 'Un po\' di Tutto'}],
|
||||
{_id: 16, descr: 'Un po\' di Tutto'},
|
||||
{_id: 17, descr: 'Attrezzature'},
|
||||
|
||||
],
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ router.post('/load', async (req, res) => {
|
||||
|
||||
let datastat = {
|
||||
num_reg: await User.getUsersRegistered(idapp),
|
||||
online_today: await User.getUsersOnLineToday(idapp),
|
||||
// num_passeggeri: await 0,
|
||||
// num_imbarcati: 0,
|
||||
// email_non_verif: await User.getEmailNotVerified(idapp),
|
||||
|
||||
@@ -89,6 +89,10 @@ router.post('/', async (req, res) => {
|
||||
const user = new User(body);
|
||||
user.ipaddr = tools.getiPAddressUser(req);
|
||||
|
||||
if ((user.aportador_solidario === 'tuo_username') || (user.aportador_solidario === '{username}')) {
|
||||
user.aportador_solidario = 'paoloar77';
|
||||
}
|
||||
|
||||
// tools.mylog("LANG PASSATO = " + user.lang, "IDAPP", user.idapp);
|
||||
|
||||
if (!tools.isAlphaNumericAndSpecialCharacter(body.username) ||
|
||||
@@ -551,12 +555,12 @@ router.post('/groups', authenticate, (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/friends/cmd', authenticate, (req, res) => {
|
||||
router.post('/friends/cmd', authenticate, async (req, res) => {
|
||||
const usernameLogged = req.user.username;
|
||||
const idapp = req.body.idapp;
|
||||
const locale = req.body.locale;
|
||||
const usernameOrig = req.body.usernameOrig;
|
||||
const usernameDest = req.body.usernameDest;
|
||||
let usernameOrig = req.body.usernameOrig;
|
||||
let usernameDest = req.body.usernameDest;
|
||||
const cmd = req.body.cmd;
|
||||
const value = req.body.value;
|
||||
|
||||
@@ -568,6 +572,9 @@ router.post('/friends/cmd', authenticate, (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
usernameOrig = await User.getRealUsernameByUsername(idapp, usernameOrig);
|
||||
usernameDest = await User.getRealUsernameByUsername(idapp, usernameDest);
|
||||
|
||||
return User.setFriendsCmd(idapp, usernameOrig, usernameDest, cmd, value).
|
||||
then((ris) => {
|
||||
res.send(ris);
|
||||
|
||||
@@ -76,6 +76,8 @@ const emo = {
|
||||
};
|
||||
|
||||
MsgBot = {
|
||||
OK: ['si', 'ok'],
|
||||
CUORE: ['❤️', '💚️', '💜'],
|
||||
CIAO: [
|
||||
'ciao',
|
||||
'ciaoo',
|
||||
@@ -129,6 +131,7 @@ MsgBot = {
|
||||
HAHA: ['hahaha', 'ahah', '😂'],
|
||||
MI_AMI: ['mi ami'],
|
||||
TI_AMO: ['ti amo', 'ti adoro', 'ti lovvo'],
|
||||
PREGO: [ 'prego', 'Prego ! 💋💋💋'],
|
||||
GRAZIE: [
|
||||
'grazie ainy',
|
||||
'grazie',
|
||||
@@ -1475,6 +1478,8 @@ class Telegram {
|
||||
risp = 'Eh non te lo posso dire! ' + emo.JOY;
|
||||
} else if (MsgBot.GRAZIE.includes(testo.replace('!', ''))) {
|
||||
risp = 'Prego ! ' + emo.KISS + emo.KISS + emo.KISS;
|
||||
} else if (MsgBot.PREGO.includes(testo.replace('!', ''))) {
|
||||
risp = 'Grazie a te ! ' + emo.KISS + emo.KISS + emo.KISS;
|
||||
} else if (MsgBot.MI_AMI.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = ' Tantissimo! ' + emo.KISS + emo.GIFT_HEART + emo.GIFT_HEART +
|
||||
emo.GIFT_HEART;
|
||||
@@ -1542,8 +1547,11 @@ class Telegram {
|
||||
} else if (MsgBot.PAROLACCE.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = 'Da te non me l\'aspettavo proprio !! ' + emo.INNOCENT +
|
||||
emo.CROSS_ROSSA;
|
||||
} else if (MsgBot.HAHA.find((rec) => testo.indexOf(rec) > -1) &&
|
||||
testo.length < 8) {
|
||||
} else if (MsgBot.OK.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = '👍🏻';
|
||||
} else if (MsgBot.CUORE.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = '❤️💚💜';
|
||||
} else if (MsgBot.HAHA.find((rec) => testo.indexOf(rec) > -1) && testo.length < 8) {
|
||||
risp = emo.JOY + emo.JOY + emo.JOY;
|
||||
} else if (testo.length >= 10) {
|
||||
noanswer = true;
|
||||
@@ -1595,7 +1603,7 @@ class Telegram {
|
||||
if (risp !== '' && risp !== shared_consts.RIS_OK) {
|
||||
rec.numdomande++;
|
||||
if (!noanswer) {
|
||||
await tools.snooze(500);
|
||||
await tools.snooze(300);
|
||||
risp = '[BOT' + emo.ROBOT_FACE + ' scrive]:\n' + risp;
|
||||
}
|
||||
this._inviaMsg(id, risp, keyboard);
|
||||
@@ -2939,8 +2947,7 @@ class Telegram {
|
||||
let isAdmin = user ? user.profile.manage_telegram && user.username ===
|
||||
'paoloar77' : false;
|
||||
const isManager = user ? user.profile.manage_telegram : false;
|
||||
const isVerified = user ? user.profile.teleg_id > 0 &&
|
||||
user.verified_by_aportador : false;
|
||||
const isVerified = user ? user.profile.teleg_id > 0 && user.verified_by_aportador : false;
|
||||
|
||||
recuser.menuDb = await MyBot.findAllIdApp(idapp);
|
||||
|
||||
@@ -3533,6 +3540,10 @@ if (true) {
|
||||
const status = await myclTelegram.setInit(msg);
|
||||
|
||||
const rec = myclTelegram.getRecInMem(msg);
|
||||
|
||||
data.username = await User.getRealUsernameByUsername(idapp, data.username);
|
||||
data.userDest = await User.getRealUsernameByUsername(idapp, data.userDest);
|
||||
|
||||
const user = await User.getUserShortDataByUsername(idapp, data.username);
|
||||
const userDest = data.userDest ? await User.getUserShortDataByUsername(idapp, data.userDest) : null;
|
||||
|
||||
|
||||
@@ -1413,10 +1413,7 @@ module.exports = {
|
||||
filtriadded.push({verified_email: false});
|
||||
if (params.filterand.includes(shared_consts.FILTER_USER_NO_VERIFIED_APORTADOR))
|
||||
filtriadded.push({
|
||||
$or: [
|
||||
{verified_by_aportador: {$exists: false}},
|
||||
{verified_by_aportador: {$exists: true, $eq: false}}],
|
||||
|
||||
verified_by_aportador: {$exists: false},
|
||||
});
|
||||
if (params.filterand.includes(shared_consts.FILTER_USER_WITHOUT_USERNAME_TELEGRAM))
|
||||
filtriadded.push({
|
||||
|
||||
@@ -234,9 +234,7 @@ module.exports = {
|
||||
'profile.teleg_id': {$gt: 1},
|
||||
'profile.username_telegram': {$exists: true},
|
||||
$expr: { $gt: [ { $strLenCP: "$profile.username_telegram" }, 3 ] },
|
||||
$or: [
|
||||
{'verified_by_aportador': {$exists: false}},
|
||||
{'verified_by_aportador': {$exists: true, $eq: false}}],
|
||||
'verified_by_aportador': {$exists: false}
|
||||
};
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_GROUP) {
|
||||
if (params.groupnameDest) {
|
||||
|
||||
Reference in New Issue
Block a user