- Add to Friends
- remove from Friend list - Cancel Ask Friend .... OK !
This commit is contained in:
@@ -8,6 +8,8 @@ require('../config/config');
|
||||
|
||||
require('../models/subscribers');
|
||||
|
||||
const printf = require('util').format;
|
||||
|
||||
const Site = require('../models/site');
|
||||
|
||||
const CryptoJS = require('crypto-js');
|
||||
@@ -117,9 +119,9 @@ const textlang = {
|
||||
'NAVE': 'NAVE',
|
||||
'MSG_SEND_FROM': 'Msg Inviato da',
|
||||
'ZOOM_CONFERMATO': 'Sei stato confermato ad aver visto la Video Conferenza di Benvenuto!',
|
||||
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
|
||||
},
|
||||
si: {
|
||||
},
|
||||
si: {},
|
||||
es: {
|
||||
'L\'Email è già stata Verificata': 'El correo electrónico ya ha sido verificado',
|
||||
'Nuova Registrazione': 'Nuevo Registro',
|
||||
@@ -670,11 +672,12 @@ module.exports = {
|
||||
publicKey: process.env.PUBLIC_VAPI_KEY,
|
||||
},
|
||||
TTL: payload.ttl,
|
||||
headers: {}
|
||||
headers: {},
|
||||
};
|
||||
|
||||
// Pass object into sendNotification
|
||||
return webpush.sendNotification(subscription, JSON.stringify(payload), pushOptions).
|
||||
return webpush.sendNotification(subscription, JSON.stringify(payload),
|
||||
pushOptions).
|
||||
catch(err => {
|
||||
if (err.statusCode === 410) {
|
||||
// Gone: is not valid anymore (Expired probably!), so I have to delete from my db
|
||||
@@ -794,6 +797,45 @@ module.exports = {
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
sendNotificationByUsername: async function(idapp, username, cmd, telegram) {
|
||||
|
||||
var {User} = require('../models/user');
|
||||
|
||||
const user = await User.findOne({idapp, username}, {_id: 1, lang: 1});
|
||||
if (!user)
|
||||
return;
|
||||
|
||||
let userId = user._id;
|
||||
let lang = user.lang;
|
||||
|
||||
let title = this.getNomeAppByIdApp(idapp);
|
||||
let descr = '';
|
||||
let openUrl = '/';
|
||||
let tag = '';
|
||||
let actions = [];
|
||||
if (cmd) {
|
||||
if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
|
||||
descr = printf(this.get__('RICHIESTA_AMICIZIA', lang) , username);
|
||||
openUrl = '/my/' + username;
|
||||
tag = 'reqfriends';
|
||||
}
|
||||
}
|
||||
|
||||
if (userId) {
|
||||
this.sendNotificationToUser(userId, title, descr, openUrl, '', tag, actions);
|
||||
}
|
||||
|
||||
if (telegram) {
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
const idtelegram = await User.TelegIdByUsername(idapp, username);
|
||||
|
||||
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, descr);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// **********************
|
||||
// SORT WITH PREV_ID
|
||||
// **********************
|
||||
@@ -929,7 +971,8 @@ module.exports = {
|
||||
const myapp =
|
||||
this.getApps().find(item => item.idapp === idapp);
|
||||
if (myapp) {
|
||||
let siteport = (myapp.portapp && myapp.portapp !== '0') ? (':' + myapp.portapp) : '';
|
||||
let siteport = (myapp.portapp && myapp.portapp !== '0') ? (':' +
|
||||
myapp.portapp) : '';
|
||||
|
||||
if (process.env.NODE_ENV === 'test')
|
||||
return myapp.host_test + siteport;
|
||||
@@ -1035,14 +1078,14 @@ module.exports = {
|
||||
},
|
||||
|
||||
getLookup: function(params, num, pass_proj) {
|
||||
const query = []
|
||||
const query = [];
|
||||
|
||||
if (!params)
|
||||
return;
|
||||
|
||||
let mylkLF = params.lk_LF;
|
||||
if (params.af_objId_tab) {
|
||||
const myobj = {}
|
||||
const myobj = {};
|
||||
myobj['myId' + num] = {'$toObjectId': '$' + params.lk_LF};
|
||||
query.push(
|
||||
{'$addFields': myobj},
|
||||
@@ -1053,9 +1096,9 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (params.lk_tab) {
|
||||
let proj = params.lk_proj
|
||||
let proj = params.lk_proj;
|
||||
if (!!pass_proj) {
|
||||
proj = pass_proj
|
||||
proj = pass_proj;
|
||||
}
|
||||
query.push(
|
||||
{
|
||||
@@ -1096,7 +1139,6 @@ module.exports = {
|
||||
|
||||
let query = [];
|
||||
|
||||
|
||||
if (params.filter && params.fieldsearch) {
|
||||
|
||||
let myregexp = {};
|
||||
@@ -1160,9 +1202,11 @@ module.exports = {
|
||||
if (params.filterand.includes(
|
||||
shared_consts.FILTER_USER_CODICE_AUTH_TELEGRAM))
|
||||
filtriadded.push({'profile.teleg_checkcode': {$gt: 1}});
|
||||
if (params.filterand.includes(shared_consts.FILTER_USER_NO_EMAIL_VERIFICATA))
|
||||
if (params.filterand.includes(
|
||||
shared_consts.FILTER_USER_NO_EMAIL_VERIFICATA))
|
||||
filtriadded.push({verified_email: false});
|
||||
if (params.filterand.includes(shared_consts.FILTER_USER_NO_VERIFIED_APORTADOR))
|
||||
if (params.filterand.includes(
|
||||
shared_consts.FILTER_USER_NO_VERIFIED_APORTADOR))
|
||||
filtriadded.push({
|
||||
$or: [
|
||||
{verified_by_aportador: {$exists: false}},
|
||||
@@ -1245,8 +1289,8 @@ module.exports = {
|
||||
|
||||
if (params.filtercustom) {
|
||||
for (const myfilter of params.filtercustom) {
|
||||
if (myfilter["userId"]) {
|
||||
myfilter["userId"] = ObjectID(myfilter["userId"]);
|
||||
if (myfilter['userId']) {
|
||||
myfilter['userId'] = ObjectID(myfilter['userId']);
|
||||
}
|
||||
filtriadded.push(myfilter);
|
||||
}
|
||||
@@ -1257,7 +1301,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (params.options) {
|
||||
if (this.isBitActive(params.options, shared_consts.OPTIONS_SEARCH_ONLY_FULL_WORDS)) {
|
||||
if (this.isBitActive(params.options,
|
||||
shared_consts.OPTIONS_SEARCH_ONLY_FULL_WORDS)) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1286,13 +1331,12 @@ module.exports = {
|
||||
if (numrowend < 0)
|
||||
numrowend = 1;
|
||||
|
||||
|
||||
if (newvers) {
|
||||
// NUOVA VERSIONE
|
||||
let proj = params.lookup2 ? params.lookup2.lk_proj : null;
|
||||
|
||||
const q1 = this.getLookup(params.lookup1, 1, proj);
|
||||
if (q1) query = [...query, ...q1]
|
||||
if (q1) query = [...query, ...q1];
|
||||
|
||||
const q2 = this.getLookup(params.lookup2, 2, proj);
|
||||
if (q2) query = [...query, ...q2];
|
||||
@@ -1312,10 +1356,9 @@ module.exports = {
|
||||
} else {
|
||||
// VECCHIA VERSIONE
|
||||
const q1 = this.getLookup(params, 1);
|
||||
if (q1) query = [...query, ...q1]
|
||||
if (q1) query = [...query, ...q1];
|
||||
}
|
||||
|
||||
|
||||
query.push(
|
||||
{
|
||||
$group: {
|
||||
@@ -1919,12 +1962,12 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
extractFileName: function (filename) {
|
||||
return path.basename(filename)
|
||||
extractFileName: function(filename) {
|
||||
return path.basename(filename);
|
||||
},
|
||||
|
||||
extractFilePath: function (filename) {
|
||||
return path.dirname(filename)
|
||||
extractFilePath: function(filename) {
|
||||
return path.dirname(filename);
|
||||
},
|
||||
|
||||
delete(mypath, alsothumb, callback) {
|
||||
@@ -1932,7 +1975,8 @@ module.exports = {
|
||||
fs.unlink(mypath, function(err) {
|
||||
if (alsothumb) {
|
||||
try {
|
||||
let img_small = path.dirname(mypath) + '/' + server_constants.PREFIX_IMG_SMALL + path.basename(mypath);
|
||||
let img_small = path.dirname(mypath) + '/' +
|
||||
server_constants.PREFIX_IMG_SMALL + path.basename(mypath);
|
||||
fs.unlink(img_small, () => {});
|
||||
} catch (e) {
|
||||
console.error(err);
|
||||
@@ -2212,7 +2256,7 @@ module.exports = {
|
||||
versionarr = versionarr.reverse();
|
||||
|
||||
for (let i = 0; i < versionarr.length; i++) {
|
||||
version += versionarr[i] * Math.pow(10, i*2);
|
||||
version += versionarr[i] * Math.pow(10, i * 2);
|
||||
}
|
||||
|
||||
return parseInt(version);
|
||||
@@ -2222,8 +2266,8 @@ module.exports = {
|
||||
return mystr.replace(/-/g, '/');
|
||||
},
|
||||
|
||||
isNumber(n){
|
||||
return typeof(n) != "boolean" && !isNaN(n) && n;
|
||||
isNumber(n) {
|
||||
return typeof (n) != 'boolean' && !isNaN(n) && n;
|
||||
},
|
||||
getNumObj(obj) {
|
||||
let count = 0;
|
||||
|
||||
Reference in New Issue
Block a user