Conto Comunitario...
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
||||
"✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !",
|
||||
"HANDSHAKE_SET": "<strong>%s</strong> ha comunicato che ti conosce personalmente e ha fiducia in te.",
|
||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Gruppo %s (da parte di %s)",
|
||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato a far parte del Gruppo %s (da parte di %s)",
|
||||
"GROUPS_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Gruppo %s. Se pensi sia un'errore, contatta l'amministratore del Gruppo.",
|
||||
"GROUPS_REMOVED": "❌ l'utente %s è stato rimosso del Gruppo %s (da parte di %s)",
|
||||
"GROUPS_EXIT_USER": "❌ l'utente %s è uscito dal Gruppo %s",
|
||||
|
||||
@@ -380,7 +380,7 @@ AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
|
||||
{ $eq: ['$typedir', '$$typedir'] },
|
||||
{ $eq: ['$typeid', '$$typeid'] },
|
||||
{ $eq: ['$status', 0] },
|
||||
{ $eq: ['$sender', '$$username'] },
|
||||
{ $eq: ['$sendergroup', '$$groupname'] },
|
||||
{ $eq: ['$idapp', '$$idapp'] },
|
||||
{ $eq: ['$extrarec.circuitname', '$$circuitname'] },
|
||||
],
|
||||
|
||||
@@ -227,7 +227,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif) {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
} else {
|
||||
newdescr = i18n.__('GROUPS_ACCEPTED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('GROUPS_ACCEPTED', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
}
|
||||
tag = 'addgroup';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REMOVED) {
|
||||
|
||||
@@ -1657,8 +1657,10 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
||||
};
|
||||
}
|
||||
|
||||
let regexpusername = new RegExp(`^${username}$`, 'i');
|
||||
|
||||
const myfind = {
|
||||
idapp, username,
|
||||
idapp, username: { $regex: regexpusername },
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
};
|
||||
|
||||
@@ -4537,6 +4539,12 @@ UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave) {
|
||||
|
||||
const useraccounts = await Account.getUserAccounts(idapp, recUser.username);
|
||||
|
||||
for (const group of listManageGroups) {
|
||||
const myaccounts = await Account.getGroupAccounts(idapp, group.groupname);
|
||||
if (myaccounts && myaccounts.length > 0)
|
||||
group.account = myaccounts[0]
|
||||
}
|
||||
|
||||
recUser.profile = { ...recUser.profile, ...circuitobj, useraccounts };
|
||||
|
||||
recUser.calcstat = await User.calculateStat(idapp, recUser.username);
|
||||
|
||||
@@ -879,7 +879,7 @@ const MyTelegramBot = {
|
||||
}
|
||||
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_GRUPPO) {
|
||||
|
||||
domanda = printf(getstr(langdest, 'MSG_ACCEPT_NEWENTRY_INGROUP'), name);
|
||||
domanda = printf(getstr(langdest, 'MSG_ACCEPT_NEWENTRY_INGROUP'), name) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
@@ -894,7 +894,7 @@ const MyTelegramBot = {
|
||||
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (groupname) {
|
||||
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY_BYGROUP', locale: langdest }, groupname);
|
||||
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY_BYGROUP', locale: langdest }, groupname) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
@@ -909,7 +909,7 @@ const MyTelegramBot = {
|
||||
},
|
||||
]);
|
||||
} else {
|
||||
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest }, name);
|
||||
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest }, name) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
@@ -1312,7 +1312,7 @@ async function sendMsgTelegramToTheAdmin(idapp, text, msg) {
|
||||
async function setVerifiedReg(idapp, lang, usernameorig, usernameDest) {
|
||||
try {
|
||||
await User.setVerifiedByAportador(idapp, usernameorig, true);
|
||||
await User.setFriendsCmd(null, idapp, usernameorig, usernameDest, shared_consts.FRIENDSCMD.SETFRIEND);
|
||||
// await User.setFriendsCmd(null, idapp, usernameorig, usernameDest, shared_consts.FRIENDSCMD.SETFRIEND);
|
||||
|
||||
const msgDest = printf(getstr(lang, 'MSG_APORTADOR_CONFIRMED'),
|
||||
`${usernameorig}`, usernameDest);
|
||||
@@ -4000,7 +4000,7 @@ if (true) {
|
||||
|
||||
if (changed) {
|
||||
const req = tools.getReqByPar(user.idapp, username_action);
|
||||
await User.setFriendsCmd(req, user.idapp, data.username, userDest.username, shared_consts.FRIENDSCMD.SETFRIEND, null, true);
|
||||
// await User.setFriendsCmd(req, user.idapp, data.username, userDest.username, shared_consts.FRIENDSCMD.SETFRIEND, null, true);
|
||||
|
||||
await User.setaportador_solidario(user.idapp, data.username, userDest.username);
|
||||
|
||||
|
||||
@@ -1047,89 +1047,90 @@ module.exports = {
|
||||
const user = await User.findOne({ idapp, username: usernameDest },
|
||||
{ _id: 1, lang: 1 });
|
||||
|
||||
let lang = 'it';
|
||||
if (user) {
|
||||
lang = user.lang;
|
||||
}
|
||||
|
||||
try {
|
||||
if (user) {
|
||||
let paramsObj = {
|
||||
usernameDest,
|
||||
circuitnameDest: circuitname,
|
||||
path,
|
||||
username_action: username_action,
|
||||
singleadmin_username: usernameDest,
|
||||
extrarec,
|
||||
options: 0,
|
||||
lang,
|
||||
isAdmin,
|
||||
username_worked,
|
||||
};
|
||||
|
||||
let lang = user.lang;
|
||||
let paramsObj = {
|
||||
usernameDest,
|
||||
circuitnameDest: circuitname,
|
||||
path,
|
||||
username_action: username_action,
|
||||
singleadmin_username: usernameDest,
|
||||
extrarec,
|
||||
options: 0,
|
||||
lang,
|
||||
isAdmin,
|
||||
username_worked,
|
||||
};
|
||||
let sendnotif = true;
|
||||
let typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
|
||||
let typeid = 0;
|
||||
let onlysave = false;
|
||||
let numuserincircuit = await User.countUsersInCircuit(idapp, circuitname);
|
||||
|
||||
let sendnotif = true;
|
||||
let typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
|
||||
let typeid = 0;
|
||||
let onlysave = false;
|
||||
let numuserincircuit = await User.countUsersInCircuit(idapp, circuitname);
|
||||
|
||||
if (cmd) {
|
||||
if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
if (myreccircuit && myreccircuit.createdBy === usernameDest && numuserincircuit <= 1) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||
} else {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED;
|
||||
}
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REFUSE_REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REFUSED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER;
|
||||
// paramsObj.options = MessageOptions.Notify_OnlyToNotifinApp + MessageOptions.Notify_ByBotTelegram;
|
||||
const myuserdata = await User.getUserShortDataByUsername(idapp, username_action);
|
||||
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_CIRCUIT, myuserdata, usernameDest, circuitname,
|
||||
myreccircuit._id, '', extrarec.groupname);
|
||||
onlysave = false;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ADDED_ADMIN;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT) {
|
||||
// Crea l'ID di Transazione
|
||||
paramsObj.idTransaction = new ObjectId();
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT;
|
||||
if (cmd) {
|
||||
if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
if (myreccircuit && myreccircuit.createdBy === usernameDest && numuserincircuit <= 1) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||
} else {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED;
|
||||
}
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REFUSE_REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REFUSED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER;
|
||||
// paramsObj.options = MessageOptions.Notify_OnlyToNotifinApp + MessageOptions.Notify_ByBotTelegram;
|
||||
const myuserdata = await User.getUserShortDataByUsername(idapp, username_action);
|
||||
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_CIRCUIT, myuserdata, usernameDest, circuitname,
|
||||
myreccircuit._id, '', extrarec.groupname);
|
||||
onlysave = false;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ADDED_ADMIN;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT) {
|
||||
// Crea l'ID di Transazione
|
||||
paramsObj.idTransaction = new ObjectId();
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT;
|
||||
}
|
||||
|
||||
if (sendnotif && typeid > 0) {
|
||||
// Check if is group:
|
||||
if (extrarec.groupdest) {
|
||||
}
|
||||
|
||||
let arrusers = await MyGroup.getListAdminsByGroupName(idapp, extrarec.groupdest);
|
||||
if (sendnotif && typeid > 0) {
|
||||
// Check if is group:
|
||||
if (extrarec.groupdest) {
|
||||
|
||||
let ris = null;
|
||||
let arrusers = await MyGroup.getListAdminsByGroupName(idapp, extrarec.groupdest);
|
||||
|
||||
for (let i = 0; i < arrusers.length; i++) {
|
||||
paramsObj.usernameDest = arrusers[i].username;
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", extrarec.groupdest)
|
||||
}
|
||||
let ris = null;
|
||||
|
||||
for (let i = 0; i < arrusers.length; i++) {
|
||||
paramsObj.usernameDest = arrusers[i].username;
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", extrarec.groupdest)
|
||||
}
|
||||
|
||||
} else {
|
||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||
return await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
}
|
||||
|
||||
} else {
|
||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||
return await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -1211,9 +1212,9 @@ module.exports = {
|
||||
|
||||
if (recnotif)
|
||||
extrarec.notifIdToUpdate = recnotif._id;
|
||||
|
||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, extrarec.dest, username_action, circuitname, circuit.path,
|
||||
null,
|
||||
false, '', extrarec);
|
||||
null, false, '', extrarec);
|
||||
|
||||
extrarec.notifIdToUpdate = '';
|
||||
|
||||
@@ -3367,7 +3368,7 @@ module.exports = {
|
||||
const linkuserprof = this.getHostByIdApp(idapp) + '/my/' +
|
||||
myuser.username;
|
||||
|
||||
msg = `<br>Username: <b>${name}</b><br>Profilo su APP: ${linkuserprof}<br>Email: ${myuser.email}`;
|
||||
msg = `<br>👉🏻 <a href="${linkuserprof}">${name}</a> (email: ${myuser.email})`;
|
||||
|
||||
let u_tg = myuser.profile && myuser.profile.hasOwnProperty('username_telegram') ? myuser.profile.username_telegram : usernametelegram;
|
||||
let name_tg = myuser.profile && myuser.profile.hasOwnProperty('firstname_telegram')
|
||||
@@ -3377,8 +3378,12 @@ module.exports = {
|
||||
? myuser.profile.lastname_telegram
|
||||
: surname_telegram;
|
||||
|
||||
let namesurnametg = '';
|
||||
if (name_tg || surname_tg)
|
||||
namesurnametg = ` [${name_tg} ${surname_tg}]`;;
|
||||
|
||||
if (u_tg) {
|
||||
msg += `<br>Profilo su Telegram [${name_tg} ${surname_tg}]:<br>https://t.me/${u_tg}`;
|
||||
msg += `<br><br>https://t.me/${u_tg}`;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('getUserInfoMsg', e);
|
||||
@@ -3397,7 +3402,7 @@ module.exports = {
|
||||
const linkuserprof = this.getHostByIdApp(idapp) + '/my/' +
|
||||
myuser.username;
|
||||
|
||||
let u_tg = myuser.profile && myuser.profile.hasOwnProperty('username_telegram') ? myuser.profile.username_telegram : usernametelegram;
|
||||
let u_tg = myuser.profile && myuser.profile.hasOwnProperty('username_telegram') ? myuser.profile.username_telegram : usernametelegram;
|
||||
|
||||
msg = `<br>Vedi Profilo sulla APP di <a href="${linkuserprof}">${name}</a>`;
|
||||
msg += `<br>Telegram: @${u_tg}`;
|
||||
|
||||
Reference in New Issue
Block a user