Add to the Circuit
Remove to the Circuit Revoke request Users Admins
This commit is contained in:
@@ -12,6 +12,7 @@ const printf = require('util').format;
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
const {Circuit} = require('../models/circuit');
|
||||
const {CalZoom} = require('../models/calzoom');
|
||||
const {MyBot} = require('../models/bot');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
@@ -450,6 +451,7 @@ const Status = {
|
||||
const Cmd = {
|
||||
VALIDATE_REGISTRATION: 1,
|
||||
RICHIESTA_GRUPPO: 2,
|
||||
RICHIESTA_CIRCUIT: 3,
|
||||
};
|
||||
|
||||
const Destin = {
|
||||
@@ -864,6 +866,20 @@ const MyTelegramBot = {
|
||||
|
||||
domanda = printf(getstr(langdest, 'MSG_ACCEPT_NEWENTRY_INGROUP'), groupname) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Accetta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + groupid,
|
||||
},
|
||||
{
|
||||
text: '🚫 Rifiuta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + groupid,
|
||||
},
|
||||
]);
|
||||
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
domanda = i18n.__({phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest} , groupname) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Accetta ' + myuser.username,
|
||||
@@ -3822,9 +3838,13 @@ if (true) {
|
||||
const userDest = data.userDest ? await User.getUserShortDataByUsername(idapp, data.userDest) : null;
|
||||
|
||||
let group = null;
|
||||
let circuit = null;
|
||||
if (data.groupId) {
|
||||
group = await MyGroup.findOne({idapp, _id: data.groupId}).lean();
|
||||
}
|
||||
if (data.circuitId) {
|
||||
circuit = await Circuit.findOne({idapp, _id: data.circuitId}).lean();
|
||||
}
|
||||
|
||||
let cmd = 0;
|
||||
|
||||
@@ -3912,6 +3932,30 @@ if (true) {
|
||||
await User.setGroupsCmd(user.idapp, data.username, group.groupname, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (circuit) {
|
||||
cmd = shared_consts.CIRCUITCMD.SET;
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||
|
||||
if (!foundIfAlreadyCircuit) {
|
||||
// Aggiungilo nel Gruppo
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (circuit) {
|
||||
cmd = shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST;
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||
|
||||
if (foundIfAlreadyCircuit) {
|
||||
// Rimuovilo nel Circuito
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_AMICIZIA) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user