Conto Comunitario...

This commit is contained in:
Surya Paolo
2023-01-12 01:03:10 +01:00
parent e13fe84709
commit f7d05eb856
6 changed files with 100 additions and 87 deletions

View File

@@ -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",

View File

@@ -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'] },
],

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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);

View File

@@ -1047,10 +1047,12 @@ module.exports = {
const user = await User.findOne({ idapp, username: usernameDest },
{ _id: 1, lang: 1 });
try {
let lang = 'it';
if (user) {
lang = user.lang;
}
let lang = user.lang;
try {
let paramsObj = {
usernameDest,
circuitnameDest: circuitname,
@@ -1131,7 +1133,6 @@ module.exports = {
return await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
}
}
}
} catch (e) {
console.log(e.message);
}
@@ -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);