Conti Comunitari e Collettivi
This commit is contained in:
@@ -1042,6 +1042,7 @@ module.exports = {
|
||||
const { User } = require('../models/user');
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
const req = this.getReqByPar(idapp, usernameOrig, groupOrig);
|
||||
|
||||
@@ -1117,26 +1118,25 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (sendnotif && typeid > 0) {
|
||||
const groupDestoContoCom = groupDest ? groupDest : (extrarec && extrarec.contoComDest ? extrarec.contoComDest : '');
|
||||
// Check if is group:
|
||||
if (groupDest && (
|
||||
if (groupDestoContoCom && (
|
||||
(cmd !== shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT) &&
|
||||
(cmd !== shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT)
|
||||
)) {
|
||||
|
||||
let arrusers = await MyGroup.getListAdminsByGroupName(idapp, groupDest);
|
||||
let arrusers = await MyGroup.getListAdminsByGroupName(idapp, groupDestoContoCom);
|
||||
if (arrusers.length <= 0)
|
||||
arrusers = await Circuit.getListAdminsByCircuitPath(idapp, groupDestoContoCom);
|
||||
|
||||
let notiftoUpdate = '';
|
||||
let findrecnotif = await SendNotif.findOne({ _id: paramsObj.extrarec.notifId }).lean();
|
||||
notiftoUpdate = findrecnotif ? findrecnotif.extrarec.notifIdToUpdate : '';
|
||||
// arrnotiftoUpdate = findrecnotif ? findrecnotif.extrarec.arrnotifIdToUpdate : '';
|
||||
if (findrecnotif) {
|
||||
let arrrec = [];
|
||||
|
||||
if (notiftoUpdate)
|
||||
arrrec = await SendNotif.find({ 'extrarec.notifIdToUpdate': notiftoUpdate });
|
||||
// if (arrnotiftoUpdate)
|
||||
// arrrec = await SendNotif.find({'extrarec.notifIdToUpdate': notiftoUpdate});
|
||||
|
||||
|
||||
for (let rec of arrrec) {
|
||||
paramsObj.usernameDest = rec.dest;
|
||||
@@ -1149,7 +1149,7 @@ module.exports = {
|
||||
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDest)
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDestoContoCom)
|
||||
} else {
|
||||
arrris.push(ris._id);
|
||||
}
|
||||
@@ -1163,7 +1163,7 @@ module.exports = {
|
||||
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDest)
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDestoContoCom)
|
||||
} else {
|
||||
arrris.push(ris._id);
|
||||
}
|
||||
@@ -1199,7 +1199,7 @@ module.exports = {
|
||||
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDest)
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDestoContoCom)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1274,12 +1274,7 @@ module.exports = {
|
||||
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ || cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT || cmd ===
|
||||
shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
|
||||
let extrarecorig = { ...extrarec };
|
||||
let temp = ''
|
||||
temp = extrarecorig.groupdest
|
||||
extrarecorig.groupdest = extrarecorig.grouporig
|
||||
groupOrig = extrarec.grouporig
|
||||
// extrarecorig.grouporig = temp
|
||||
|
||||
let arrris = [];
|
||||
let recnotif = null;
|
||||
|
||||
Reference in New Issue
Block a user