This commit is contained in:
paoloar77
2022-02-03 00:33:15 +01:00
parent c391ca85c3
commit daf872fe55
20 changed files with 651 additions and 4831 deletions

View File

@@ -838,6 +838,53 @@ module.exports = {
},
sendNotificationByGroupname: async function(idapp, groupname, cmd, telegram) {
var {User} = require('../models/user');
var {MyGroup} = require('../models/mygroup');
const group = await MyGroup.findOne({idapp, groupname}, {_id: 1, admins: 1});
if (!group)
return;
// Send msg to Admins
const arrusernameAdmins = group.admins;
for (const username of arrusernameAdmins) {
const user = await User.get
let userId = user._id;
let lang = user.lang;
let title = this.getNomeAppByIdApp(idapp);
let descr = '';
let openUrl = '/';
let tag = '';
let actions = [];
if (cmd) {
if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
descr = printf(this.get__('RICHIESTA_AMICIZIA', lang), username);
openUrl = '/my/' + username;
tag = 'reqfriends';
}
}
if (userId) {
this.sendNotificationToUser(userId, title, descr, openUrl, '', tag,
actions);
}
if (telegram) {
const telegrambot = require('../telegram/telegrambot');
const idtelegram = await User.TelegIdByUsername(idapp, username);
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, descr);
}
}
},
// **********************
// SORT WITH PREV_ID
// **********************
@@ -2099,7 +2146,7 @@ module.exports = {
NotifyIfDelRecord(table) {
if ((table === 'users') || (table === 'extralist') ||
(table === 'listaingressos') || (table === 'graduatorias')) {
(table === 'groups') || (table === 'graduatorias')) {
return true;
}

View File

@@ -45,6 +45,17 @@ module.exports = {
FIND_PEOPLE: 166,
},
GROUPSCMD: {
SETTRUST: 1121,
REQGROUP: 1125,
SETGROUP: 1132,
REMOVE_FROM_MYGROUP: 1144,
REFUSE_REQ_GROUP: 1145,
CANCEL_REQ_GROUP: 1146,
BLOCK_GROUP: 1155,
FIND_GROUP: 1166,
},
REPORT_FILT_RESP: 1,
REPORT_FILT_ATTIVITA: 2,
@@ -69,8 +80,9 @@ module.exports = {
PARAM_SHOW_PROVINCE: 1,
TABLES_ID_NUMBER: ['permissions', 'levels', 'statusSkills', 'sectors', 'skills', 'subskills', 'cities', 'myskills'],
TABLES_USER_ID: ['myskills'],
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybots'],
TABLES_USER_ID: ['myskills', 'mygroups'],
TABLES_USER_INCLUDE_MY: ['mygroups'],
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybots', 'mygroups'],
TABLES_PERM_CHANGE_FOR_USERS: ['myskills'],
TABLES_PERM_NEWREC: ['skills', 'subskills'],