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;
}