- Accepted and Refused Group Entering
- Report a User
This commit is contained in:
@@ -16,6 +16,13 @@
|
|||||||
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> refused your Friendship",
|
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> refused your Friendship",
|
||||||
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
||||||
"✅ You have accepted %s' Friendship request!": "✅ You have accepted %s' Friendship request!",
|
"✅ You have accepted %s' Friendship request!": "✅ You have accepted %s' Friendship request!",
|
||||||
"GROUPS_ACCEPTED": "✅ You have been accepted by %s to join the Group %s",
|
"GROUPS_ACCEPTED": "✅ You have been accepted by %s to join the Group %s (by %s)",
|
||||||
"GROUP_CREATED": "✅ A new Group created by %s called %s has been created"
|
"GROUPS_REFUSED": "❌ You have been denied access by %s to join the %s Group. If you think this is an error, please contact the group administrator.",
|
||||||
|
"GROUPS_REMOVED": "❌ user %s was removed from the %s Group (by %s)",
|
||||||
|
"ACCETTATO_NOTIFICA_ADMINS": "✅ l'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)",
|
||||||
|
"GROUP_CREATED": "✅ A new Group created by %s called %s has been created",
|
||||||
|
"GROUP_REQUEST_TO_ENTER": "%s asked to join the group %s",
|
||||||
|
"GROUP_REQUEST": "Richiesta di entrare nel Gruppo %s da parte di %s",
|
||||||
|
"RICHIESTA_BLOCCO_GRUPPO": "Richiesta di bloccare il Gruppo %s da parte di %s",
|
||||||
|
"GRUPPO_ELIMINATO": "Il gruppo %s è stato eliminato da parte di %s"
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/server/locales/it.json
Executable file → Normal file
17
src/server/locales/it.json
Executable file → Normal file
@@ -11,6 +11,19 @@
|
|||||||
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> ha rifiutato l'Amicizia",
|
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> ha rifiutato l'Amicizia",
|
||||||
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
"✅ %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 !",
|
"✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !",
|
||||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Gruppo %s",
|
"GROUPS_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Gruppo %s (da parte di %s)",
|
||||||
"GROUP_CREATED": "✅ %s ha creato un nuovo Gruppo chiamato %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",
|
||||||
|
"GROUPS_EXIT_USER_TO_ME": "❌ Sei uscito dal Gruppo %s",
|
||||||
|
"GROUPS_REMOVED_TO_ME": "❌ Sei stato rimosso dal Gruppo %s (da parte di %s)",
|
||||||
|
"ACCETTATO_NOTIFICA_ADMINS": "✅ l'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)",
|
||||||
|
"GROUP_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel gruppo %s",
|
||||||
|
"GROUP_CREATED": "✅ %s ha creato un nuovo Gruppo chiamato %s",
|
||||||
|
"GROUP_REQUEST": "Richiesta di entrare nel Gruppo %s da parte di %s",
|
||||||
|
"RICHIESTA_BLOCCO_GRUPPO": "Richiesta di bloccare il Gruppo %s da parte di %s",
|
||||||
|
"GRUPPO_ELIMINATO": "Il gruppo %s è stato eliminato da parte di %s",
|
||||||
|
"FRIEND_REPORTED_TO_ME": "Sei stato segnalato da %s per comportamenti non idonei. Contatta %s per chiarimenti",
|
||||||
|
"FRIEND_REPORTED": "E' stato segnalato %s da %s per comportamenti non idonei.",
|
||||||
|
"FRIEND_REPORTED_YOU": "Hai segnalato %s per comportamenti non idonei."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -264,6 +265,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -320,6 +322,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -376,6 +379,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/*{
|
/*{
|
||||||
@@ -432,6 +436,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -488,6 +493,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -263,6 +264,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -318,6 +320,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -373,6 +376,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -428,6 +432,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -483,6 +488,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ const MyGroupSchema = new Schema({
|
|||||||
pwd_cryp: {
|
pwd_cryp: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
createdBy: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
admins: [
|
admins: [
|
||||||
{
|
{
|
||||||
username: {type: String},
|
username: {type: String},
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -259,6 +260,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -310,6 +312,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -361,6 +364,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/*{
|
/*{
|
||||||
@@ -412,6 +416,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -463,6 +468,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -263,6 +264,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -317,6 +319,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -371,6 +374,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/*{
|
/*{
|
||||||
@@ -427,6 +431,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -481,6 +486,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
|||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
"profile.mygroups": 1,
|
"profile.mygroups": 1,
|
||||||
'profile.qualifica': 1,
|
'profile.qualifica': 1,
|
||||||
|
reported: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ const sendNotifSchema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
options: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
read: {
|
read: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
@@ -69,6 +72,9 @@ const sendNotifSchema = new Schema({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
extrafield: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -126,6 +132,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
|||||||
let mydescr = '';
|
let mydescr = '';
|
||||||
let myidrec = '';
|
let myidrec = '';
|
||||||
let userorig = recnotif.sender;
|
let userorig = recnotif.sender;
|
||||||
|
let tag = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (recnotif.myrectableorig) {
|
if (recnotif.myrectableorig) {
|
||||||
@@ -150,16 +157,56 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
|||||||
newdescr = i18n.__('<strong>%s</strong> accepted your Friendship', userorig, mydescr);
|
newdescr = i18n.__('<strong>%s</strong> accepted your Friendship', userorig, mydescr);
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REFUSED) {
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REFUSED) {
|
||||||
newdescr = i18n.__('<strong>%s</strong> refused your Friendship', userorig, mydescr);
|
newdescr = i18n.__('<strong>%s</strong> refused your Friendship', userorig, mydescr);
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REPORTED) {
|
||||||
|
if (recnotif.paramsObj.usernameDest === recnotif.paramsObj.username_action) {
|
||||||
|
newdescr = i18n.__('FRIEND_REPORTED_YOU', recnotif.paramsObj.username_worked);
|
||||||
|
} else if (recnotif.paramsObj.isAdmin) {
|
||||||
|
newdescr = i18n.__('FRIEND_REPORTED', recnotif.paramsObj.usernameDest, userorig);
|
||||||
|
} else {
|
||||||
|
newdescr = i18n.__('FRIEND_REPORTED_TO_ME', recnotif.paramsObj.username_action, recnotif.paramsObj.username_action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||||
recnotif.openUrl = '/grp/' + recnotif.paramsObj.groupNameDest;
|
recnotif.openUrl = '/grp/' + recnotif.paramsObj.groupnameDest;
|
||||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_NEW_REC) {
|
if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_NEW_REC) {
|
||||||
newdescr = i18n.__('GROUP_CREATED', userorig, recnotif.paramsObj.groupNameDest);
|
newdescr = i18n.__('GROUP_CREATED', userorig, recnotif.paramsObj.groupnameDest);
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ACCEPTED) {
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ACCEPTED) {
|
||||||
newdescr = i18n.__('GROUPS_ACCEPTED', userorig, recnotif.paramsObj.groupNameDest);
|
if (recnotif.paramsObj.isAdmin)
|
||||||
|
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||||
|
else
|
||||||
|
newdescr = i18n.__('GROUPS_ACCEPTED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||||
|
tag = 'addgroup';
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REMOVED) {
|
||||||
|
if (recnotif.paramsObj.username_action === recnotif.paramsObj.usernameDest && userorig === recnotif.paramsObj.usernameDest)
|
||||||
|
newdescr = i18n.__('GROUPS_EXIT_USER_TO_ME', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||||
|
else if (userorig === recnotif.paramsObj.usernameDest)
|
||||||
|
newdescr = i18n.__('GROUPS_REMOVED_TO_ME', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||||
|
else if (userorig === recnotif.paramsObj.username_action)
|
||||||
|
newdescr = i18n.__('GROUPS_EXIT_USER', userorig, recnotif.paramsObj.groupnameDest);
|
||||||
|
else
|
||||||
|
newdescr = i18n.__('GROUPS_REMOVED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||||
|
tag = 'remgroup';
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REFUSED) {
|
||||||
|
newdescr = i18n.__('GROUPS_REFUSED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||||
|
tag = 'addgroup';
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER) {
|
||||||
|
newdescr = i18n.__('GROUP_REQUEST_TO_ENTER', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.singleadmin_username);
|
||||||
|
tag = 'reqgroups';
|
||||||
|
// sendnotifPush = false; // non lo rimandare 2 volte !
|
||||||
|
// telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_GRUPPO, myuser, singleadmin.username, groupname, group._id);
|
||||||
|
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_BLOCK_USER) {
|
||||||
|
newdescr = i18n.__('RICHIESTA_BLOCCO_GRUPPO', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.singleadmin_username);
|
||||||
|
tag = 'blockgroups';
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_DELETE_USER) {
|
||||||
|
newdescr = i18n.__('GRUPPO_ELIMINATO', userorig, recnotif.paramsObj.username_action);
|
||||||
|
tag = 'deletegroup';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recnotif.tag = recnotif.tag ? recnotif.tag : tag;
|
||||||
|
|
||||||
if (!recnotif.descr) {
|
if (!recnotif.descr) {
|
||||||
recnotif.descr = newdescr;
|
recnotif.descr = newdescr;
|
||||||
}
|
}
|
||||||
@@ -216,55 +263,86 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function(username, idap
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sendNotifSchema.statics.saveAndSendNotif = function(myrecnotif, req, res, user) {
|
sendNotifSchema.statics.saveAndSendNotif = async function(myrecnotif, req, res, user) {
|
||||||
|
const SendNotif = this;
|
||||||
|
|
||||||
let idapp = req.body.idapp;
|
let idapp = req.body.idapp;
|
||||||
const check = tools.checkUserOk(myrecnotif.sender, user ? myrecnotif.sender : req.user.username, res);
|
const check = tools.checkUserOk(myrecnotif.sender, user ? myrecnotif.sender : req.user.username, res);
|
||||||
if (check.exit) return check.ret;
|
if (check.exit) return check.ret;
|
||||||
|
|
||||||
myrecnotif._id = new ObjectID();
|
const {myrecout, save} = await SendNotif.updateStatusAndDescr(myrecnotif, false);
|
||||||
if (!myrecnotif.openUrl) {
|
if (!myrecout)
|
||||||
// If not exist, then I set openUrl and description
|
return null;
|
||||||
myrecnotif = this.getDescrAndLinkByRecNotif(myrecnotif);
|
|
||||||
}
|
|
||||||
|
|
||||||
return myrecnotif.save().then((writeresult) => {
|
if (save) {
|
||||||
|
await myrecout.save().then((writeresult) => {
|
||||||
let idobj = writeresult._id;
|
let idobj = writeresult._id;
|
||||||
|
|
||||||
myrecnotif._id = idobj;
|
|
||||||
|
|
||||||
return SendNotif.findById(idobj).lean().then(async (recnotif) => {
|
return SendNotif.findById(idobj).lean().then(async (recnotif) => {
|
||||||
return await globalTables.sendNotif(myrecnotif.typedir, myrecnotif.typeid, res, idapp, user ? user : req.user, recnotif).
|
return await globalTables.sendNotif(myrecnotif.typedir, myrecnotif.typeid, res, idapp, user ? user : req.user, recnotif).
|
||||||
then((ris) => {
|
then((ris) => {
|
||||||
return recnotif;
|
return recnotif;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
return await globalTables.sendNotif(myrecout.typedir, myrecout.typeid, res, idapp, user ? user : req.user, myrecout).
|
||||||
|
then((ris) => {
|
||||||
|
return myrecout;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sendNotifSchema.statics.saveNotif = async function(myrecnotif) {
|
sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysave) {
|
||||||
|
|
||||||
const SendNotif = this;
|
const SendNotif = this;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!myrecnotif.openUrl) {
|
||||||
|
// If not exist, then I set openUrl and description
|
||||||
|
myrecnotif = this.getDescrAndLinkByRecNotif(myrecnotif);
|
||||||
|
}
|
||||||
|
|
||||||
let newstatus = 0;
|
let newstatus = 0;
|
||||||
let typeidsearch = 0;
|
let typeidsearch = 0;
|
||||||
|
let dest = '';
|
||||||
|
|
||||||
// Controllare se devo modificare un Notif già esistente !
|
// Controllare se devo modificare un Notif già esistente !
|
||||||
if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
|
if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
|
||||||
typeidsearch = shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC;
|
typeidsearch = shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC;
|
||||||
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED) {
|
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED) {
|
||||||
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_ACCEPTED;
|
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_ACCEPTED;
|
||||||
|
dest = myrecnotif.sender;
|
||||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REFUSED) {
|
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REFUSED) {
|
||||||
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_REFUSED;
|
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_REFUSED;
|
||||||
|
dest = myrecnotif.sender;
|
||||||
}
|
}
|
||||||
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||||
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
||||||
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ACCEPTED) {
|
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ACCEPTED) {
|
||||||
newstatus = shared_consts.StatusNotifs.STATUS_GROUPS_ACCEPTED;
|
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||||
|
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_ACCEPTED;
|
||||||
|
dest = myrecnotif.dest;
|
||||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REFUSED) {
|
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REFUSED) {
|
||||||
newstatus = shared_consts.StatusNotifs.STATUS_GROUPS_REFUSED;
|
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||||
|
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_REFUSED;
|
||||||
|
dest = myrecnotif.dest;
|
||||||
|
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REMOVED) {
|
||||||
|
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||||
|
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_REMOVED;
|
||||||
|
dest = myrecnotif.dest;
|
||||||
|
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_BLOCK_USER) {
|
||||||
|
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||||
|
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_BLOCKED;
|
||||||
|
dest = myrecnotif.dest;
|
||||||
|
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_DELETE_USER) {
|
||||||
|
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||||
|
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_DELETED;
|
||||||
|
dest = myrecnotif.dest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,39 +350,52 @@ sendNotifSchema.statics.saveNotif = async function(myrecnotif) {
|
|||||||
const fields_to_update = {
|
const fields_to_update = {
|
||||||
status: newstatus,
|
status: newstatus,
|
||||||
read: true,
|
read: true,
|
||||||
|
descr: myrecnotif.descr,
|
||||||
};
|
};
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
idapp: myrecnotif.idapp,
|
idapp: myrecnotif.idapp,
|
||||||
typedir: myrecnotif.typedir,
|
typedir: myrecnotif.typedir,
|
||||||
typeid: typeidsearch,
|
typeid: typeidsearch,
|
||||||
dest: myrecnotif.sender,
|
dest,
|
||||||
deleted: false,
|
deleted: false,
|
||||||
status: 0,
|
status: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cerca il record e se lo trova lo aggiorna
|
// Cerca il record e se lo trova lo aggiorna
|
||||||
const myrec = await SendNotif.findOneAndUpdate(query, {$set: fields_to_update}, {
|
const myrec = await SendNotif.findOneAndUpdate(query, {$set: fields_to_update}, {
|
||||||
new: false,
|
new: true,
|
||||||
returnNewDocument: true,
|
returnNewDocument: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (myrec) {
|
if (myrec) {
|
||||||
return myrec._doc;
|
return {myrecout: myrec, save: false};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
myrecnotif._id = new ObjectID();
|
myrecnotif._id = new ObjectID();
|
||||||
if (!myrecnotif.openUrl) {
|
if (newstatus > 0) {
|
||||||
// If not exist, then I set openUrl and description
|
myrecnotif.status = newstatus;
|
||||||
myrecnotif = this.getDescrAndLinkByRecNotif(myrecnotif);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return myrecnotif.save().then((writeresult) => {
|
return {myrecout: myrecnotif, save: true};
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return {myrecout: null, save: false};
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
sendNotifSchema.statics.saveNotif = async function(myrecnotif) {
|
||||||
|
|
||||||
|
const SendNotif = this;
|
||||||
|
|
||||||
|
const {myrecout, save} = await SendNotif.updateStatusAndDescr(myrecnotif, true);
|
||||||
|
if (!myrecout)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return myrecout.save().then((writeresult) => {
|
||||||
let idobj = writeresult._id;
|
let idobj = writeresult._id;
|
||||||
|
|
||||||
myrecnotif._id = idobj;
|
|
||||||
|
|
||||||
return SendNotif.findById(idobj).lean().then(async (recnotif) => {
|
return SendNotif.findById(idobj).lean().then(async (recnotif) => {
|
||||||
return recnotif;
|
return recnotif;
|
||||||
});
|
});
|
||||||
@@ -334,11 +425,24 @@ sendNotifSchema.statics.getDefaultRec = function(req) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sendNotifSchema.statics.getExtraParam = function(myrecnotif, paramsObj) {
|
||||||
|
let out = myrecnotif;
|
||||||
|
//if (myrecnotif._doc) {
|
||||||
|
//out = myrecnotif._doc
|
||||||
|
//}
|
||||||
|
out.paramsObj = paramsObj;
|
||||||
|
out.options = paramsObj.options ? paramsObj.options : 0;
|
||||||
|
out.extrafield = paramsObj.groupnameDest ? paramsObj.groupnameDest : '';
|
||||||
|
|
||||||
|
return myrecnotif;
|
||||||
|
};
|
||||||
|
|
||||||
sendNotifSchema.statics.createNewNotification = async function(req, res, paramsObj, table, rec, typedir, typeid) {
|
sendNotifSchema.statics.createNewNotification = async function(req, res, paramsObj, table, rec, typedir, typeid) {
|
||||||
const SendNotif = this;
|
const SendNotif = this;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let myrecnotif = new SendNotif(this.getDefaultRec(req));
|
let myrecnotif = new SendNotif(this.getDefaultRec(req));
|
||||||
|
myrecnotif = this.getExtraParam(myrecnotif, paramsObj);
|
||||||
|
|
||||||
myrecnotif.tablerec = table;
|
myrecnotif.tablerec = table;
|
||||||
if (rec && table) {
|
if (rec && table) {
|
||||||
@@ -348,7 +452,7 @@ sendNotifSchema.statics.createNewNotification = async function(req, res, paramsO
|
|||||||
myrecnotif.typedir = typedir;
|
myrecnotif.typedir = typedir;
|
||||||
myrecnotif.typeid = typeid;
|
myrecnotif.typeid = typeid;
|
||||||
|
|
||||||
await SendNotif.sendToTheDestinations(myrecnotif, req, res, paramsObj);
|
await SendNotif.sendToTheDestinations(myrecnotif, req, res);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -362,11 +466,12 @@ sendNotifSchema.statics.createNewNotifToSingleUser = async function(req, res, pa
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let myrecnotif = new SendNotif(this.getDefaultRec(req));
|
let myrecnotif = new SendNotif(this.getDefaultRec(req));
|
||||||
|
myrecnotif = this.getExtraParam(myrecnotif, paramsObj);
|
||||||
|
|
||||||
myrecnotif.typedir = typedir;
|
myrecnotif.typedir = typedir;
|
||||||
myrecnotif.typeid = typeid;
|
myrecnotif.typeid = typeid;
|
||||||
|
|
||||||
await SendNotif.sendToSingleUserDest(myrecnotif, req, res, paramsObj, onlysave);
|
await SendNotif.sendToSingleUserDest(myrecnotif, req, res, onlysave);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -375,7 +480,7 @@ sendNotifSchema.statics.createNewNotifToSingleUser = async function(req, res, pa
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotif, req, res, paramsObj) {
|
sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotif, req, res) {
|
||||||
const SendNotif = this;
|
const SendNotif = this;
|
||||||
|
|
||||||
const {User} = require('../models/user');
|
const {User} = require('../models/user');
|
||||||
@@ -383,8 +488,6 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotif, req,
|
|||||||
const {City} = require('../models/city');
|
const {City} = require('../models/city');
|
||||||
const {Province} = require('../models/province');
|
const {Province} = require('../models/province');
|
||||||
|
|
||||||
myrecnotif.paramsObj = paramsObj;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Send only to the destination to reach:
|
// Send only to the destination to reach:
|
||||||
@@ -469,7 +572,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotif, req,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotif.tablerec)) {
|
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotif.tablerec)) {
|
||||||
if (tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
|
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
|
||||||
send = true;
|
send = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -487,19 +590,18 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotif, req,
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sendNotifSchema.statics.sendToSingleUserDest = async function(myrecnotif, req, res, paramsObj, onlysave) {
|
sendNotifSchema.statics.sendToSingleUserDest = async function(myrecnotif, req, res, onlysave) {
|
||||||
const SendNotif = this;
|
const SendNotif = this;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
myrecnotif.paramsObj = paramsObj;
|
myrecnotif.dest = myrecnotif.paramsObj && myrecnotif.paramsObj.usernameDest ? myrecnotif.paramsObj.usernameDest : '';
|
||||||
myrecnotif.dest = paramsObj.usernameDest ? paramsObj.usernameDest : '';
|
myrecnotif.username_worked = myrecnotif.paramsObj && myrecnotif.paramsObj.username_worked ? myrecnotif.paramsObj.username_worked : myrecnotif.dest;
|
||||||
myrecnotif = this.getDescrAndLinkByRecNotif(myrecnotif);
|
|
||||||
|
|
||||||
if (onlysave) {
|
if (onlysave) {
|
||||||
await SendNotif.saveNotif(myrecnotif);
|
await SendNotif.saveNotif(myrecnotif);
|
||||||
} else {
|
} else {
|
||||||
await SendNotif.saveAndSendNotif(myrecnotif, req, res, user);
|
await SendNotif.saveAndSendNotif(myrecnotif, req, res, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -181,6 +181,15 @@ const UserSchema = new mongoose.Schema({
|
|||||||
date_blocked: {
|
date_blocked: {
|
||||||
type: Date,
|
type: Date,
|
||||||
},
|
},
|
||||||
|
reported: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
username_who_report: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
date_report: {
|
||||||
|
type: Date,
|
||||||
|
},
|
||||||
non_voglio_imbarcarmi: {
|
non_voglio_imbarcarmi: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
@@ -386,7 +395,7 @@ const UserSchema = new mongoose.Schema({
|
|||||||
notif_sector_goods: [
|
notif_sector_goods: [
|
||||||
{
|
{
|
||||||
type: Number,
|
type: Number,
|
||||||
}]
|
}],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
@@ -693,6 +702,7 @@ UserSchema.statics.getUserShortDataByUsername = async function(idapp, username)
|
|||||||
name: 1,
|
name: 1,
|
||||||
surname: 1,
|
surname: 1,
|
||||||
deleted: 1,
|
deleted: 1,
|
||||||
|
reported: 1,
|
||||||
sospeso: 1,
|
sospeso: 1,
|
||||||
verified_email: 1,
|
verified_email: 1,
|
||||||
verified_by_aportador: 1,
|
verified_by_aportador: 1,
|
||||||
@@ -1355,6 +1365,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
|
|||||||
username: 1,
|
username: 1,
|
||||||
deleted: 1,
|
deleted: 1,
|
||||||
sospeso: 1,
|
sospeso: 1,
|
||||||
|
reported: 1,
|
||||||
verified_email: 1,
|
verified_email: 1,
|
||||||
verified_by_aportador: 1,
|
verified_by_aportador: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
@@ -1372,6 +1383,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
|
|||||||
surname: 1,
|
surname: 1,
|
||||||
deleted: 1,
|
deleted: 1,
|
||||||
sospeso: 1,
|
sospeso: 1,
|
||||||
|
reported: 1,
|
||||||
verified_email: 1,
|
verified_email: 1,
|
||||||
verified_by_aportador: 1,
|
verified_by_aportador: 1,
|
||||||
'profile.nationality': 1,
|
'profile.nationality': 1,
|
||||||
@@ -1405,6 +1417,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
|
|||||||
surname: 1,
|
surname: 1,
|
||||||
deleted: 1,
|
deleted: 1,
|
||||||
sospeso: 1,
|
sospeso: 1,
|
||||||
|
reported: 1,
|
||||||
verified_email: 1,
|
verified_email: 1,
|
||||||
verified_by_aportador: 1,
|
verified_by_aportador: 1,
|
||||||
notask_verif: 1,
|
notask_verif: 1,
|
||||||
@@ -1559,19 +1572,26 @@ UserSchema.statics.removeReqFriend = async function(
|
|||||||
{$pull: {'profile.req_friends': {username: {$in: [usernameDest]}}}});
|
{$pull: {'profile.req_friends': {username: {$in: [usernameDest]}}}});
|
||||||
};
|
};
|
||||||
|
|
||||||
UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameDest, cmd, value) {
|
UserSchema.statics.setFriendsCmd = async function(req, idapp, usernameOrig, usernameDest, cmd, value) {
|
||||||
|
|
||||||
const {SendNotif} = require('../models/sendnotif');
|
const {SendNotif} = require('../models/sendnotif');
|
||||||
|
|
||||||
const telegrambot = require('../telegram/telegrambot');
|
const telegrambot = require('../telegram/telegrambot');
|
||||||
|
|
||||||
|
if (!req) {
|
||||||
|
req = tools.getReqByPar(idapp, usernameOrig);
|
||||||
|
}
|
||||||
|
|
||||||
|
const username_action = req.user.username;
|
||||||
|
let username_worked = usernameDest;
|
||||||
|
|
||||||
let ris = null;
|
let ris = null;
|
||||||
let update = {};
|
let update = {};
|
||||||
try {
|
try {
|
||||||
if (cmd === shared_consts.FRIENDSCMD.SETTRUST) {
|
if (cmd === shared_consts.FRIENDSCMD.SETTRUST) {
|
||||||
|
|
||||||
// Aggiungi alle amicizie
|
// Aggiungi alle amicizie
|
||||||
await this.setFriendsCmd(idapp, usernameOrig, usernameDest,
|
await this.setFriendsCmd(req, idapp, usernameOrig, usernameDest,
|
||||||
shared_consts.FRIENDSCMD.SETFRIEND, value);
|
shared_consts.FRIENDSCMD.SETFRIEND, value);
|
||||||
|
|
||||||
return User.updateOne({idapp, username: usernameDest},
|
return User.updateOne({idapp, username: usernameDest},
|
||||||
@@ -1601,11 +1621,13 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
|
|||||||
|
|
||||||
// Send a notification to the DESTINATION FRIENDSHIP !
|
// Send a notification to the DESTINATION FRIENDSHIP !
|
||||||
let req = tools.getReqByPar(idapp, usernameOrig);
|
let req = tools.getReqByPar(idapp, usernameOrig);
|
||||||
await SendNotif.createNewNotifToSingleUser(req, null, {usernameDest}, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS, shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED);
|
await SendNotif.createNewNotifToSingleUser(req, null, {usernameDest}, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||||
|
shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED);
|
||||||
|
|
||||||
// Send a notification to the SENDER FRIENDSHIP !
|
// Send a notification to the SENDER FRIENDSHIP !
|
||||||
req = tools.getReqByPar(idapp, usernameOrig);
|
req = tools.getReqByPar(idapp, usernameOrig);
|
||||||
await SendNotif.createNewNotifToSingleUser(req, null, {usernameDest}, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS, shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED_MY_REQUEST);
|
await SendNotif.createNewNotifToSingleUser(req, null, {usernameDest}, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||||
|
shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED_MY_REQUEST);
|
||||||
|
|
||||||
update = {$pull: {'profile.req_friends': {username: {$in: [usernameDest]}}}};
|
update = {$pull: {'profile.req_friends': {username: {$in: [usernameDest]}}}};
|
||||||
ris = await User.updateOne({idapp, username: usernameOrig}, update);
|
ris = await User.updateOne({idapp, username: usernameOrig}, update);
|
||||||
@@ -1614,8 +1636,8 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
|
|||||||
try {
|
try {
|
||||||
const userDest = await User.getRecLangAndIdByUsername(idapp, usernameDest);
|
const userDest = await User.getRecLangAndIdByUsername(idapp, usernameDest);
|
||||||
const user = await User.getRecLangAndIdByUsername(idapp, usernameOrig);
|
const user = await User.getRecLangAndIdByUsername(idapp, usernameOrig);
|
||||||
const msgOrig = i18n.__({phrase: '✅ %s accepted your Friendship request !', locale: user.lang}, usernameOrig)
|
const msgOrig = i18n.__({phrase: '✅ %s accepted your Friendship request !', locale: user.lang}, usernameOrig);
|
||||||
const msgDest = i18n.__({phrase: "✅ You have accepted %s' Friendship request!", locale: userDest.lang}, usernameDest);
|
const msgDest = i18n.__({phrase: '✅ You have accepted %s\' Friendship request!', locale: userDest.lang}, usernameDest);
|
||||||
|
|
||||||
await telegrambot.sendMsgTelegram(idapp, usernameDest, msgOrig);
|
await telegrambot.sendMsgTelegram(idapp, usernameDest, msgOrig);
|
||||||
await telegrambot.sendMsgTelegram(idapp, usernameOrig, msgDest);
|
await telegrambot.sendMsgTelegram(idapp, usernameOrig, msgDest);
|
||||||
@@ -1701,7 +1723,8 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
|
|||||||
|
|
||||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||||
const req = tools.getReqByPar(idapp, usernameOrig);
|
const req = tools.getReqByPar(idapp, usernameOrig);
|
||||||
await SendNotif.createNewNotifToSingleUser(req, null, {usernameDest}, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS, shared_consts.TypeNotifs.ID_FRIENDS_REFUSED);
|
await SendNotif.createNewNotifToSingleUser(req, null, {usernameDest}, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||||
|
shared_consts.TypeNotifs.ID_FRIENDS_REFUSED);
|
||||||
|
|
||||||
await this.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
|
await this.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
|
||||||
ris = await this.removeFriend(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da me
|
ris = await this.removeFriend(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da me
|
||||||
@@ -1723,6 +1746,38 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
|
|||||||
date_blocked: new Date(),
|
date_blocked: new Date(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else if (cmd === shared_consts.FRIENDSCMD.REPORT_USER) {
|
||||||
|
|
||||||
|
username_worked = usernameDest;
|
||||||
|
|
||||||
|
// Segnalo la persona
|
||||||
|
ris = await User.updateOne({idapp, username: username_worked}, {
|
||||||
|
$set: {
|
||||||
|
reported: true,
|
||||||
|
username_who_report: usernameOrig,
|
||||||
|
date_report: new Date(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ris) {
|
||||||
|
// Send a notification to the DESTINATION!
|
||||||
|
// Sei stato segnalato da %s per comportamenti non idonei. Contatta %s per chiarimenti
|
||||||
|
await SendNotif.createNewNotifToSingleUser(req, null, {username_worked, usernameDest, username_action}, false, shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||||
|
shared_consts.TypeNotifs.ID_FRIENDS_REPORTED);
|
||||||
|
|
||||||
|
// Send a notification to the SENDER !
|
||||||
|
// Hai segnalato %s da %s per comportamenti non idonei.
|
||||||
|
await SendNotif.createNewNotifToSingleUser(req, null, {username_worked, usernameDest: username_action, username_action}, false, shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||||
|
shared_consts.TypeNotifs.ID_FRIENDS_REPORTED);
|
||||||
|
|
||||||
|
if (usernameOrig !== telegrambot.ADMIN_USER_SERVER) {
|
||||||
|
// Send a notification to the Admin
|
||||||
|
await SendNotif.createNewNotifToSingleUser(req, null, {username_worked, usernameDest: telegrambot.ADMIN_USER_SERVER, username_action, isAdmin: true}, false,
|
||||||
|
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||||
|
shared_consts.TypeNotifs.ID_FRIENDS_REPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error: ', e);
|
console.error('Error: ', e);
|
||||||
@@ -1744,9 +1799,19 @@ UserSchema.statics.ifAlreadyInGroup = async function(idapp, usernameOrig, groupn
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameDest, cmd, value, username_action) {
|
UserSchema.statics.countUsersInGroup = async function(idapp, groupnameDest) {
|
||||||
|
|
||||||
const {SendNotif} = require('../models/sendnotif');
|
// Controllo se è stato già inserito
|
||||||
|
return User.countDocuments({
|
||||||
|
idapp,
|
||||||
|
'profile.mygroups': {
|
||||||
|
$elemMatch: {groupname: {$eq: groupnameDest}},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameDest, cmd, value, username_action) {
|
||||||
|
|
||||||
let ris = null;
|
let ris = null;
|
||||||
let update = {};
|
let update = {};
|
||||||
@@ -1765,11 +1830,6 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
|||||||
};
|
};
|
||||||
ris = await User.updateOne({idapp, username: usernameOrig}, update);
|
ris = await User.updateOne({idapp, username: usernameOrig}, update);
|
||||||
|
|
||||||
|
|
||||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
|
||||||
const req = tools.getReqByPar(idapp, usernameOrig);
|
|
||||||
SendNotif.createNewNotifToSingleUser(req, null, {usernameDest:'', groupnameDest}, true, shared_consts.TypeNotifs.TYPEDIR_GROUPS, shared_consts.TypeNotifs.ID_GROUP_ACCEPTED);
|
|
||||||
|
|
||||||
// Elimina la richiesta:
|
// Elimina la richiesta:
|
||||||
update = {$pull: {req_users: {username: {$in: [usernameOrig]}}}};
|
update = {$pull: {req_users: {username: {$in: [usernameOrig]}}}};
|
||||||
ris = await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
ris = await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||||
@@ -1779,7 +1839,7 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
|||||||
}
|
}
|
||||||
if (ris) {
|
if (ris) {
|
||||||
// Invia una notifica alla persona e agli Admin
|
// Invia una notifica alla persona e agli Admin
|
||||||
tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, true, username_action);
|
tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, value, true, username_action);
|
||||||
ris = await MyGroup.getInfoGroupByGroupname(idapp, groupnameDest);
|
ris = await MyGroup.getInfoGroupByGroupname(idapp, groupnameDest);
|
||||||
}
|
}
|
||||||
} else if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
|
} else if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
|
||||||
@@ -1807,12 +1867,14 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
|||||||
}
|
}
|
||||||
if (ris) {
|
if (ris) {
|
||||||
// Invia una notifica alla persona
|
// Invia una notifica alla persona
|
||||||
tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, true, username_action);
|
await tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, true, true, username_action);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (foundIfAlreadyAskGroup) {
|
if (foundIfAlreadyAskGroup) {
|
||||||
ris = await this.removeFromMyGroups(idapp, usernameOrig,
|
ris = await this.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo il Gruppo da me
|
||||||
groupnameDest); // Rimuovo il Gruppo da me
|
|
||||||
|
// Invia una notifica alla persona
|
||||||
|
await tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, false, true, username_action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1825,13 +1887,24 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
|||||||
ris = await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
ris = await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
||||||
console.log('ris', ris);
|
console.log('ris', ris);
|
||||||
|
|
||||||
|
// Invia una notifica alla persona
|
||||||
|
await tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, false, true, username_action);
|
||||||
|
|
||||||
|
} else if (cmd === shared_consts.GROUPSCMD.REFUSE_REQ_GROUP) {
|
||||||
|
|
||||||
|
ris = await MyGroup.removeReqGroup(idapp, usernameOrig, groupnameDest); // Rimuovo la richiesta di entrare nel gruppo
|
||||||
|
console.log('ris', ris);
|
||||||
|
|
||||||
|
// Invia una notifica alla persona
|
||||||
|
await tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, false, true, username_action);
|
||||||
|
|
||||||
} else if (cmd === shared_consts.GROUPSCMD.DELETE_GROUP) {
|
} else if (cmd === shared_consts.GROUPSCMD.DELETE_GROUP) {
|
||||||
|
|
||||||
ris = await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
ris = await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
||||||
|
|
||||||
if (ris) {
|
if (ris) {
|
||||||
// Invia una notifica alla persona e agli Admin
|
// Invia una notifica alla persona e agli Admin
|
||||||
await tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, true, username_action);
|
await tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, false, true, username_action);
|
||||||
|
|
||||||
}
|
}
|
||||||
ris = await MyGroup.deleteGroup(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
ris = await MyGroup.deleteGroup(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
||||||
@@ -1854,7 +1927,7 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
//++Todo: Send Notification to Admin and Group's manager
|
//++Todo: Send Notification to Admin and Group's manager
|
||||||
tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, true, username_action);
|
tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, false, true, username_action);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -1872,6 +1945,7 @@ function getWhatToShow(idapp, username) {
|
|||||||
surname: 1,
|
surname: 1,
|
||||||
deleted: 1,
|
deleted: 1,
|
||||||
sospeso: 1,
|
sospeso: 1,
|
||||||
|
reported: 1,
|
||||||
verified_email: 1,
|
verified_email: 1,
|
||||||
verified_by_aportador: 1,
|
verified_by_aportador: 1,
|
||||||
notask_verif: 1,
|
notask_verif: 1,
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ const UserCost = {
|
|||||||
'profile.teleg_id',
|
'profile.teleg_id',
|
||||||
'profile.manage_telegram',
|
'profile.manage_telegram',
|
||||||
'deleted',
|
'deleted',
|
||||||
|
'reported',
|
||||||
],
|
],
|
||||||
|
|
||||||
FIELDS_REQUISITI: [
|
FIELDS_REQUISITI: [
|
||||||
@@ -247,6 +248,11 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
mydata.userId = req.user._id;
|
mydata.userId = req.user._id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shared_consts.TABLES_CREATEDBY.includes(params.table)) {
|
||||||
|
if (!mydata.createdBy)
|
||||||
|
mydata.createdBy = req.user.username;
|
||||||
|
}
|
||||||
|
|
||||||
if (shared_consts.TABLES_PERM_NEWREC.includes(params.table)) {
|
if (shared_consts.TABLES_PERM_NEWREC.includes(params.table)) {
|
||||||
if (!consentito) {
|
if (!consentito) {
|
||||||
mydata.verifyrec = false;
|
mydata.verifyrec = false;
|
||||||
@@ -332,7 +338,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
let setnotif = false;
|
let setnotif = false;
|
||||||
let typedir = 0;
|
let typedir = 0;
|
||||||
let typeid = 0;
|
let typeid = 0;
|
||||||
let groupNameDest = '';
|
let groupnameDest = '';
|
||||||
|
|
||||||
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(params.table)) {
|
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(params.table)) {
|
||||||
typedir = shared_consts.TypeNotifs.TYPEDIR_BACHECA;
|
typedir = shared_consts.TypeNotifs.TYPEDIR_BACHECA;
|
||||||
@@ -349,12 +355,12 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(params.table)) {
|
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(params.table)) {
|
||||||
typedir = shared_consts.TypeNotifs.TYPEDIR_GROUPS;
|
typedir = shared_consts.TypeNotifs.TYPEDIR_GROUPS;
|
||||||
typeid = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
typeid = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
||||||
groupNameDest = myrec ? myrec.groupname : '';
|
groupnameDest = myrec ? myrec.groupname : '';
|
||||||
setnotif = true;
|
setnotif = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setnotif) {
|
if (setnotif) {
|
||||||
await SendNotif.createNewNotification(req, res, {groupNameDest}, params.table, myrec, typedir, typeid);
|
await SendNotif.createNewNotification(req, res, {groupnameDest}, params.table, myrec, typedir, typeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.table === shared_consts.TAB_MYGROUPS && isnewrec) {
|
if (params.table === shared_consts.TAB_MYGROUPS && isnewrec) {
|
||||||
@@ -502,6 +508,7 @@ router.post('/getexp', authenticate, (req, res) => {
|
|||||||
{
|
{
|
||||||
username: 1,
|
username: 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
|
'reported': 1,
|
||||||
'profile.teleg_id': 1,
|
'profile.teleg_id': 1,
|
||||||
'verified_by_aportador': 1,
|
'verified_by_aportador': 1,
|
||||||
'profile.username_telegram': 1,
|
'profile.username_telegram': 1,
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ const {ObjectID} = require('mongodb');
|
|||||||
|
|
||||||
async function getGroupRecAdminsInfo(idapp, data) {
|
async function getGroupRecAdminsInfo(idapp, data) {
|
||||||
|
|
||||||
|
if (data && data.admins) {
|
||||||
for (const admin of data.admins) {
|
for (const admin of data.admins) {
|
||||||
const myuser = await User.findOne({idapp, username: admin.username}).lean();
|
const myuser = await User.findOne({idapp, username: admin.username}, {'profile.img': 1}).lean();
|
||||||
admin.profile = {img: myuser.profile.img};
|
admin.profile = {img: myuser.profile.img};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -424,9 +424,19 @@ router.post('/panel', authenticate, async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
const myuser = await User.findOne({idapp, username},
|
const myuser = await User.findOne({idapp, username},
|
||||||
{
|
{
|
||||||
username: 1, email: 1, verified_by_aportador: 1, aportador_solidario: 1,
|
username: 1,
|
||||||
|
name: 1,
|
||||||
|
surname: 1,
|
||||||
|
email: 1,
|
||||||
|
verified_by_aportador: 1,
|
||||||
|
aportador_solidario: 1,
|
||||||
lasttimeonline: 1,
|
lasttimeonline: 1,
|
||||||
deleted: 1,
|
deleted: 1,
|
||||||
|
sospeso: 1,
|
||||||
|
blocked: 1,
|
||||||
|
reported: 1,
|
||||||
|
username_who_report: 1,
|
||||||
|
date_report: 1,
|
||||||
profile: 1,
|
profile: 1,
|
||||||
}).lean();
|
}).lean();
|
||||||
if (!!myuser) {
|
if (!!myuser) {
|
||||||
@@ -647,7 +657,7 @@ router.post('/friends/cmd', authenticate, async (req, res) => {
|
|||||||
usernameOrig = await User.getRealUsernameByUsername(idapp, usernameOrig);
|
usernameOrig = await User.getRealUsernameByUsername(idapp, usernameOrig);
|
||||||
usernameDest = await User.getRealUsernameByUsername(idapp, usernameDest);
|
usernameDest = await User.getRealUsernameByUsername(idapp, usernameDest);
|
||||||
|
|
||||||
return User.setFriendsCmd(idapp, usernameOrig, usernameDest, cmd, value).
|
return User.setFriendsCmd(req, idapp, usernameOrig, usernameDest, cmd, value).
|
||||||
then((ris) => {
|
then((ris) => {
|
||||||
res.send(ris);
|
res.send(ris);
|
||||||
}).
|
}).
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ async function faitest() {
|
|||||||
|
|
||||||
const langdest = 'it';
|
const langdest = 'it';
|
||||||
|
|
||||||
telegrambot.askConfirmationUser(req, res, myuser.idapp, shared_consts.CallFunz.REGISTRATION, myuser);
|
telegrambot.askConfirmationUser(myuser.idapp, shared_consts.CallFunz.REGISTRATION, myuser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ const txt = {
|
|||||||
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
||||||
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
|
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
|
||||||
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK + '🚫 %s Non è stato Abilitato !',
|
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK + '🚫 %s Non è stato Abilitato !',
|
||||||
MSG_ISCRITTO_CONACREIS: emo.FIRE + ' Si è appena Iscritto al Conacreis "%s"',
|
MSG_ISCRITTO_CONACREIS: emo.FIRE + '[%] Si è appena Iscritto al Conacreis "%s"',
|
||||||
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
||||||
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
|
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
|
||||||
MSG_MSG_INCORSO: emoji.get('envelope') + ' messaggi in corso... Inviati attualmente',
|
MSG_MSG_INCORSO: emoji.get('envelope') + ' messaggi in corso... Inviati attualmente',
|
||||||
@@ -683,7 +683,7 @@ const txt_pt = {
|
|||||||
|
|
||||||
const TelegramBot = require('node-telegram-bot-api');
|
const TelegramBot = require('node-telegram-bot-api');
|
||||||
|
|
||||||
const ADMIN_IDTELEGRAM_TEST = 5356627050; // 5022837609; //Perseo
|
const ADMIN_IDTELEGRAM_TEST = 5356627050; // 5022837609; //Surya Arena
|
||||||
|
|
||||||
const MyTelegramBot = {
|
const MyTelegramBot = {
|
||||||
|
|
||||||
@@ -807,7 +807,9 @@ const MyTelegramBot = {
|
|||||||
let langdest = mylocalsconf.iscritto.lang;
|
let langdest = mylocalsconf.iscritto.lang;
|
||||||
let NameFrom = `${mylocalsconf.iscritto.name} ${mylocalsconf.iscritto.surname}`;
|
let NameFrom = `${mylocalsconf.iscritto.name} ${mylocalsconf.iscritto.surname}`;
|
||||||
|
|
||||||
let text = printf(getstr(langdest, 'MSG_ISCRITTO_CONACREIS'), NameFrom);
|
let nomeapp = tools.getHostByIdApp(mylocalsconf.idapp);
|
||||||
|
|
||||||
|
let text = printf(getstr(langdest, 'MSG_ISCRITTO_CONACREIS'), nomeapp, NameFrom);
|
||||||
|
|
||||||
let addtext = '';
|
let addtext = '';
|
||||||
|
|
||||||
@@ -891,14 +893,24 @@ const MyTelegramBot = {
|
|||||||
try {
|
try {
|
||||||
const cl = getclTelegByidapp(idapp);
|
const cl = getclTelegByidapp(idapp);
|
||||||
|
|
||||||
|
const {SendNotif} = require('../models/sendnotif');
|
||||||
|
|
||||||
const langdest = myuser.lang;
|
const langdest = myuser.lang;
|
||||||
|
|
||||||
let keyb = null;
|
let keyb = null;
|
||||||
let domanda = '';
|
let domanda = '';
|
||||||
|
let sendnotif = false;
|
||||||
|
let typedir = 0;
|
||||||
|
let typeid = 0;
|
||||||
|
let paramsObj = {};
|
||||||
|
|
||||||
const struserinfomsg = tools.getUserInfoMsg(idapp, myuser);
|
const struserinfomsg = tools.getUserInfoMsg(idapp, myuser);
|
||||||
|
|
||||||
if (myfunc === shared_consts.CallFunz.RICHIESTA_AMICIZIA) {
|
if (myfunc === shared_consts.CallFunz.RICHIESTA_AMICIZIA) {
|
||||||
|
sendnotif = true;
|
||||||
|
typedir = shared_consts.TypeNotifs.TYPEDIR_FRIENDS;
|
||||||
|
typeid = shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC;
|
||||||
|
paramsObj = {usernameDest: userDest}
|
||||||
|
|
||||||
domanda = printf(tools.gettranslate('RICHIESTA_AMICIZIA', langdest), myuser.username) + '<br>' + struserinfomsg;
|
domanda = printf(tools.gettranslate('RICHIESTA_AMICIZIA', langdest), myuser.username) + '<br>' + struserinfomsg;
|
||||||
|
|
||||||
@@ -920,6 +932,13 @@ const MyTelegramBot = {
|
|||||||
await this.local_sendMsgTelegramByIdTelegram(idapp, teleg_id, domanda, undefined, undefined, true, keyb);
|
await this.local_sendMsgTelegramByIdTelegram(idapp, teleg_id, domanda, undefined, undefined, true, keyb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (sendnotif) {
|
||||||
|
const req = this.getReqByPar(idapp, username);
|
||||||
|
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||||
|
await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, true, typedir, typeid);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error askConfirmationUser', e);
|
console.error('Error askConfirmationUser', e);
|
||||||
}
|
}
|
||||||
@@ -1224,7 +1243,7 @@ async function sendMsgTelegramToTheAdmin(idapp, text, msg) {
|
|||||||
async function setVerifiedReg(idapp, lang, usernameorig, usernameDest) {
|
async function setVerifiedReg(idapp, lang, usernameorig, usernameDest) {
|
||||||
try {
|
try {
|
||||||
await User.setVerifiedByAportador(idapp, usernameorig, true);
|
await User.setVerifiedByAportador(idapp, usernameorig, true);
|
||||||
await User.setFriendsCmd(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'),
|
const msgDest = printf(getstr(lang, 'MSG_APORTADOR_CONFIRMED'),
|
||||||
`${usernameorig}`, usernameDest);
|
`${usernameorig}`, usernameDest);
|
||||||
@@ -3838,7 +3857,8 @@ if (true) {
|
|||||||
Cmd.VALIDATE_REGISTRATION, true);
|
Cmd.VALIDATE_REGISTRATION, true);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
await User.setFriendsCmd(user.idapp, data.username, userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
|
const req = tools.getReqByPar(user.idapp, username_action);
|
||||||
|
await User.setFriendsCmd(req, user.idapp, data.username, userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
|
||||||
|
|
||||||
await User.setaportador_solidario(user.idapp, data.username, userDest.username);
|
await User.setaportador_solidario(user.idapp, data.username, userDest.username);
|
||||||
|
|
||||||
@@ -3898,7 +3918,8 @@ if (true) {
|
|||||||
|
|
||||||
if (!foundIfAlreadyFriend) {
|
if (!foundIfAlreadyFriend) {
|
||||||
// Aggiungilo nelle Amicizie
|
// Aggiungilo nelle Amicizie
|
||||||
const ris = await User.setFriendsCmd(user.idapp, data.username, data.userDest, cmd);
|
const req = tools.getReqByPar(user.idapp, username_action);
|
||||||
|
const ris = await User.setFriendsCmd(req, user.idapp, data.username, data.userDest, cmd);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3911,7 +3932,7 @@ if (true) {
|
|||||||
|
|
||||||
if (foundIfAlreadyFriend) {
|
if (foundIfAlreadyFriend) {
|
||||||
// Aggiungilo nelle Amicizie
|
// Aggiungilo nelle Amicizie
|
||||||
const ris = await User.setFriendsCmd(user.idapp, data.username, data.userDest, cmd);
|
const ris = await User.setFriendsCmd(req, user.idapp, data.username, data.userDest, cmd);
|
||||||
if (ris) {
|
if (ris) {
|
||||||
const msgDest = printf(getstr(user.lang, 'MSG_FRIENDS_NOT_ACCEPTED_CONFIRMED'), data.username);
|
const msgDest = printf(getstr(user.lang, 'MSG_FRIENDS_NOT_ACCEPTED_CONFIRMED'), data.username);
|
||||||
|
|
||||||
|
|||||||
@@ -128,9 +128,7 @@ const textlang = {
|
|||||||
'ACCETTATO_SUL_GRUPPO': '✅ Sei stato accettato da %s a far parte del Gruppo %s',
|
'ACCETTATO_SUL_GRUPPO': '✅ Sei stato accettato da %s a far parte del Gruppo %s',
|
||||||
'CREATO_NUOVO_GRUPPO': '✅ Hai appena creato un nuovo Gruppo chiamato %s',
|
'CREATO_NUOVO_GRUPPO': '✅ Hai appena creato un nuovo Gruppo chiamato %s',
|
||||||
'ACCETTATO_NOTIFICA_ADMINS': '✅ l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
'ACCETTATO_NOTIFICA_ADMINS': '✅ l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
||||||
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
|
'GROUP_REQUEST': 'Richiesta di entrare nel Gruppo %s da parte di %s',
|
||||||
'GRUPPO_ELIMINATO': 'Il gruppo %s è stato eliminato da parte di %s',
|
|
||||||
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
|
|
||||||
},
|
},
|
||||||
si: {},
|
si: {},
|
||||||
es: {
|
es: {
|
||||||
@@ -199,7 +197,6 @@ const textlang = {
|
|||||||
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
|
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
|
||||||
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
|
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
|
||||||
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
||||||
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
|
|
||||||
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
|
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
|
||||||
},
|
},
|
||||||
enUs: {
|
enUs: {
|
||||||
@@ -263,7 +260,6 @@ const textlang = {
|
|||||||
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
|
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
|
||||||
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
|
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
|
||||||
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
||||||
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
|
|
||||||
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
|
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
|
||||||
},
|
},
|
||||||
fr: {
|
fr: {
|
||||||
@@ -332,7 +328,6 @@ const textlang = {
|
|||||||
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
|
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
|
||||||
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
|
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
|
||||||
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
||||||
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
|
|
||||||
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
|
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
|
||||||
},
|
},
|
||||||
pt: {
|
pt: {
|
||||||
@@ -399,7 +394,7 @@ const textlang = {
|
|||||||
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
|
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
|
||||||
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
|
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
|
||||||
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
||||||
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
|
|
||||||
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
|
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -587,6 +582,7 @@ module.exports = {
|
|||||||
'deleted',
|
'deleted',
|
||||||
'idapp',
|
'idapp',
|
||||||
'tablerec',
|
'tablerec',
|
||||||
|
'extrafield',
|
||||||
'idrec',
|
'idrec',
|
||||||
'status'];
|
'status'];
|
||||||
},
|
},
|
||||||
@@ -741,7 +737,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
then(ris => {
|
then(ris => {
|
||||||
console.log('sendNotification', ris)
|
console.log('sendNotification', ris);
|
||||||
}).
|
}).
|
||||||
catch(err => {
|
catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@@ -862,7 +858,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
username: usernameOrig,
|
username: usernameOrig,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -895,11 +891,6 @@ module.exports = {
|
|||||||
|
|
||||||
const userrecDest = await User.getUserShortDataByUsername(idapp, usernameOrig);
|
const userrecDest = await User.getUserShortDataByUsername(idapp, usernameOrig);
|
||||||
|
|
||||||
const req = this.getReqByPar(idapp, usernameOrig);
|
|
||||||
|
|
||||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
|
||||||
SendNotif.createNewNotifToSingleUser(req, null, {usernameDest: username}, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS, shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC);
|
|
||||||
|
|
||||||
if (userrecDest) {
|
if (userrecDest) {
|
||||||
sendmynotif = false; // non lo rimandare 2 volte !
|
sendmynotif = false; // non lo rimandare 2 volte !
|
||||||
// SEND TELEGRAM NOTIFICATION
|
// SEND TELEGRAM NOTIFICATION
|
||||||
@@ -940,107 +931,106 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
sendNotificationByGroupname: async function(idapp, usernameOrig, groupname, cmd, telegram, username_action) {
|
sendNotifGroupByUsername: async function(cmd, typeid_pass, idapp, usernameOrig, usernameDest, username_action, groupname, myrecgroup, isAdmin, username_worked) {
|
||||||
|
|
||||||
var {User} = require('../models/user');
|
|
||||||
var {MyGroup} = require('../models/mygroup');
|
|
||||||
|
|
||||||
|
const {SendNotif} = require('../models/sendnotif');
|
||||||
|
const {User} = require('../models/user');
|
||||||
const telegrambot = require('../telegram/telegrambot');
|
const telegrambot = require('../telegram/telegrambot');
|
||||||
|
|
||||||
const group = await MyGroup.findOne({idapp, groupname},
|
const req = this.getReqByPar(idapp, usernameOrig);
|
||||||
{_id: 1, admins: 1});
|
|
||||||
if (!group)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Send msg to Admins
|
const user = await User.findOne({idapp, username: usernameDest},
|
||||||
|
|
||||||
const arrusernameAdmins = group.admins;
|
|
||||||
|
|
||||||
const myuser = await User.findOne({idapp, username: usernameOrig}).lean();
|
|
||||||
|
|
||||||
let struserinfomsg = this.getUserInfoMsg(idapp, myuser);
|
|
||||||
|
|
||||||
let objmsg = {
|
|
||||||
title: this.getNomeAppByIdApp(idapp),
|
|
||||||
descr: '',
|
|
||||||
openUrl: '/',
|
|
||||||
tag: '',
|
|
||||||
actions: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
let creazionegruppo = false;
|
|
||||||
|
|
||||||
for (const singleadmin of arrusernameAdmins) {
|
|
||||||
try {
|
|
||||||
if (singleadmin.username) {
|
|
||||||
|
|
||||||
creazionegruppo = arrusernameAdmins.length === 1 && usernameOrig === singleadmin.username && cmd ===
|
|
||||||
shared_consts.GROUPSCMD.SETGROUP;
|
|
||||||
|
|
||||||
const user = await User.findOne({idapp, username: singleadmin.username},
|
|
||||||
{_id: 1, lang: 1});
|
{_id: 1, lang: 1});
|
||||||
if (user) {
|
if (user) {
|
||||||
|
|
||||||
let userId = user._id;
|
|
||||||
let lang = user.lang;
|
let lang = user.lang;
|
||||||
|
let paramsObj = {
|
||||||
|
usernameDest,
|
||||||
|
groupnameDest: groupname,
|
||||||
|
username_action: username_action,
|
||||||
|
singleadmin_username: usernameDest,
|
||||||
|
options: 0,
|
||||||
|
lang,
|
||||||
|
isAdmin,
|
||||||
|
username_worked,
|
||||||
|
};
|
||||||
|
|
||||||
let sendnotif = true;
|
let sendnotif = true;
|
||||||
|
let typedir = shared_consts.TypeNotifs.TYPEDIR_GROUPS;
|
||||||
|
let typeid = 0;
|
||||||
|
let onlysave = false;
|
||||||
|
let numuseringroup = await User.countUsersInGroup(idapp, groupname);
|
||||||
|
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
if (cmd === shared_consts.GROUPSCMD.SETGROUP) {
|
if (cmd === shared_consts.GROUPSCMD.SETGROUP) {
|
||||||
if (creazionegruppo) {
|
if (myrecgroup && myrecgroup.createdBy === usernameDest && numuseringroup <= 1) {
|
||||||
objmsg.descr = printf(this.get__('CREATO_NUOVO_GRUPPO', lang), groupname);
|
typeid = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
||||||
} else {
|
} else {
|
||||||
objmsg.descr = printf(this.get__('ACCETTATO_NOTIFICA_ADMINS', lang), usernameOrig, groupname, username_action);
|
typeid = shared_consts.TypeNotifs.ID_GROUP_ACCEPTED;
|
||||||
}
|
}
|
||||||
objmsg.openUrl = '/grp/' + groupname;
|
} else if (cmd === shared_consts.GROUPSCMD.REFUSE_REQ_GROUP) {
|
||||||
objmsg.tag = 'addgroups';
|
typeid = shared_consts.TypeNotifs.ID_GROUP_REFUSED;
|
||||||
|
} else if (cmd === shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP) {
|
||||||
|
typeid = shared_consts.TypeNotifs.ID_GROUP_REMOVED;
|
||||||
} else if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
|
} else if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
|
||||||
objmsg.descr = printf(this.get__('RICHIESTA_GRUPPO', lang), groupname,
|
typeid = shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER;
|
||||||
singleadmin.username);
|
// paramsObj.options = MessageOptions.Notify_OnlyToNotifinApp + MessageOptions.Notify_ByBotTelegram;
|
||||||
objmsg.openUrl = '/grp/' + groupname;
|
const myuserdata = await User.getUserShortDataByUsername(idapp, username_action);
|
||||||
objmsg.tag = 'reqgroups';
|
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_GRUPPO, myuserdata, usernameDest, groupname, myrecgroup._id);
|
||||||
|
onlysave = false;
|
||||||
sendnotif = false; // non lo rimandare 2 volte !
|
|
||||||
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_GRUPPO, myuser, singleadmin.username, groupname,
|
|
||||||
group._id);
|
|
||||||
|
|
||||||
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_USER) {
|
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_USER) {
|
||||||
objmsg.descr = printf(this.get__('RICHIESTA_BLOCCO_GRUPPO', lang),
|
typeid = shared_consts.TypeNotifs.ID_GROUP_BLOCK_USER;
|
||||||
groupname, singleadmin.username);
|
|
||||||
objmsg.openUrl = '/grp/' + groupname;
|
|
||||||
objmsg.tag = 'blockgroups';
|
|
||||||
} else if (cmd === shared_consts.GROUPSCMD.DELETE_GROUP) {
|
} else if (cmd === shared_consts.GROUPSCMD.DELETE_GROUP) {
|
||||||
objmsg.descr = printf(this.get__('GRUPPO_ELIMINATO', lang), groupname, username_action);
|
typeid = shared_consts.TypeNotifs.ID_GROUP_DELETE_USER;
|
||||||
objmsg.openUrl = '/grp/' + groupname;
|
|
||||||
objmsg.tag = 'deletegroup';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeid_pass) {
|
||||||
|
typeid = typeid_pass;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendnotif && objmsg.descr && !creazionegruppo) {
|
if (sendnotif && typeid > 0) {
|
||||||
await this.sendNotifAndMsgTelegram(idapp, userId, objmsg, telegram, struserinfomsg);
|
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||||
|
await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
},
|
||||||
|
|
||||||
|
sendNotificationByGroupname: async function(idapp, usernameOrig, groupname, cmd, value, telegram, username_action) {
|
||||||
|
|
||||||
|
const {MyGroup} = require('../models/mygroup');
|
||||||
|
const {User} = require('../models/user');
|
||||||
|
|
||||||
|
|
||||||
|
const group = await MyGroup.findOne({idapp, groupname}, {_id: 1, admins: 1, createdBy: 1}).lean();
|
||||||
|
if (!group)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let giainviato = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// SEND TO THE ADMINS THE NOTIFICATIONS
|
||||||
|
for (const singleadmin of group.admins) {
|
||||||
|
try {
|
||||||
|
if (singleadmin.username) {
|
||||||
|
if (usernameOrig === singleadmin.username)
|
||||||
|
giainviato = true;
|
||||||
|
|
||||||
|
await this.sendNotifGroupByUsername(cmd, 0, idapp, usernameOrig, singleadmin.username, username_action, groupname, group, true);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('sendNotificationByGroupname', e);
|
console.error('sendNotificationByGroupname', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd === shared_consts.GROUPSCMD.SETGROUP) {
|
if (!giainviato && (cmd !== shared_consts.GROUPSCMD.REQGROUP)) {
|
||||||
const reclang = await User.getRecLangAndIdByUsername(idapp, usernameOrig);
|
// SEND TO THE USER THE NOTIFICATION
|
||||||
objmsg.openUrl = '/grp/' + groupname;
|
await this.sendNotifGroupByUsername(cmd, value, idapp, usernameOrig, usernameOrig, username_action, groupname, false);
|
||||||
objmsg.tag = 'addgroups';
|
|
||||||
if (creazionegruppo) {
|
|
||||||
objmsg.descr = printf(this.get__('CREATO_NUOVO_GRUPPO', reclang.lang), groupname);
|
|
||||||
} else {
|
|
||||||
objmsg.descr = printf(this.get__('ACCETTATO_SUL_GRUPPO', reclang.lang), username_action, groupname);
|
|
||||||
}
|
}
|
||||||
// Send to User:
|
|
||||||
await this.sendNotifAndMsgTelegram(idapp, reclang._id, objmsg, telegram);
|
} catch (e) {
|
||||||
|
console.error('e', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -1131,7 +1121,7 @@ module.exports = {
|
|||||||
return {
|
return {
|
||||||
exit: true,
|
exit: true,
|
||||||
ret: false,
|
ret: false,
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
exit: true,
|
exit: true,
|
||||||
@@ -1208,11 +1198,11 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getLinkUserProfile: function(idapp, username) {
|
getLinkUserProfile: function(idapp, username) {
|
||||||
return tools.getHostByIdApp(idapp) + '/my/' + username;
|
return this.getHostByIdApp(idapp) + '/my/' + username;
|
||||||
},
|
},
|
||||||
|
|
||||||
getLinkEditUserProfile: function(idapp) {
|
getLinkEditUserProfile: function(idapp) {
|
||||||
return tools.getHostByIdApp(idapp) + '/editprofile';
|
return this.getHostByIdApp(idapp) + '/editprofile';
|
||||||
},
|
},
|
||||||
|
|
||||||
getConfSiteOptionEnabledByIdApp: function(idapp, option) {
|
getConfSiteOptionEnabledByIdApp: function(idapp, option) {
|
||||||
@@ -2964,22 +2954,22 @@ module.exports = {
|
|||||||
|
|
||||||
capitalize(value) {
|
capitalize(value) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return ''
|
return '';
|
||||||
}
|
}
|
||||||
const myval = value.toString()
|
const myval = value.toString();
|
||||||
return myval.charAt(0).toUpperCase() + myval.slice(1)
|
return myval.charAt(0).toUpperCase() + myval.slice(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
firstchars(value, numchars = 200) {
|
firstchars(value, numchars = 200) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return ''
|
return '';
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let mycar = value.substring(0, numchars)
|
let mycar = value.substring(0, numchars);
|
||||||
if (value.length > numchars) mycar += '...'
|
if (value.length > numchars) mycar += '...';
|
||||||
return mycar
|
return mycar;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return value
|
return value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -2994,17 +2984,17 @@ module.exports = {
|
|||||||
updateQueryStringParameter(uri, key, value) {
|
updateQueryStringParameter(uri, key, value) {
|
||||||
if (uri === '')
|
if (uri === '')
|
||||||
return '';
|
return '';
|
||||||
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
|
var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
|
||||||
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
|
var separator = uri.indexOf('?') !== -1 ? '&' : '?';
|
||||||
if (uri.match(re)) {
|
if (uri.match(re)) {
|
||||||
return uri.replace(re, '$1' + key + "=" + value + '$2');
|
return uri.replace(re, '$1' + key + '=' + value + '$2');
|
||||||
} else {
|
} else {
|
||||||
return uri + separator + key + "=" + value;
|
return uri + separator + key + '=' + value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
isArray(val) {
|
isArray(val) {
|
||||||
return Array.isArray(val)
|
return Array.isArray(val);
|
||||||
},
|
},
|
||||||
|
|
||||||
getContentByTypeMsg(typemsg) {
|
getContentByTypeMsg(typemsg) {
|
||||||
@@ -3021,6 +3011,6 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ module.exports = {
|
|||||||
REFUSE_REQ_FRIEND: 145,
|
REFUSE_REQ_FRIEND: 145,
|
||||||
CANCEL_REQ_FRIEND: 146,
|
CANCEL_REQ_FRIEND: 146,
|
||||||
BLOCK_USER: 155,
|
BLOCK_USER: 155,
|
||||||
|
REPORT_USER: 158,
|
||||||
FIND_PEOPLE: 166,
|
FIND_PEOPLE: 166,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -134,6 +135,7 @@ module.exports = {
|
|||||||
'circuits',
|
'circuits',
|
||||||
'movements'],
|
'movements'],
|
||||||
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||||
|
TABLES_CREATEDBY: ['mygroups'],
|
||||||
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots'],
|
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots'],
|
||||||
|
|
||||||
TABLES_PERM_CHANGE_FOR_USERS: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
TABLES_PERM_CHANGE_FOR_USERS: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||||
@@ -203,6 +205,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
MessageOptions: {
|
MessageOptions: {
|
||||||
|
Notify_OnlyToNotifinApp: 1,
|
||||||
Notify_ByEmail: 2,
|
Notify_ByEmail: 2,
|
||||||
Notify_ByPushNotification: 4,
|
Notify_ByPushNotification: 4,
|
||||||
Notify_ByBotTelegram: 8,
|
Notify_ByBotTelegram: 8,
|
||||||
@@ -291,14 +294,16 @@ module.exports = {
|
|||||||
StatusNotifs: {
|
StatusNotifs: {
|
||||||
STATUS_FRIENDS_ACCEPTED: 1,
|
STATUS_FRIENDS_ACCEPTED: 1,
|
||||||
STATUS_FRIENDS_REFUSED: 2,
|
STATUS_FRIENDS_REFUSED: 2,
|
||||||
STATUS_GROUPS_ACCEPTED: 3,
|
STATUS_FRIENDS_REPORTED: 3,
|
||||||
STATUS_GROUPS_REFUSED: 4,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
GroupsNotifs: {
|
GroupsNotifs: {
|
||||||
STATUS_GROUPS_NEW: 1,
|
STATUS_GROUPS_NEW: 1,
|
||||||
STATUS_GROUPS_ACCEPTED: 2,
|
STATUS_GROUPS_ACCEPTED: 3,
|
||||||
STATUS_GROUPS_REFUSED: 4,
|
STATUS_GROUPS_REFUSED: 4,
|
||||||
|
STATUS_GROUPS_BLOCKED: 5,
|
||||||
|
STATUS_GROUPS_DELETED: 6,
|
||||||
|
STATUS_GROUPS_REMOVED: 7,
|
||||||
},
|
},
|
||||||
|
|
||||||
TypeNotifs: {
|
TypeNotifs: {
|
||||||
@@ -315,11 +320,16 @@ module.exports = {
|
|||||||
ID_FRIENDS_ACCEPTED: 2,
|
ID_FRIENDS_ACCEPTED: 2,
|
||||||
ID_FRIENDS_REFUSED: 4,
|
ID_FRIENDS_REFUSED: 4,
|
||||||
ID_FRIENDS_ACCEPTED_MY_REQUEST: 8,
|
ID_FRIENDS_ACCEPTED_MY_REQUEST: 8,
|
||||||
|
ID_FRIENDS_REPORTED: 16,
|
||||||
|
|
||||||
TYPEDIR_GROUPS: 4,
|
TYPEDIR_GROUPS: 4,
|
||||||
ID_GROUP_NEW_REC: 1,
|
ID_GROUP_NEW_REC: 1,
|
||||||
ID_GROUP_ACCEPTED: 2,
|
ID_GROUP_ACCEPTED: 2,
|
||||||
ID_GROUP_REFUSED: 4,
|
ID_GROUP_REFUSED: 4,
|
||||||
|
ID_GROUP_REQUEST_TO_ENTER: 8,
|
||||||
|
ID_GROUP_BLOCK_USER: 16,
|
||||||
|
ID_GROUP_DELETE_USER: 32,
|
||||||
|
ID_GROUP_REMOVED: 64,
|
||||||
|
|
||||||
TYPEDIR_CIRCUITS: 5,
|
TYPEDIR_CIRCUITS: 5,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user