piccole modifiche...

This commit is contained in:
Surya Paolo
2025-01-12 21:29:05 +01:00
parent c631ca9d6a
commit 45be5038b9
9 changed files with 15 additions and 34 deletions

View File

@@ -599,7 +599,7 @@ async function inizia() {
if (process.env.NODE_ENV === 'development') {
await telegrambot.sendMsgTelegram(tools.FREEPLANET,
telegrambot.ADMIN_USER_SERVER,
shared_consts.ADMIN_USER_SERVER,
`Ciao ${telegrambot.ADMIN_USER_NAME_SERVER}!`);
await telegrambot.sendMsgTelegramByIdTelegram(tools.FREEPLANET,

View File

@@ -1107,7 +1107,7 @@ CircuitSchema.statics.getCircuitMyProvince = async function (idapp, username) {
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province, card) {
const { User } = require('../models/user');
const useradmin = tools.USER_ADMIN_CIRCUITS;
const useradmin = shared_consts.USER_ADMIN_CIRCUITS;
let myrec = null;
try {

View File

@@ -409,7 +409,7 @@ module.exports.createFirstUserAdmin = async function () {
if (numusers === 0) {
// Non esistono utenti, quindi creo quello di Admin
const utenteadmin = { idapp: '13', username: telegrambot.ADMIN_USER_SERVER };
const utenteadmin = { idapp: '13', username: shared_consts.ADMIN_USER_SERVER };
const newuser = new User(utenteadmin);
newuser._id = new ObjectId();

View File

@@ -2653,10 +2653,10 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
shared_consts.TypeNotifs.ID_FRIENDS_REPORTED);
if (usernameOrig !== telegrambot.ADMIN_USER_SERVER) {
if (usernameOrig !== shared_consts.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,
{ username_worked, usernameDest: shared_consts.ADMIN_USER_SERVER, username_action, isAdmin: true }, false,
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
shared_consts.TypeNotifs.ID_FRIENDS_REPORTED);
}
@@ -2685,10 +2685,10 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED);
if (usernameOrig !== telegrambot.ADMIN_USER_SERVER) {
if (usernameOrig !== shared_consts.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,
{ username_worked, usernameDest: shared_consts.ADMIN_USER_SERVER, username_action, isAdmin: true }, false,
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED);
}
@@ -4085,22 +4085,6 @@ UserSchema.statics.isManagerByIdTeleg = async function (idapp, idtelegram) {
});
};
UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) {
const User = this;
return await User.findOne({
idapp,
username: 'paoloar77',
'profile.admin_telegram': true,
'profile.teleg_id': idtelegram,
}, { 'profile.teleg_id': 1 }).then((rec) => {
return (!!rec && rec.profile.teleg_id === idtelegram);
}).catch((e) => {
console.error('getusersManagers', e);
return false;
});
};
UserSchema.statics.isAdminByUsername = async function (idapp, username) {
const User = this;

View File

@@ -480,7 +480,7 @@ async function inizia() {
if (process.env.NODE_ENV === 'development') {
await telegrambot.sendMsgTelegram(tools.FREEPLANET,
telegrambot.ADMIN_USER_SERVER,
shared_consts.ADMIN_USER_SERVER,
`Ciao ${telegrambot.ADMIN_USER_NAME_SERVER}!`);
await telegrambot.sendMsgTelegramByIdTelegram(tools.FREEPLANET,

View File

@@ -702,7 +702,6 @@ const MyTelegramBot = {
ADMIN_IDTELEGRAM_SERVER: '12429864', //Paolo
ADMIN_USERNAME_TELEGRAM: 'surya1977', //Paolo
ADMIN_USER_SERVER: 'paoloar77',
ADMIN_USER_NAME_SERVER: 'Paolo',
phase: {
@@ -3073,9 +3072,6 @@ class Telegram {
// let chiedisino = false;
// TEST usersall = await User.getUsersTelegALL(rec.user.idapp, 'paoloar77');
for (const utente of usersall) {
let FormDaMostrare = null;
@@ -3098,7 +3094,7 @@ class Telegram {
} else if (destin === Destin.TUTTI) {
invia = true;
} else if (destin === Destin.PAOLO) {
invia = utente.username === 'paoloar77';
invia = utente.username === shared_consts.ADMIN_USER_SERVER;
} else if (destin === Destin.A_UTENTE) {
invia = utente.username === rec.msgall_username_specifico;
} else if (destin === Destin.DOMANDA) {
@@ -3644,7 +3640,6 @@ class Telegram {
// Check if you are Admin
const user = await User.UserByIdTelegram(idapp, id);
// let isAdmin = user ? user.profile.manage_telegram && user.username === 'paoloar77' : false;
let isAdmin = user ? user.profile.admin_telegram : false;
const isManager = user ? user.profile.manage_telegram : false;
const isVerified = user ? user.profile.teleg_id > 0 && user.verified_by_aportador : false;

View File

@@ -554,8 +554,6 @@ module.exports = {
SEP: '|',
USER_ADMIN_CIRCUITS: 'paoloar77',
TYPE_PROJECT: 1,
TYPE_TODO: 2,

View File

@@ -367,7 +367,7 @@ module.exports = {
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_NON_SOCI) {
addquery = { 'profile.socio': false };
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_PAOLO) {
addquery = { username: 'paoloar77' };
addquery = { username: shared_consts.ADMIN_USER_SERVER };
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_USER) {
addquery = { username: params.usernameDest };
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_MYSELF) {
@@ -426,7 +426,7 @@ module.exports = {
).lean();
if (!tools.sulServer()) {
arrusers = await User.find({ idapp, username: telegrambot.ADMIN_USER_SERVER });
arrusers = await User.find({ idapp, username: shared_consts.ADMIN_USER_SERVER });
}
for (const user of arrusers) {

View File

@@ -1,4 +1,6 @@
module.exports = {
USER_ADMIN_CIRCUITS: 'surya1977',
ADMIN_USER_SERVER: 'surya1977',
Accepted: {
CHECK_READ_GUIDELINES: 1,
CHECK_SEE_VIDEO_PRINCIPI: 2,
@@ -47,6 +49,8 @@ module.exports = {
FILTER_USER_PROVINCE: 16777216,
FILTER_USER_SENZA_PROVINCE: 33554432,
FILTER_USER_SENZA_CIRCUITO: 67108864,
FILTER_USER_CON_CIRCUITO: 134217728,
FILTER_USER_ONLINE_6_MESI: 268435456,
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,